#include <stdio.h>#include "med.h"Go to the source code of this file.
Functions | |
| int | prefix (char *s1, char *s2) |
| void | upstring (char *s) |
| void | stripwhitespace (char *s) |
| int | balanced (char *s) |
| int | atom (char *s) |
| char * | advance_past_comma (char *s) |
| med * | new_med (void) |
| void | check_med1 (med *m) |
| void | check_med (med *m) |
| med * | parse_med1 (char *s) |
| med * | parse_med (char *s) |
| void | print_med (med *m) |
| void | print_sample (med *m) |
| int | figure_length1 (med *m) |
| int | figure_length (med *m) |
| void | write_pattern1 (int *pattern, int *offset, med *m) |
| void | write_pattern (int *pattern, int *offset, med *m) |
| med_pattern * | make_pattern (med *m) |
| void | print_pattern (med_pattern *pat) |
| void | add_to_mux_table (mux_table_entry *mt, int *size, char *medstr) |
Variables | |
| int | debug |
| int | depth |
| int | gotucf |
|
||||||||||||||||
|
Definition at line 572 of file med.c. References mux_table_entry::entry, make_pattern(), parse_med(), mux_table_entry::pattern, pattern, and print_pattern(). Referenced by mux_table_config(). 00573 {
00574 mt[*size].entry = parse_med(medstr);
00575 mt[*size].pattern = make_pattern(mt[*size].entry);
00576
00577 if (debug)
00578 print_pattern(mt[*size].pattern);
00579
00580 (*size)++;
00581 }
|
|
|
Definition at line 97 of file med.c. 00099 {}'s.
00100 */
00101 {
00102 int paren=0;
00103 while (*s) {
00104 if (*s=='{')
00105 paren++;
00106 else if (*s=='}')
00107 paren--;
00108 else if ((*s==',') && (paren==0)) {
00109 s++;
00110 break;
00111 }
00112 s++;
00113 }
00114 return (s);
00115 }
|
|
|
Definition at line 81 of file med.c. 00083 { followed by one }).
00084 */
00085 {
00086 int leftbraces=0;
00087 while ((*s) && (*s != '}')) {
00088 if (*s=='{')
00089 leftbraces++;
00090 s++;
00091 }
00092 return(leftbraces==1);
00093 }
|
|
|
Definition at line 61 of file med.c. 00063 {'s and }'s in *s forms a DYCK word.
00064 */
00065 {
00066 int leftbraces=0,rightbraces=0;
00067 int good=1;
00068 while (*s) {
00069 if (*s=='{')
00070 leftbraces++;
00071 else if (*s=='}')
00072 rightbraces++;
00073 if (rightbraces > leftbraces)
00074 good = 0;
00075 s++;
00076 }
00077 return((good) && (leftbraces==rightbraces));
00078 }
|
|
|
Definition at line 165 of file med.c. References check_med1(), depth, gotucf, med, _med::next, and _med::rc. 00170 {
00171 depth=0;
00172 gotucf=0;
00173
00174 check_med1(m);
00175
00176 while (m->next != NULL) {
00177 m = m->next;
00178 }
00179
00180 if ((m->next == NULL) && (m->rc != UCF)) {
00181 printf("check_med(): Last entry in MultiplexEntryDescriptor should contain a 'RC UCF'.\n");
00182 exit(1);
00183 }
00184 }
|
|
|
Definition at line 139 of file med.c. References check_med1(), depth, gotucf, _med::list, med, _med::next, _med::rc, and _med::type. 00140 {
00141 depth++;
00142 while (m != NULL) {
00143 if (m->type == MedList)
00144 check_med1(m->list);
00145 if (m->rc == UCF) {
00146 if (gotucf) {
00147 fflush(stdout);
00148 fprintf(stderr, "check_med1(): Multiple 'RC UCF's are not allowed.\n");
00149 exit(1);
00150 }
00151 else {
00152 gotucf=1;
00153 }
00154 if (depth > 1) {
00155 fflush(stdout);
00156 fprintf(stderr, "check_med1(): 'RC UCF's not allowed in a nested sub-expression.\n");
00157 exit(1);
00158 }
00159 }
00160 m = m->next;
00161 }
00162 depth--;
00163 }
|
|
|
Definition at line 397 of file med.c. References figure_length1(), _med::list, med, _med::rc, and _med::type. 00402 {
00403 int sum=0;
00404 if (m->type == MedAtom) {
00405 if (m->rc == UCF)
00406 sum = 1;
00407 else
00408 sum = m->rc;
00409 }
00410 else {
00411 if (m->rc == UCF) {
00412 sum += figure_length1(m->list);
00413 }
00414 else {
00415 sum += m->rc * figure_length1(m->list);
00416 }
00417 }
00418 return(sum);
00419 }
|
|
|
Definition at line 377 of file med.c. References figure_length1(), _med::list, med, _med::next, _med::rc, and _med::type. 00383 {
00384 int sum=0;
00385 while (m != NULL) {
00386 if (m->type == MedAtom) {
00387 sum += m->rc;
00388 }
00389 else {
00390 sum += m->rc * figure_length1(m->list);
00391 }
00392 m = m->next;
00393 }
00394 return (sum);
00395 }
|
|
|
Definition at line 483 of file med.c. References figure_length(), med, _med::next, med_pattern::non_repeating_part, med_pattern::non_repeating_part_length, _med::rc, med_pattern::repeating_part, med_pattern::repeating_part_length, warn(), and write_pattern(). 00498 {
00499 med_pattern *pat;
00500 med *save_m;
00501 int x, y;
00502
00503 pat = (med_pattern *) malloc(sizeof(med_pattern));
00504 if (debug)
00505 printf("make_pattern at %x...............................................\n",pat);
00506 if (pat == NULL) {
00507 /*
00508 * I hate running out of memory.
00509 */
00510 warn("make_pattern", "malloc failed");
00511 }
00512 else {
00513 /*
00514 * First figure out how much space to allocate for patterns.
00515 */
00516 pat->non_repeating_part_length = 0;
00517 pat->non_repeating_part = NULL;
00518 pat->repeating_part_length = 0;
00519 pat->repeating_part = NULL;
00520 save_m = m;
00521 while (m != NULL) {
00522 if (m->rc != UCF)
00523 pat->non_repeating_part_length += figure_length(m);
00524 else
00525 pat->repeating_part_length += figure_length(m);
00526
00527 m = m->next;
00528 }
00529 pat->non_repeating_part = (int *) malloc(pat->non_repeating_part_length * sizeof(int));
00530 pat->repeating_part = (int *) malloc(pat->repeating_part_length * sizeof(int));
00531
00532 if (((pat->non_repeating_part == NULL)&&(pat->non_repeating_part_length>0)) ||
00533 ((pat->repeating_part == NULL)&&(pat->repeating_part_length>0))) {
00534 warn("make_pattern", "malloc failed");
00535 }
00536 else {
00537 m = save_m;
00538 x = 0;
00539 y = 0;
00540 while (m != NULL) {
00541 if (m->rc != UCF) {
00542 write_pattern(pat->non_repeating_part, &x, m);
00543 }
00544 else {
00545 write_pattern(pat->repeating_part, &y, m);
00546 }
00547 m = m->next;
00548 }
00549 }
00550 }
00551 return (pat);
00552 }
|
|
|
Definition at line 118 of file med.c. References med. Referenced by parse_med1(). 00119 {
00120 med *bob = (med *) malloc(sizeof(med));
00121 if (bob==NULL) {
00122 fflush(stdout);
00123 fprintf(stderr, "new_med(): malloc() returned NULL.\n");
00124 exit(1);
00125 }
00126 return(bob);
00127 }
|
|
|
Definition at line 275 of file med.c. References advance_past_comma(), balanced(), check_med(), med, _med::next, parse_med1(), stripwhitespace(), and upstring(). 00278 :
00279 * {...},{...}
00280 */
00281 {
00282 med *bob, *alice;
00283
00284 upstring(s);
00285 stripwhitespace(s);
00286
00287 if (!balanced(s)) {
00288 printf("Error: Unbalanced {}'s.\n");
00289 }
00290
00291 if (*s != '{') {
00292 fflush(stdout);
00293 fprintf(stderr, "parse_med(): Parse error at %s.\n", s);
00294 exit(1);
00295 }
00296 bob = alice = parse_med1(s);
00297
00298 s = advance_past_comma(s);
00299
00300 while (*s) {
00301 alice->next = parse_med1(s);
00302 alice = alice->next;
00303 alice->next = NULL;
00304 s = advance_past_comma(s);
00305 }
00306
00307 check_med(bob);
00308 return(bob);
00309 }
|
|
|
Definition at line 192 of file med.c. References advance_past_comma(), _med::ch, _med::list, med, new_med(), _med::next, parse_med1(), prefix(), _med::rc, and _med::type. 00198 : See *parse_med(char *s). 00199 * 00200 */ 00201 { 00202 int i=0, paren=0; 00203 char *r, *t; 00204 med *head, *bob; 00205 00206 /* 00207 * Two possible cases here. Either we have something like "{LCN<i>,RC<j>}", 00208 * or we have something like "{{...}, ..., RC<j>}". 00209 */ 00210 00211 s++; 00212 if (*s == '{') { 00213 /* 00214 * Make a list, recursing when necessary. 00215 */ 00216 head = new_med(); 00217 head->type = MedList; 00218 head->next = NULL; 00219 00220 head->list = bob = parse_med1(s); 00221 00222 s = advance_past_comma(s); 00223 00224 while (*s == '{') { 00225 bob->next = parse_med1(s); 00226 bob = bob->next; 00227 bob->next = NULL; 00228 00229 s = advance_past_comma(s); 00230 } 00231 00232 if (prefix("RCUCF", s)) { 00233 head->rc = UCF; 00234 } 00235 else if (prefix("RC", s)) { head->rc = atoi(s+2); 00236 } 00237 else { 00238 fflush(stdout); 00239 fprintf(stderr, "parse_med1(): Parse error at %s.\n", s); 00240 exit(1); 00241 } 00242 } 00243 /* Base case (just a single channel) */ 00244 else { 00245 if (prefix("LCN", s)) { 00246 head = new_med(); 00247 s+=3; 00248 head->type = MedAtom; 00249 head->ch = atoi(s); 00250 head->next = NULL; 00251 00252 s = advance_past_comma(s); 00253 if (prefix("RCUCF", s)) { 00254 head->rc = UCF; 00255 } 00256 else if (prefix("RC", s)) { 00257 head->rc = atoi(s+2); 00258 } 00259 else { 00260 fflush(stdout); 00261 fprintf(stdout,"parse_med1(): Parse_error at %s.\n", s); 00262 exit(1); 00263 } 00264 } 00265 else { 00266 fflush(stdout); 00267 fprintf(stderr,"parse_med1(): Parse error at %s.\n", s); 00268 exit(1); 00269 } 00270 } 00271 return (head); 00272 }
|
|
||||||||||||
|
Definition at line 17 of file med.c. Referenced by parse_med1(), and set_config(). 00021 {
00022 while ((*s1) && (*s2) && (*s1==*s2)) {
00023 s1++;
00024 s2++;
00025 }
00026 return (!*s1);
00027 }
|
|
|
Definition at line 312 of file med.c. References _med::ch, _med::list, med, _med::next, print_med(), _med::rc, and _med::type. 00318 {
00319 while (m != NULL) {
00320 printf("{");
00321 if (m->type == MedAtom) {
00322 printf("LCN%d", m->ch);
00323 }
00324 else {
00325 print_med(m->list);
00326 }
00327 if (m->rc == -1)
00328 printf(",RC UCF}");
00329 else
00330 printf(",RC %d}", m->rc);
00331 if (m->next != NULL)
00332 printf(",");
00333 m = m->next;
00334 }
00335 }
|
|
|
Definition at line 555 of file med.c. References med_pattern::non_repeating_part, med_pattern::non_repeating_part_length, med_pattern::repeating_part, and med_pattern::repeating_part_length. 00556 {
00557 int i;
00558 printf("non-repeating part length: %d\n", pat->non_repeating_part_length);
00559 printf("non-repeating part: ");
00560 for (i=0; i<pat->non_repeating_part_length; i++)
00561 printf("%d", pat->non_repeating_part[i]);
00562 printf("\n");
00563 printf("repeating part length: %d\n", pat->repeating_part_length);
00564 printf("repeating part : ");
00565 for (i=0; i<pat->repeating_part_length; i++)
00566 printf("%d", pat->repeating_part[i]);
00567 printf("\n");
00568 }
|
|
|
Definition at line 338 of file med.c. References _med::ch, _med::list, med, _med::next, print_sample(), _med::rc, and _med::type. 00342 {{LCN1,RC5},{LCN2,RC2},RC UCF} will produce:
00343 *
00344 * 1111122 repeat until closing flag
00345 */
00346 {
00347 int i;
00348
00349 while (m) {
00350 if (m->type == MedAtom) {
00351 if (m->rc == UCF) {
00352 printf("{%d} repeat until closing flag", m->ch);
00353 }
00354 else {
00355 for (i=0;i<m->rc;i++) {
00356 printf("%d", m->ch);
00357 }
00358 }
00359 }
00360 else if (m->type == MedList) {
00361 if (m->rc == UCF) {
00362 printf("{");
00363 print_sample(m->list);
00364 printf("} repeat until closing flag");
00365 }
00366 else {
00367 for (i=0; i<m->rc; i++) {
00368 print_sample(m->list);
00369 }
00370 }
00371 }
00372 m = m->next;
00373 }
00374 }
|
|
|
Definition at line 43 of file med.c. 00047 {
00048 char *r = s;
00049
00050 while (*s) {
00051 if ((*s!=' ') && (*s!='\t') && (*s!='\n')) {
00052 *r=*s;
00053 r++;
00054 }
00055 s++;
00056 }
00057 *r='\0';
00058 }
|
|
|
Definition at line 30 of file med.c. 00034 {
00035 while (*s) {
00036 if ((*s >= 'a') && (*s <= 'z'))
00037 *s = *s - 'a' + 'A';
00038 s++;
00039 }
00040 }
|
|
||||||||||||||||
|
Definition at line 453 of file med.c. References _med::ch, _med::list, med, pattern, _med::rc, _med::type, and write_pattern1(). 00458 {
00459 int i;
00460
00461 if (m->type == MedAtom) {
00462 if (m->rc == UCF) {
00463 pattern[(*offset)++]=m->ch;
00464 }
00465 else {
00466 for (i=0; i<m->rc; i++)
00467 pattern[(*offset)++]=m->ch;
00468 }
00469 }
00470 else if (m->type == MedList) {
00471 if (m->rc == UCF) {
00472 write_pattern1(pattern, offset, m->list);
00473 }
00474 else {
00475 for (i=0; i<m->rc; i++)
00476 write_pattern1(pattern, offset, m->list);
00477 }
00478 }
00479 }
|
|
||||||||||||||||
|
Definition at line 422 of file med.c. References _med::ch, _med::list, med, _med::next, pattern, _med::rc, _med::type, and write_pattern1(). 00427 {
00428 int i;
00429 while (m != NULL) {
00430 if (m->type == MedAtom) {
00431 if (m->rc == UCF) {
00432 pattern[(*offset)++]=m->ch;
00433 }
00434 else {
00435 for (i=0; i<m->rc; i++)
00436 pattern[(*offset)++]=m->ch;
00437 }
00438 }
00439 else if (m->type == MedList) {
00440 if (m->rc == UCF) {
00441 write_pattern1(pattern, offset, m->list);
00442 }
00443 else {
00444 for (i=0; i<m->rc; i++)
00445 write_pattern1(pattern, offset, m->list);
00446 }
00447 }
00448 m = m->next;
00449 }
00450 }
|
|
|
|
|
|
Definition at line 136 of file med.c. Referenced by check_med(), and check_med1(). |
|
|
Definition at line 137 of file med.c. Referenced by check_med(), and check_med1(). |
1.3.9.1