Changeset 784

Show
Ignore:
Timestamp:
2005-01-30 13:07:50 (4 years ago)
Author:
conrad
Message:

backport cmml reparsing to not send <stream> (ticket: 41)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mod_annodex-ap13/trunk/Makefile

    r472 r784  
    1111#DEF=-Dmy_define=my_value 
    1212#INC=-Imy/include/dir 
    13 INC=`pkg-config --cflags annodex
     13INC=`pkg-config --cflags annodex cmml
    1414#LIB=-Lmy/lib/dir -lc -lmylib 
    15 LIB=`pkg-config --libs annodex
     15LIB=`pkg-config --libs annodex cmml
    1616 
    1717#   the default target 
  • mod_annodex-ap13/trunk/mod_annodex.c

    r754 r784  
    5151#include <annodex/anx_core.h> 
    5252#include <annodex/annodex.h> 
     53#include <cmml.h> 
    5354 
    5455/* define __PROTOTYPE to enable mode= parameter */ 
     
    540541#endif 
    541542 
     543#ifdef UNUSED 
    542544static int 
    543545ma_send (request_rec * r, char * filename) 
     
    563565 
    564566  ap_pfclose (r->pool, f); 
     567 
     568  return 0; 
     569} 
     570#endif 
     571 
     572static int 
     573read_cmml_stream (CMML * cmml, const CMML_Stream * stream, void * user_data) 
     574{ 
     575  request_rec * r = (request_rec *)user_data; 
     576  CMML_Preamble * preamble; 
     577  static char buf[1024]; 
     578  int n; 
     579 
     580  preamble = cmml_get_preamble (cmml); 
     581  n = cmml_preamble_snprint (buf, 1024, preamble); 
     582  if (n > 0) { 
     583    ap_rwrite (buf, n, r); 
     584  } 
     585 
     586  return 0; 
     587} 
     588 
     589static int 
     590read_cmml_head (CMML * cmml, const CMML_Head * head, void * user_data) 
     591{ 
     592  request_rec * r = (request_rec *)user_data; 
     593  static char buf[MAX_CLIP_LEN]; 
     594  int n; 
     595 
     596  n = cmml_head_pretty_snprint (buf, MAX_CLIP_LEN, (CMML_Head *)head); 
     597  if (n > 0) { 
     598    ap_rwrite (buf, n, r); 
     599  } 
     600 
     601  return 0; 
     602} 
     603 
     604static int 
     605read_cmml_clip (CMML * cmml, const CMML_Clip * clip, void * user_data) 
     606{  
     607  request_rec * r = (request_rec *)user_data; 
     608  static char buf[MAX_CLIP_LEN]; 
     609  int n; 
     610 
     611  n = cmml_clip_pretty_snprint (buf, MAX_CLIP_LEN, (CMML_Clip *)clip); 
     612  if (n > 0) { 
     613    ap_rwrite (buf, n, r); 
     614  } 
     615 
     616  return 0; 
     617} 
     618 
     619static int 
     620ma_send_cmml (request_rec * r, char * filename) 
     621{ 
     622  CMML * doc; 
     623  size_t nread = 0; 
     624  long n; 
     625  static char * cmml_tail = "</cmml>\n"; 
     626 
     627  doc = cmml_open (filename); 
     628  cmml_set_read_callbacks (doc, read_cmml_stream, read_cmml_head, 
     629                           read_cmml_clip, r); 
     630 
     631  while ((n = cmml_read (doc, 1024)) > 0) nread += n; 
     632 
     633  if (n < 0) { 
     634    /* ERROR */ 
     635  } 
     636 
     637  n = strlen (cmml_tail); 
     638  if (n > 0) { 
     639    ap_rwrite (cmml_tail, n, r); 
     640  } 
     641 
     642  cmml_destroy (doc); 
    565643 
    566644  return 0; 
     
    706784             output_type == MOD_ANNODEX_TYPE_CMML) { 
    707785    /* push out cmml */ 
    708     ma_send (r, srcpath); 
     786    ma_send_cmml (r, srcpath); 
    709787#ifdef __PROTOTYPE 
    710788  } else if (input_type == MOD_ANNODEX_TYPE_ANX &&