Main Page | Class List | File List | Class Members | File Members

med.h

Go to the documentation of this file.
00001 /* MED.H */ 
00002 
00003 #ifndef _MED_H_
00004 #define _MED_H_
00005 
00006 /*
00007  * A med is a list of med elements.
00008  * 
00009  * A med element.  Can be either an MedAtom or a MedList. 
00010  *
00011  * If the element is an MedAtom, it will be a channel number repeated x times.
00012  *
00013  * If the element is a MedList, it will be a list that is repeated x times.
00014  */
00015 
00016 #define UCF  -1
00017 #define MAX_MUX_TABLE_SIZE 16
00018 
00019 typedef struct _med { 
00020 
00021   enum { MedAtom, MedList } type;
00022 
00023   int ch;                       /* A channel number.  Used iff type = MedAtom */
00024   struct _med *list;            /* A list of MEDs.  Used iff type = MedList */
00025 
00026   int rc;                       /* Number of times to repeat.  -1 means UCF */
00027   struct _med *next;
00028 
00029 } med;
00030 
00031 
00032 typedef struct {
00033   /*
00034    * The pattern of bytes which a MultiplexEntryDescriptor defines.  
00035    * With every MED, there is a non-repeating part and a repeating part.  
00036    * The non-repeating part comes first.  It is followed by the repeating 
00037    * part.
00038    */
00039   int *non_repeating_part;
00040   int non_repeating_part_length;
00041   int *repeating_part;
00042   int repeating_part_length;
00043 
00044 } med_pattern;
00045 
00046 
00047 typedef struct {
00048   /* 
00049    * Information stored in the MUX table.
00050    */
00051   med *entry;
00052   med_pattern *pattern;
00053   
00054 } mux_table_entry;
00055 
00056 /* Function Prototypes */
00057 
00058 int prefix (char *s1, char *s2);
00059 /*
00060  * Returns 1 iff s1 is a prefix of s2.
00061  */
00062 
00063 static void upstring(char *s);
00064 /*
00065  * Converts a string to upper case.  Assumes ASCII.
00066  */
00067 
00068 static void stripwhitespace(char *s);
00069 /*
00070  * This function does exactly what it says it does.
00071  */
00072 
00073 static int balanced(char *s);
00074 /*
00075  * Returns 1 iff the sequence of {'s and }'s in *s forms a DYCK word.
00076  */
00077 
00078 static int atom(char *s);
00079 /*
00080  * Returns 1 iff prefix(s) is an atom (i.e. one { followed by one }).
00081  */
00082 
00083 static char *advance_past_comma(char *s);
00084 /*
00085  * Advances to just past the next comma, ignoring stuff in nested {}'s.
00086  */
00087 
00088 static med *new_med(void);
00089 /*
00090  * mallocs a new med structure
00091  */
00092 
00093 static void check_med1(med *m);
00094 /*
00095  * helper for the next function
00096  */
00097 
00098 static void check_med(med *m);
00099 /*
00100  * Checks multiplex entry for multiple RC UCF's or an RC UCF 
00101  *   in a nested sub-expression.
00102  * Most of the code is in check_med1();
00103  */
00104 
00105 static med *parse_med1(char *s);
00106 /*
00107  * helper function for function below
00108  */
00109 
00110 static med *parse_med(char *s);
00111 /*
00112  * Returns a med structure from a string (i.e., a pointer to the start
00113  *   of a MED list).  String is expected to have been removed of whitespace
00114  *   and converted to uppercase.
00115  *
00116  * This is the toplevel function.
00117  *   The top layer is different, since we can have stuff like:
00118  *   {...},{...}
00119  */
00120 
00121 static void print_med(med *m);
00122 /*
00123  * Prints out the med pointed to by m.
00124  *
00125  * Is recursive (i.e. See print_med(med *m)).
00126  */
00127 
00128 static void print_sample(med *m);
00129 /*
00130  * Prints out a sample of what output the code will produce.
00131  *
00132  * Ex.  {{LCN1,RC5},{LCN2,RC2},RC UCF} will produce:
00133  *
00134  * 1111122 repeat until closing flag
00135  */
00136 
00137 static int figure_length1(med *m);
00138 /*
00139  * Helper function for function below
00140  */
00141 static int figure_length(med *m);
00142 /*
00143  * Figure out the length of a pattern a med produces.
00144  * Do not follow (*next) pointers of (*m).
00145  */
00146 
00147 static void write_pattern1(int *pattern, int *offset, med *m);
00148 /*
00149  * Helper function for function below
00150  */
00151 
00152 static void write_pattern(int *pattern, int *offset, med *m);
00153 /*
00154  * Fills in the pattern array
00155  */
00156  
00157 static med_pattern *make_pattern(med *m);
00158 /*
00159  * Makes a pattern for putting data in a MUX-PDU payload packet
00160  *   or removing data from a MUX-PDU payload.
00161  *
00162  * Assumes (*m) is a vaild med structure;
00163  *
00164  * See above for struct med_pattern.
00165  *
00166  * Since logical channel numbers can only be between 0 and 65535,
00167  *   (according to H.223/AnnexA), an unnsigned short int array would
00168  *   suffice.  If logical channel numbers were between 0 and 255, an
00169  *   unsigned char would be fine.  I don't really care about storage,
00170  *   so I'm making them natural ints.
00171  */
00172 
00173 static void print_pattern(med_pattern *pat);
00174 /*
00175  * Prints out the med's pattern
00176  */
00177 
00178 void add_to_mux_table(mux_table_entry *mt, int *size, char *medstr);
00179 /*
00180  * Adds an multiplex entry to the mux table using the med
00181  */
00182 
00183 #endif

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1