120 unsigned short suppress_messages;
125 unsigned short suppress_messages)
187 expand, suppress_messages)
192 unsigned short suppress_messages;
197 MASK expand,
unsigned short suppress_messages)
202 FILE *tmp_fptr = {
NULL};
203 char *tmp_fname = {
NULL};
209 if (tmp_fname ==
NULL)
212 if ((tmp_fptr = (FILE *) fopen(tmp_fname,
"w")) !=
NULL)
214 (void)fprintf(tmp_fptr,
"%s", odl_string);
215 (void)fclose(tmp_fptr);
217 expand, suppress_messages);
276 unsigned short suppress_messages;
281 unsigned short suppress_messages)
285 KEYWORD *kwd = {
NULL};
286 KEYWORD *new_kwd = {
NULL};
287 KEYWORD *save_kwd = {
NULL};
288 OBJDESC *temp_root = {
NULL};
289 OBJDESC *new_obj = {
NULL};
290 OBJDESC *save_obj = {
NULL};
291 FILE *l_ptr = {
NULL};
292 unsigned long start_loc = {1};
294 unsigned short done = {
FALSE};
295 char *fspec = {
NULL};
296 char *fname = {
NULL};
297 char *keyword_name = {
NULL};
326 kwd = (KEYWORD *)
OdlFindKwd(
object, keyword_name,
340 (void)sprintf(error_message,
341 "Recursive %s statement found in file: %s",
342 keyword_name, fname);
353 (void)sprintf(error_message,
354 "Unable to locate %s file: %s",
355 keyword_name, fname);
365 message_fname,
NULL,0,1,1,1);
368 if (temp_root !=
NULL)
371 for (new_kwd=temp_root->first_keyword;
372 new_kwd !=
NULL; new_kwd = save_kwd)
374 save_kwd = new_kwd->right_sibling;
380 for (new_obj=temp_root->first_child;
381 new_obj !=
NULL; new_obj = save_obj)
383 save_obj = new_obj->right_sibling;
389 temp_root->first_keyword =
NULL;
390 temp_root->first_child =
NULL;
418 expand, suppress_messages);
445 OBJDESC *obj = {
NULL};
446 char *temp_fname = {
NULL};
447 unsigned short found = {
FALSE};
449 if ((keyword !=
NULL) && (exp_fname !=
NULL))
451 #if (defined( VAX) || defined( ALPHA_VMS))
457 #if (defined( VAX) || defined( ALPHA_VMS))
461 found = (strcmp(temp_fname, exp_fname) == 0);
464 for (obj=keyword->parent;
465 ((! found) && (obj !=
NULL)); obj=obj->parent)
469 #if (defined( VAX) || defined( ALPHA_VMS))
473 found = (strcmp(temp_fname, exp_fname) == 0);
525 keyword_value, object_position, search_scope)
527 OBJDESC *start_object;
528 const char *object_class;
529 const char *keyword_name;
531 unsigned long object_position;
532 unsigned short search_scope;
537 const char *keyword_name,
char *keyword_value,
538 unsigned long object_position,
539 unsigned short search_scope)
543 OBJDESC *found_object = {
NULL};
544 OBJDESC *obj = {
NULL};
545 KEYWORD *kwd = {
NULL};
546 unsigned short found = {
FALSE};
547 unsigned short scope = {search_scope};
548 unsigned long current_position = {0};
550 for (obj=start_object;
551 ((obj !=
NULL) && (! found));
552 obj = (OBJDESC *)
OdlNextObjDesc(obj, start_object->level, &scope))
554 if (object_class ==
NULL)
559 if ((found) && (keyword_name !=
NULL))
561 kwd = (KEYWORD *)
OdlFindKwd(obj, keyword_name,
563 found = (kwd !=
NULL);
566 if ((found) && (keyword_value !=
NULL))
569 if ((found) && (object_position != 0))
570 found = ((++current_position) == object_position);
572 if (found) found_object = obj;
576 return(found_object);
614 unsigned long root_level;
615 unsigned short *search_scope;
620 unsigned short *search_scope)
624 OBJDESC *next_object = {
NULL};
628 switch (*search_scope)
650 default : next_object = (OBJDESC *)
708 if (object->right_sibling ==
NULL)
709 object->parent->last_child =
object->left_sibling;
711 object->right_sibling->left_sibling =
object->left_sibling;
713 if (object->left_sibling ==
NULL)
714 object->parent->first_child =
object->right_sibling;
716 object->left_sibling->right_sibling =
object->right_sibling;
718 object->parent =
NULL;
719 object->left_sibling =
NULL;
720 object->right_sibling =
NULL;
762 OBJDESC *parent_object;
770 if ((new_object !=
NULL) && (parent_object !=
NULL))
772 new_object->left_sibling = parent_object->last_child;
773 new_object->right_sibling =
NULL;
774 new_object->parent = parent_object;
776 if (parent_object->first_child ==
NULL)
777 parent_object->first_child = new_object;
779 if (parent_object->last_child !=
NULL)
780 parent_object->last_child->right_sibling = new_object;
782 parent_object->last_child = new_object;
834 if ((new_object !=
NULL) && (old_object !=
NULL))
836 new_object->left_sibling = old_object->left_sibling;
837 new_object->right_sibling = old_object;
838 new_object->parent = old_object->parent;
840 if (old_object->left_sibling ==
NULL)
841 old_object->parent->first_child = new_object;
843 old_object->left_sibling->right_sibling = new_object;
845 old_object->left_sibling = new_object;
897 if ((new_object !=
NULL) && (old_object !=
NULL))
899 new_object->right_sibling = old_object->right_sibling;
900 new_object->left_sibling = old_object;
901 new_object->parent = old_object->parent;
903 if (old_object->right_sibling ==
NULL)
904 old_object->parent->last_child = new_object;
906 old_object->right_sibling->left_sibling = new_object;
908 old_object->right_sibling = new_object;
960 OBJDESC *new_object = {
NULL};
965 object->pre_comment, object->line_comment,
966 object->post_comment, object->end_comment,
967 object->file_name, object->is_a_group,
968 (
long)object->line_number);
1006 OBJDESC *
OdlNewObjDesc (object_class, pre_comment, line_comment, post_comment,
1007 end_comment, file_name, is_a_group, line_number)
1008 const char *object_class;
1009 const char *pre_comment;
1010 const char *line_comment;
1011 const char *post_comment;
1012 const char *end_comment;
1013 const char *file_name;
1020 const char *line_comment,
const char *post_comment,
1021 const char *end_comment,
const char *file_name,
1022 short is_a_group,
long line_number)
1026 OBJDESC *new_object = {
NULL};
1028 if ((new_object = (OBJDESC *)malloc(
sizeof(OBJDESC))) ==
NULL)
1033 CopyString(new_object->pre_comment, pre_comment)
1034 CopyString(new_object->line_comment, line_comment)
1035 CopyString(new_object->post_comment, post_comment)
1036 CopyString(new_object->end_comment, end_comment)
1039 new_object->is_a_group = is_a_group;
1040 new_object->child_count = 0;
1041 new_object->line_number = line_number;
1042 new_object->level = 0;
1043 new_object->parent =
NULL;
1044 new_object->left_sibling =
NULL;
1045 new_object->right_sibling =
NULL;
1046 new_object->first_child =
NULL;
1047 new_object->last_child =
NULL;
1048 new_object->first_keyword =
NULL;
1049 new_object->last_keyword =
NULL;
1050 new_object->appl1 =
NULL;
1051 new_object->appl2 =
NULL;
1106 KEYWORD *kwd = {
NULL};
1111 kwd = (KEYWORD *)
OdlFindKwd(
object,
"PDS_VERSION_ID",
1115 kwd = (KEYWORD *)
OdlFindKwd(
object,
"ODL_VERSION_NUMBER",
1171 char *class_name = {
NULL};
1174 class_name =
object->class;
1221 OBJDESC *obj = {
NULL};
1222 int child_count = {0};
1226 for (obj=object->first_child; obj !=
NULL; obj=obj->right_sibling)
1230 return(child_count);
1275 OBJDESC *obj = {
NULL};
1280 for (obj=object->parent; obj !=
NULL; obj=obj->parent)
1333 OBJDESC *obj = {
NULL};
1336 for (obj=
object; obj !=
NULL;
1339 obj->level = (obj->parent ==
NULL) ? 0 : (1 + obj->parent->level);
1390 OBJDESC *parent = {
NULL};
1393 parent =
object->parent;
1442 KEYWORD *
OdlFindKwd (start_object, keyword_name, keyword_value,
1443 keyword_position, search_scope)
1444 OBJDESC *start_object;
1445 const char *keyword_name;
1446 char *keyword_value;
1447 unsigned long keyword_position;
1448 unsigned short search_scope;
1452 KEYWORD *
OdlFindKwd (OBJDESC *start_object,
const char *keyword_name,
1453 char *keyword_value,
unsigned long keyword_position,
1454 unsigned short search_scope)
1458 OBJDESC *obj = {
NULL};
1459 KEYWORD *kwd = {
NULL};
1460 KEYWORD *found_kwd = {
NULL};
1461 unsigned short found = {
FALSE};
1462 unsigned short scope = {search_scope};
1463 unsigned long current_position = {0};
1465 for (obj=start_object;
1466 ((obj !=
NULL) && (! found));
1467 obj = (OBJDESC *)
OdlNextObjDesc(obj, start_object->level, &scope))
1469 for (kwd=obj->first_keyword; ((kwd !=
NULL) && (! found)); kwd=kwd->right_sibling)
1471 if (keyword_name ==
NULL)
1476 if ((found) && (keyword_value !=
NULL))
1479 if ((found) && (keyword_position != 0))
1480 found = ((++current_position) == keyword_position);
1482 if (found) found_kwd = kwd;
1527 KEYWORD *
OdlNextKwd (start_keyword, keyword_name, keyword_value,
1528 keyword_position, search_scope)
1530 KEYWORD *start_keyword;
1532 char *keyword_value;
1533 unsigned long keyword_position;
1534 unsigned short search_scope;
1539 char *keyword_value,
unsigned long keyword_position,
1540 unsigned short search_scope)
1544 OBJDESC *start_object = {
NULL};
1545 OBJDESC *obj = {
NULL};
1546 KEYWORD *kwd = {
NULL};
1547 KEYWORD *found_kwd = {
NULL};
1548 unsigned short found = {
FALSE};
1549 unsigned short scope = {search_scope};
1550 unsigned long current_position = {0};
1552 if (start_keyword !=
NULL)
1554 start_object = start_keyword->parent;
1556 kwd = start_keyword;
1560 for ( ; ((kwd !=
NULL) && (! found)); kwd=kwd->right_sibling)
1562 if (keyword_name ==
NULL)
1567 if ((found) && (keyword_value !=
NULL))
1570 if ((found) && (keyword_position != 0))
1571 found = ((++current_position) == keyword_position);
1573 if (found) found_kwd = kwd;
1579 obj = (OBJDESC *)
OdlNextObjDesc(obj, start_object->level, &scope);
1583 }
while ((obj !=
NULL) && (! found));
1638 if (keyword !=
NULL)
1640 if (keyword->left_sibling !=
NULL)
1641 keyword->left_sibling->right_sibling = keyword->right_sibling;
1643 if (keyword->right_sibling !=
NULL)
1644 keyword->right_sibling->left_sibling = keyword->left_sibling;
1646 if (keyword->parent->first_keyword == keyword)
1647 keyword->parent->first_keyword = keyword->right_sibling;
1649 if (keyword->parent->last_keyword == keyword)
1650 keyword->parent->last_keyword = keyword->left_sibling;
1652 keyword->parent =
NULL;
1653 keyword->left_sibling =
NULL;
1654 keyword->right_sibling =
NULL;
1703 if ((keyword !=
NULL) && (
object !=
NULL))
1705 keyword->parent = object;
1706 keyword->left_sibling =
object->last_keyword;
1707 keyword->right_sibling =
NULL;
1709 if (object->first_keyword ==
NULL)
1710 object->first_keyword = keyword;
1712 if (object->last_keyword !=
NULL)
1713 object->last_keyword->right_sibling = keyword;
1715 object->last_keyword = keyword;
1755 KEYWORD *new_keyword;
1756 KEYWORD *old_keyword;
1764 if ((new_keyword !=
NULL) && (old_keyword !=
NULL))
1766 new_keyword->parent = old_keyword->parent;
1767 new_keyword->left_sibling = old_keyword->left_sibling;
1768 new_keyword->right_sibling = old_keyword;
1770 if (old_keyword->left_sibling ==
NULL)
1771 old_keyword->parent->first_keyword = new_keyword;
1773 old_keyword->left_sibling->right_sibling = new_keyword;
1775 old_keyword->left_sibling = new_keyword;
1779 return(new_keyword);
1815 KEYWORD *new_keyword;
1816 KEYWORD *old_keyword;
1824 if ((new_keyword !=
NULL) && (old_keyword !=
NULL))
1826 new_keyword->parent = old_keyword->parent;
1827 new_keyword->right_sibling = old_keyword->right_sibling;
1828 new_keyword->left_sibling = old_keyword;
1830 if (old_keyword->right_sibling ==
NULL)
1831 old_keyword->parent->last_keyword = new_keyword;
1833 old_keyword->right_sibling->left_sibling = new_keyword;
1835 old_keyword->right_sibling = new_keyword;
1839 return(new_keyword);
1884 KEYWORD *new_keyword = {
NULL};
1886 if (keyword !=
NULL)
1888 new_keyword =
OdlNewKwd(keyword->name, keyword->value,
1889 keyword->pre_comment, keyword->line_comment,
1890 keyword->file_name, (
long)keyword->line_number);
1893 return(new_keyword);
1928 KEYWORD *
OdlNewKwd (keyword_name, value_text, pre_comment,
1929 line_comment, file_name, line_number)
1940 KEYWORD *
OdlNewKwd (
char *keyword_name,
char *value_text,
char *pre_comment,
1941 char *line_comment,
char *file_name,
long line_number)
1945 KEYWORD *new_keyword = {
NULL};
1947 if ((new_keyword = (KEYWORD *)malloc(
sizeof(KEYWORD))) ==
NULL)
1952 CopyString(new_keyword->pre_comment, pre_comment)
1953 CopyString(new_keyword->line_comment, line_comment)
1954 CopyString(new_keyword->file_name, file_name)
1957 new_keyword->is_a_pointer = (keyword_name ==
NULL) ?
FALSE : (*keyword_name ==
'^');
1959 if (value_text ==
NULL)
1961 new_keyword->size = 0;
1962 new_keyword->is_a_list =
FALSE;
1966 new_keyword->size = strlen(new_keyword->value);
1967 new_keyword->is_a_list = ((*value_text ==
'{') || (*value_text ==
'('));
1970 new_keyword->line_number = line_number;
1971 new_keyword->parent =
NULL;
1972 new_keyword->left_sibling =
NULL;
1973 new_keyword->right_sibling =
NULL;
1974 new_keyword->appl1 =
NULL;
1975 new_keyword->appl2 =
NULL;
1979 return(new_keyword);
2028 KEYWORD *kwd = {
NULL};
2031 kwd =
object->first_keyword;
2082 KEYWORD *kwd = {
NULL};
2084 if (keyword !=
NULL)
2085 kwd = keyword->right_sibling;
2137 if (keyword !=
NULL)
2138 value = keyword->value;
2204 TB_STRING_LIST *value_list = {
NULL};
2205 char *val_start = {
NULL};
2206 char *val_stop = {
NULL};
2209 if (keyword !=
NULL)
2211 if (keyword->value !=
NULL)
2218 save_ch = *(val_stop + 1); *(val_stop + 1) =
'\0';
2220 *(val_stop + 1) = save_ch;
2336 char *unit = {
NULL};
2339 if (keyword !=
NULL)
2342 c = (
char *) strchr(keyword->value,
'<');
2351 c = (
char *) strchr(unit,
'>');
2352 if (
c !=
NULL) *(
c + 1) =
'\0';
2407 if (keyword !=
NULL)
2408 name = keyword->name;
2524 KEYWORD *kwd = {
NULL};
2528 for (kwd=object->first_keyword; kwd !=
NULL;
2531 object->first_keyword =
NULL;
2532 object->last_keyword =
NULL;
2582 KEYWORD *next_kwd = {
NULL};
2584 if (keyword !=
NULL)
2586 next_kwd = keyword->right_sibling;
2591 LemmeGo(keyword->line_comment)
2643 const char *message_fname;
2654 if (message_fptr !=
NULL)
2655 fptr = message_fptr;
2659 if ((fptr = (FILE *) fopen(message_fname,
"a")) ==
NULL)
2663 "Unable to open the output file. Messages will be written to the terminal");
2776 char *
OdlGetFileName (keyword, start_location, start_location_type)
2779 unsigned long *start_location;
2780 unsigned short *start_location_type;
2785 unsigned short *start_location_type)
2789 char *fname = {
NULL};
2790 char *text = {
NULL};
2791 char *unit = {
NULL};
2792 char *first_word = {
NULL};
2793 char *second_word = {
NULL};
2795 if (keyword !=
NULL)
2808 unit = (
char *) strchr(text,
'<');
2811 if (unit !=
NULL) *unit =
'\0';
2817 if ((*first_word ==
'"') || (*first_word ==
'\''))
2823 if (*second_word ==
'\0')
2824 *start_location = 1;
2828 *start_location = atoi(second_word);
2829 *(second_word - 1) =
'\0';
2843 *start_location = atoi(first_word);
2856 if (strncmp(unit,
"<BYTE", 5) == 0)
2917 char *fspec = {
NULL};
2964 FILE *
OdlLocateStart (filespec, start_location, start_location_type)
2967 unsigned long start_location;
2968 unsigned short start_location_type;
2973 unsigned short start_location_type)
2977 FILE *fptr = {
NULL};
2978 unsigned short reached_the_end = {
FALSE};
2985 if (filespec !=
NULL)
2989 fptr = (FILE *) fopen(filespec,
"rb");
2990 if ((fptr !=
NULL) && (start_location > 1))
2991 reached_the_end = (fseek(fptr,start_location,0) != 0);
2995 fptr = (FILE *) fopen(filespec,
"r");
2998 for (
i=1; ((
i < start_location) && (! reached_the_end)); ++
i)
3001 reached_the_end =
TRUE;
3007 if (reached_the_end)
CloseMe(fptr)
3065 short OdlPrintMessage (message_fname, message_fptr, line_number, text)
3067 const char *message_fname;
3075 long line_number,
const char *text)
3079 FILE *m_ptr = {
NULL};
3080 char line_prompt[20];
3081 char *line_out = {
NULL};
3087 m_ptr = (message_fptr !=
NULL) ? message_fptr :
3090 if (line_number == 0)
3091 (void)
strcpy(line_prompt,
"");
3093 (
void)sprintf(line_prompt,
" Line %ld -- ", line_number);
3097 NewString(line_out, (20 + (
long)strlen(line_prompt)))
3098 (void)sprintf(line_out,
"%s Unknown error", line_prompt);
3102 NewString(line_out, (20 + (
long)strlen(line_prompt) + (
long)strlen(text)))
3103 (void)sprintf(line_out,
"%s%s", line_prompt, text);
3108 (void)fprintf(m_ptr,
"%s", line_out);
3112 if ((m_ptr !=
stdout) && (message_fptr ==
NULL))
3157 const char *message_fname;
3168 FILE *m_ptr = {
NULL};
3172 m_ptr = (message_fptr !=
NULL) ? message_fptr :
3177 (void)fprintf(m_ptr,
"%s",
"Unknown error\n");
3181 (void)fprintf(m_ptr,
"%s", text);
3185 if ((m_ptr !=
stdout) && (message_fptr ==
NULL))
3211 char *new_text = {
NULL};
3212 char *first_char = {
NULL};
3213 char *last_char = {
NULL};
3214 char *dashes = {
NULL};
3215 char *blanks = {
NULL};
3217 char save_it = {
'\0'};
3218 long report_indent = {0};
3219 long report_width = {75};
3220 long line_size = {0};
3236 if ((dashes = strstr(text,
" -- ")) !=
NULL)
3237 report_indent = 4 + ((long) (dashes - text));
3239 if (report_indent >= (report_width - 2))
3244 for (
i=0;
i < report_indent; ++
i)
3249 line_size = report_width - report_indent;
3254 for (first_char=text; *first_char !=
'\0'; first_char = last_char)
3257 len = strlen(first_char);
3268 if (first_char == text)
3270 if (len > report_width)
3271 last_char = (
char *) (first_char + report_width);
3273 last_char = (
char *) (first_char + len);
3279 if (len > line_size)
3280 last_char = (
char *) (first_char + line_size);
3282 last_char = (
char *) (first_char + len);
3291 if (*last_char !=
'\0')
3293 for (
c = last_char; ((
c >= first_char) && (*
c !=
' ')); --
c) ;
3301 save_it = *last_char;
3305 *last_char = save_it;
3308 if (*last_char ==
' ')
3358 char *message_fname;
3368 OBJDESC *obj = {
NULL};
3369 KEYWORD *kwd = {
NULL};
3370 FILE *m_ptr = {
NULL};
3371 char *format = {
NULL};
3372 const char *no_name = {
"<no name>"};
3375 m_ptr = (message_fptr !=
NULL) ? message_fptr :
3384 if ((kwd ==
NULL) || (kwd->value ==
NULL))
3386 (void)sprintf(format,
" Line %-5lu %%%lud %%%lus",
3387 obj->line_number, (obj->level + 1),
3388 (2*(obj->level) + strlen(no_name)));
3390 (void)sprintf(msgtext, format, obj->level, no_name);
3395 (void)sprintf(format,
" Line %-5lu %%%lud %%%lus",
3396 obj->line_number, (obj->level + 1),
3397 (2*(obj->level) + strlen(kwd->value)));
3398 (void)sprintf(msgtext, format, obj->level, kwd->value);
3402 if (obj->class ==
NULL)
3403 (void)
OdlPrintLine(message_fname, m_ptr,
" -- <no class>\n");
3405 (void)sprintf(msgtext,
" -- %s\n", obj->class);
3414 if ((m_ptr !=
stdout) && (message_fptr ==
NULL))
3454 void OdlPrintLabel (
object, message_fname, message_fptr, root_level)
3457 char *message_fname;
3459 unsigned long root_level;
3464 unsigned long root_level)
3468 FILE *m_ptr = {
NULL};
3469 char *blanks = {
NULL};
3475 m_ptr = (message_fptr !=
NULL) ? message_fptr :
3480 for (
i=1;
i <
object->level; ++
i) (
void)strcat(blanks,
" ");
3482 if (object->pre_comment !=
NULL)
3483 (void)
OdlPrintLine(message_fname, m_ptr, object->pre_comment);
3485 if (object->parent !=
NULL)
3489 if (object->class ==
NULL) {
3490 (void)sprintf(msgtext,
"%sOBJECT", blanks);
3494 (void)sprintf(msgtext,
"%sOBJECT = %s", blanks, object->class);
3500 if (object->class ==
NULL) {
3501 (void)sprintf(msgtext,
"%sGROUP", blanks);
3505 (void)sprintf(msgtext,
"%sGROUP = %s", blanks, object->class);
3510 if (object->line_comment !=
NULL) {
3512 (void)
OdlPrintLine(message_fname, m_ptr, object->line_comment);
3522 if (object->post_comment !=
NULL)
3523 (void)
OdlPrintLine(message_fname, m_ptr, object->post_comment);
3525 if (object->parent !=
NULL)
3529 if (object->class ==
NULL) {
3530 (void)sprintf(msgtext,
"%sEND_OBJECT", blanks);
3534 (void)sprintf(msgtext,
"%sEND_OBJECT = %s", blanks, object->class);
3540 if (object->class ==
NULL) {
3541 (void)sprintf(msgtext,
"%sEND_GROUP", blanks);
3545 (void)sprintf(msgtext,
"%sEND_GROUP = %s", blanks, object->class);
3550 if (object->end_comment !=
NULL) {
3552 (void)
OdlPrintLine(message_fname, m_ptr, object->end_comment);
3559 if (object->level > root_level)
3560 OdlPrintLabel(object->right_sibling, (
char *)0, m_ptr, root_level);
3564 if (object->parent ==
NULL)
3570 if ((m_ptr !=
stdout) && (message_fptr ==
NULL))
3590 char *message_fname;
3600 KEYWORD *keyword = {
NULL};
3601 FILE *m_ptr = {
NULL};
3602 short sfdu_only = {
FALSE};
3603 char *blanks = {
NULL};
3606 m_ptr = (message_fptr !=
NULL) ? message_fptr :
3612 if (object->level > 0)
3613 for (
i=0;
i <
object->level; ++
i) (
void)strcat(blanks,
" ");
3615 for (keyword=object->first_keyword; keyword !=
NULL;
3616 keyword = keyword->right_sibling)
3618 if (keyword->pre_comment !=
NULL)
3619 (void)
OdlPrintLine(message_fname, m_ptr, keyword->pre_comment);
3624 if (keyword->name ==
NULL)
3625 (void)
OdlPrintLine(message_fname, m_ptr,
"unknown_keyword");
3628 (void)
OdlPrintLine(message_fname, m_ptr, keyword->name);
3629 sfdu_only = ((strncmp(keyword->name,
"NJPL", 4) == 0) ||
3630 (strncmp(keyword->name,
"CCSD", 4) == 0));
3633 if ((keyword->value !=
NULL) && (! sfdu_only)) {
3635 (void)
OdlPrintLine(message_fname, m_ptr, keyword->value);
3638 if (keyword->line_comment !=
NULL) {
3640 (void)
OdlPrintLine(message_fname, m_ptr, keyword->line_comment);
3652 if ((m_ptr !=
stdout) && (message_fptr ==
NULL))
3698 OBJDESC *
OdlParseFile(label_fname, label_fptr, message_fname, message_fptr,
3699 suppress_messages, suppress_metrics, suppress_hierarchy,
3704 char *message_fname;
3706 unsigned short suppress_messages;
3707 unsigned short suppress_metrics;
3708 unsigned short suppress_hierarchy;
3709 unsigned short ignore_missing_end;
3714 char *message_fname, FILE *message_fptr,
3715 unsigned short suppress_messages,
3716 unsigned short suppress_metrics,
3717 unsigned short suppress_hierarchy,
3718 unsigned short ignore_missing_end)
3724 OBJDESC *curr_object = {
NULL};
3725 KEYWORD *curr_keyword = {
NULL};
3726 FILE *m_ptr = {
NULL};
3727 FILE *l_ptr = {
NULL};
3728 char *left_part = {
NULL};
3729 char *equals = {
NULL};
3730 char *right_part = {
NULL};
3731 char *comment = {
NULL};
3734 char *tintext = {
NULL};
3735 char *text = {
NULL};
3739 long line_number = {0};
3740 long value_list_line_number = {0};
3741 long object_count = {0};
3742 long end_object_count = {0};
3743 long keyword_count = {0};
3744 long comment_count = {0};
3745 long brace_nesting = {0};
3746 long paren_nesting = {0};
3747 short end_found = {
FALSE};
3748 short value_list = {
FALSE};
3749 short equals_found = {
FALSE};
3750 short val_found = {
FALSE};
3751 short balanced = {
FALSE};
3752 short oddquotes = {
FALSE};
3753 unsigned short is_a_group;
3759 m_ptr = (message_fptr !=
NULL) ? message_fptr :
3762 if (label_fname ==
NULL)
3763 (void)sprintf(msgtext,
"Parsing File: (no file name provided)");
3765 (
void)sprintf(msgtext,
"Parsing File: %s", label_fname);
3767 (void)
OdlPrintLine(message_fname, m_ptr,
"\n--------------------------------------------------------------------------\n");
3769 (void)
OdlPrintLine(message_fname, m_ptr,
"\n--------------------------------------------------------------------------\n\n");
3772 l_ptr = (label_fptr !=
NULL) ? label_fptr :
3774 (FILE *) fopen(label_fname,
"r");
3778 "Unable to open the label file. Parsing cannot continue");
3785 curr_object =
root =
OdlNewObjDesc(
"ROOT",(
char *)0,(
char *)0,(
char *)0,(
char *)0,label_fname,0,(
long)0);
3788 while (! end_found && fgets(intext,
TB_MAXLINE, l_ptr))
3798 if (line_number == 1
L)
3800 if (! strncmp(intext,
"CCSD", 4))
3805 *line_comment =
'\0';
3808 while ((
c = strstr(tintext,
"/*")) !=
NULL)
3810 for (tc = tintext; tc <
c; tc++)
3813 if (oddquotes) oddquotes =
FALSE;
3814 else oddquotes =
TRUE;
3820 (void)
strcpy(line_comment,
c);
3831 if (text !=
NULL || *
c !=
'\0')
3837 if (strcmp(
c,
"END") == 0)
3844 if (strcmp(
c,
"END_OBJECT") == 0 || strcmp(
c,
"END_GROUP") == 0 )
3851 equals_found = (strchr(text,
'=') !=
NULL);
3853 if (! val_found && equals_found)
3856 val_found = (*
c !=
'=');
3859 if (val_found && equals_found)
3872 if ((equals = (
char *)strchr(left_part,
'=')) !=
NULL)
3876 equals = text + strlen(text);
3877 right_part = equals;
3889 if ((strncmp(left_part,
"OBJECT ", 7) == 0) || (strcmp(left_part,
"OBJECT") == 0) ||
3890 (strncmp(left_part,
"GROUP ", 6) == 0) || (strcmp(left_part,
"GROUP") == 0))
3894 ++(curr_object->child_count);
3896 if ((strncmp(left_part,
"OBJECT ", 7) == 0) || (strcmp(left_part,
"OBJECT") == 0))
3903 message_fname, m_ptr, line_number);
3907 comment,line_comment,(
char *)0,(
char *)0,
3908 label_fname,is_a_group,line_number),
3918 if ((strncmp(left_part,
"END_OBJECT ", 11) == 0) || (strcmp(left_part,
"END_OBJECT") == 0) ||
3919 (strncmp(left_part,
"END_GROUP ", 10) == 0) || (strcmp(left_part,
"END_GROUP") == 0))
3923 if ((strncmp(left_part,
"END_OBJECT ", 11) == 0) || (strcmp(left_part,
"END_OBJECT") == 0))
3930 message_fname, m_ptr, line_number, is_a_group);
3933 CopyString(curr_object->post_comment, comment)
3934 CopyString(curr_object->end_comment, line_comment)
3937 if (curr_object->parent !=
NULL)
3938 curr_object = curr_object->parent;
3947 if ((strncmp(left_part,
"END ", 4) == 0) ||
3948 (strcmp(left_part,
"END") == 0))
3951 CopyString(curr_object->post_comment, comment)
3961 right_part, message_fname, m_ptr, line_number);
3965 comment, line_comment,
3966 label_fname, line_number),
3974 if ((value_list = curr_keyword->is_a_list) ==
TRUE)
3978 brace_nesting, paren_nesting,
3979 message_fname, m_ptr,
3980 value_list_line_number);
3991 equals_found =
FALSE;
4001 if (curr_object->parent !=
NULL)
4004 "Not enough END_OBJECT statements. Some objects may be incomplete");
4008 if ((! end_found) && (! ignore_missing_end))
4011 "END statement is missing");
4015 if (line_number == 0)
4023 if (! suppress_metrics && ! suppress_messages)
4026 (void)
OdlPrintLine(message_fname, m_ptr,
" |-------------------------------|\n");
4027 (void)
OdlPrintLine(message_fname, m_ptr,
" | Parsing Metrics: |\n");
4032 (void)sprintf(msgtext,
" | %7ld OBJECT Statements |\n", object_count);
4034 (void)sprintf(msgtext,
" | %7ld END_OBJECT Statements |\n", end_object_count);
4036 (void)sprintf(msgtext,
" | %7ld Keywords |\n", keyword_count);
4038 (void)sprintf(msgtext,
" | %7ld Comments |\n", comment_count);
4040 (void)
OdlPrintLine(message_fname, m_ptr,
" |-------------------------------|\n\n");
4045 if (! suppress_hierarchy && ! suppress_messages)
4047 if (label_fname ==
NULL)
4048 (void)sprintf(msgtext,
"Object Hierarchy in File: (no file name provided)");
4050 (
void)sprintf(msgtext,
"Object Hierarchy in File: %s", label_fname);
4052 (void)
OdlPrintLine(message_fname, m_ptr,
"\n--------------------------------------------------------------------------\n");
4054 (void)
OdlPrintLine(message_fname, m_ptr,
"\n--------------------------------------------------------------------------\n\n");
4064 if (label_fname ==
NULL)
4065 (void)sprintf(msgtext,
"End of Parsing File: (no file name provided)");
4067 (
void)sprintf(msgtext,
"End of Parsing File: %s", label_fname);
4069 (void)
OdlPrintLine(message_fname, m_ptr,
"\n--------------------------------------------------------------------------\n");
4071 (void)
OdlPrintLine(message_fname, m_ptr,
"\n--------------------------------------------------------------------------\n\n");
4074 if (label_fptr ==
NULL)
4078 if ((m_ptr !=
stdout) && (message_fptr ==
NULL))
4096 long *brace_nesting;
4097 long *paren_nesting;
4102 long *paren_nesting)
4108 for (
c=text; *
c !=
'\0'; ++
c)
4123 return((*brace_nesting == 0) && (*paren_nesting == 0));
4135 message_fname, message_fptr, line_number)
4140 char *message_fname;
4147 long paren_nesting,
char *message_fname,
4148 FILE *message_fptr,
long line_number)
4154 char *nesting_stack = {
NULL};
4158 NewString(nesting_stack, (
long)strlen(text))
4161 for (
c=text,sp=(nesting_stack-1); ((*
c !=
'\0') && (
status ==
TRUE)); ++
c)
4164 if ((*
c ==
'{') || (*
c ==
'('))
4168 if (((*
c ==
'}') && (*sp ==
'{')) || ((*
c ==
')') && (*sp ==
'(')))
4172 if ((*
c ==
'}') && (*sp !=
'{'))
4175 "Bad nesting in VALUE LIST. Expected a right parenthesis and found a brace instead.");
4179 if ((*
c ==
')') && (*sp !=
'('))
4182 "Bad nesting in VALUE LIST. Expected a right brace and found a parenthesis instead.");
4186 if ((sp < nesting_stack) && (*(
c+1) !=
'\0'))
4189 "VALUE LIST not properly enclosed in braces or parentheses");
4196 if (brace_nesting < 0)
4199 "Too many right braces in VALUE LIST");
4202 if (brace_nesting > 0)
4205 "Too many left braces in VALUE LIST");
4208 if (paren_nesting < 0)
4211 "Too many right parentheses in VALUE LIST");
4214 if (paren_nesting > 0)
4217 "Too many left parentheses in VALUE LIST");
4231 short OdlValidElement (text, message_fname, message_fptr, line_number,
4234 char *message_fname;
4237 long element_number;
4242 FILE *message_fptr,
long line_number,
4243 long element_number)
4249 char *save_units = 0;
4251 char *first_char = {
NULL};
4252 char *last_char = {
NULL};
4253 char *units_start = {
NULL};
4254 char *units_end = {
NULL};
4255 char *single_quote = {
NULL};
4256 char *double_quote = {
NULL};
4259 if (element_number <= 0)
4260 (void)
strcpy(element_prompt,
"");
4262 (
void)sprintf(element_prompt,
" LIST element %ld", element_number);
4264 single_quote = (
char *) strchr(text+1, (
int)
'\'');
4265 double_quote = (
char *) strchr(text+1, (
int)
'"');
4268 last_char = (
char *)
LastChar(text);
4273 if ((double_quote > first_char) && (double_quote < last_char))
4275 (void)sprintf(
message,
"Embedded double quote in VALUE%s", element_prompt);
4280 if (*first_char ==
'"')
4286 if ((single_quote > first_char) && (single_quote < last_char))
4288 (void)sprintf(
message,
"Embedded single quote in VALUE%s", element_prompt);
4293 if ((*first_char ==
'\'') && (*last_char ==
'\''))
4295 if (first_char == last_char)
4297 (void)sprintf(
message,
"Unpaired single quote in VALUE%s", element_prompt);
4303 if ((*first_char ==
'\'') && (*last_char !=
'\''))
4305 (void)sprintf(
message,
"Unpaired single quote in VALUE%s", element_prompt);
4310 if ((*first_char !=
'\'') && (*last_char ==
'\''))
4312 (void)sprintf(
message,
"Unpaired single quote in VALUE%s", element_prompt);
4317 if ((*first_char !=
'"') && (*last_char ==
'"'))
4319 (void)sprintf(
message,
"Unpaired double quote in VALUE%s", element_prompt);
4324 if ((element_number > 0) &&
4325 (first_char == (last_char-1)) && (*first_char ==
'"'))
4327 (void)sprintf(
message,
"Unpaired double quote in VALUE%s", element_prompt);
4332 if ((element_number > 0) &&
4333 (*first_char ==
'"') && (*(last_char-1) !=
'"'))
4335 (void)sprintf(
message,
"Unpaired double quote in VALUE%s", element_prompt);
4340 if ((*first_char !=
'\'') && (*last_char !=
'\''))
4343 if ((strcmp(first_char,
"n/a") != 0) && (strcmp(first_char,
"N/A") != 0))
4346 if (strstr(first_char,
"__") !=
NULL)
4348 (void)sprintf(
message,
"Multiple underscores in VALUE%s", element_prompt);
4353 if (*first_char ==
'_')
4355 (void)sprintf(
message,
"First character is an underscore in VALUE%s", element_prompt);
4360 if (*last_char ==
'_')
4362 (void)sprintf(
message,
"Last character is an underscore in VALUE%s", element_prompt);
4367 if ((units_start = (
char *) strchr(text, (
int)
'<')) !=
NULL)
4370 *units_start =
'\0';
4376 (void)sprintf(
message,
"Unable to determine the data type of VALUE%s: \"%s\"",
4377 element_prompt, first_char);
4382 if (units_start !=
NULL)
4385 if (strchr(units_start+1, (
int)
'<') !=
NULL)
4387 (void)sprintf(
message,
"Embedded '<' character found in the UNITS expression: \"<%s\", for VALUE%s: \"%s\"",
4388 units_start+1, element_prompt, first_char);
4393 units_end = (
char *) strchr(units_start+1, (
int)
'>');
4396 if (units_end ==
NULL)
4398 (void)sprintf(
message,
"Missing the closing '>' character in the UNITS expression: \"<%s\", for VALUE%s: \"%s\"",
4399 units_start+1, element_prompt, first_char);
4404 if (units_end != last_char)
4406 (void)sprintf(
message,
"Extraneous characters found after the closing '>' character in the UNITS expression: \"<%s\", for VALUE%s: \"%s\"",
4407 units_start+1, element_prompt, first_char);
4412 (void)strcat(text,
" ");
4413 (void)strcat(text, save_units);
4436 message_fname, message_fptr, line_number, group_type)
4437 OBJDESC *curr_object;
4440 char *message_fname;
4443 unsigned short group_type;
4448 char *right_part,
char *message_fname,
4449 FILE *message_fptr,
long line_number,
unsigned short group_type)
4456 if (curr_object->parent ==
NULL)
4459 (void)sprintf (errmsg,
4460 "Encountered an extra END_%s - Ignored",
4461 (group_type==
ODL_OBJECT) ?
"OBJECT" :
"GROUP");
4465 if (*equals !=
'\0')
4467 if (curr_object->is_a_group == group_type)
4473 if (*right_part !=
'\0')
4475 if (strcmp(curr_object->class, right_part) != 0)
4477 (void)sprintf (errmsg,
4478 "END_%s = %s doesn't match %s = %s",
4479 (group_type==
ODL_OBJECT) ?
"OBJECT" :
"GROUP",
4481 (curr_object->is_a_group==
ODL_OBJECT) ?
"OBJECT" :
"GROUP",
4482 curr_object->class);
4488 message_fname, message_fptr,line_number) &&
status;
4494 (void)sprintf (errmsg,
4495 "Found END_%s when expecting END_%s - Ignored",
4496 (group_type==
ODL_OBJECT) ?
"OBJECT" :
"GROUP",
4497 (curr_object->is_a_group==
ODL_OBJECT) ?
"OBJECT" :
"GROUP");
4514 short OdlValidIdentifier (id_name, id_type, message_fname, message_fptr, line_number)
4516 const char *id_name;
4517 const char *id_type;
4518 const char *message_fname;
4525 const char *message_fname, FILE *message_fptr,
4537 if (id_name ==
NULL)
4539 (void)sprintf(
message,
"%s identifier is missing", id_type);
4544 char *local_id_name =
strdup(id_name);
4550 if (*local_id_name ==
'\0')
4552 (void)sprintf(
message,
"%s identifier is missing", id_type);
4557 if (!
isalpha(*local_id_name))
4560 "%s identifier: \"%s\" does not begin with a letter",
4561 id_type, local_id_name);
4565 for (
c=local_id_name,
i=0; *
c !=
'\0'; ++
c)
4567 if ((*
c !=
'_') && (! isalnum(*
c))) ++
i;
4573 "%s identifier: \"%s\" contains %d embedded non-alphanumeric or \"_\" character",
4574 id_type, id_name,
i);
4575 if (
i > 1) (void)strcat(
message,
"s");
4581 free(local_id_name);
4597 short OdlValidKwd (curr_object, left_part, equals, right_part,
4598 message_fname, message_fptr, line_number)
4599 OBJDESC *curr_object;
4603 char *message_fname;
4609 short OdlValidKwd (OBJDESC *curr_object,
char *left_part,
char *equals,
4610 char *right_part,
char *message_fname,
4611 FILE *message_fptr,
long line_number)
4615 KEYWORD *keyword = {
NULL};
4619 short sfdu_only = {
FALSE};
4620 short found_keyword = {
FALSE};
4624 if (*left_part ==
'=')
4628 "KEYWORD identifier is missing");
4632 if (*equals ==
'\0')
4634 sfdu_only = ((strncmp(left_part,
"NJPL", 4) == 0) ||
4635 (strncmp(left_part,
"CCSD", 4) == 0));
4640 "Missing equals sign after KEYWORD identifier: \"%s\"", left_part);
4651 key = (*left_part !=
'^') ? left_part : left_part + 1;
4654 message_fptr, line_number) &&
status;
4656 for (keyword=curr_object->first_keyword;
4657 ((keyword !=
NULL) && (! found_keyword));
4658 keyword=keyword->right_sibling)
4660 if (keyword->name !=
NULL)
4661 found_keyword = (strcmp(keyword->name, left_part) == 0);
4667 "Duplicate KEYWORD identifier: \"%s\"", left_part);
4673 if (*right_part !=
'\0')
4676 if ((*right_part !=
'{') && (*right_part !=
'('))
4680 line_number, (
long)0) &&
status;
4693 "KEYWORD identifier: \"%s\" is missing a VALUE",
4712 message_fname, message_fptr, line_number)
4714 OBJDESC *curr_object;
4717 char *message_fname;
4724 char *right_part,
char *message_fname,
4725 FILE *message_fptr,
long line_number)
4731 if (*equals ==
'\0')
4734 "Missing equals sign after OBJECT statement");
4740 message_fname, message_fptr,line_number) &&
status;
4757 char *message_fname;
4764 FILE *message_fptr,
long line_number)
4768 char *first_char = {
NULL};
4769 char *last_char = {
NULL};
4780 save_c = *(++last_char);
4784 (void)
OdlValidElement(first_char,message_fname,message_fptr,line_number,
i);
4787 *last_char = save_c;
4839 const char *wildcard_text;
4840 const char *plain_text;
4845 const char *plain_text)
4850 char *substr = {
NULL};
4851 char *tmp_str = {
NULL};
4852 char *tmp_str2 = {
NULL};
4853 char *text_start = {
NULL};
4856 unsigned short allrightythen = {
FALSE};
4857 int StartOfLine = 1;
4860 if ((wildcard_text !=
NULL) && (plain_text !=
NULL))
4863 allrightythen =
TRUE;
4870 if ((save_it ==
'\'') || (save_it ==
'"'))
4882 save_it = *tmp_str2;
4883 if ((save_it ==
'\'') || (save_it ==
'"'))
4897 text_start = tmp_str2;
4899 if (strchr(substr,
'*') ==
NULL)
4900 allrightythen = (strcmp(text_start, substr) == 0);
4910 for ( ; *substr ==
'*'; ++substr) ;
4911 if (*substr ==
'\0')
break;
4914 for (
c=substr; ((*
c !=
'*') && (*
c !=
'\0')); ++
c) ;
4919 if ((
c = (
char *)strstr(text_start, substr)) ==
NULL)
4921 allrightythen =
FALSE;
4924 else if (StartOfLine)
4926 if (
c != text_start)
4928 allrightythen =
FALSE;
4935 len = strlen(substr);
4938 text_start =
c + len;
4939 if ((*substr ==
'\0') && (*text_start !=
'\0'))
4941 allrightythen =
FALSE;
4954 return(allrightythen);
4993 OBJDESC *curr_object;
4994 unsigned long root_level;
5002 OBJDESC *obj = {
NULL};
5003 OBJDESC *next_object = {
NULL};
5005 if (curr_object !=
NULL)
5008 if (curr_object->first_child !=
NULL)
5009 next_object = curr_object->first_child;
5012 if (curr_object->right_sibling !=
NULL)
5013 next_object = curr_object->right_sibling;
5017 for (next_object=
NULL,obj=curr_object->parent;
5018 (obj !=
NULL); obj=obj->parent)
5020 if (obj->level <= root_level)
5023 if (obj->right_sibling !=
NULL)
5025 next_object = obj->right_sibling;
5034 return(next_object);
5082 ((
c !=
NULL) && ((*
c <=
' ') || (*
c >
'~')) && (*
c !=
'\0')); ++
c) ;
5132 ((
c !=
NULL) && (*
c >
' ') && (*
c <=
'~') && (*
c !=
'\0')); ++
c) ;
5179 return(text + strspn(text,
"{}(), \n"));
5228 c = strpbrk(text,
"{}(),");
5231 for (--
c; ((
c > text) && ((*
c ==
' ') || (*
c ==
'\0'))); --
c) ;
5279 return(text + strspn(text,
"{}()\n"));
5327 c = strpbrk(text,
"{}()\n");
5330 for (--
c; ((
c > text) && ((*
c ==
' ') || (*
c ==
',') || (*
c ==
'\0'))); --
c) ;
5379 char *tempstr = {
NULL};
5380 char *last_pound = {
NULL};
5382 unsigned long decimal_count = {0};
5383 unsigned long hyphen_count = {0};
5384 unsigned long colon_count = {0};
5385 unsigned long t_count = {0};
5386 unsigned short has_sign = {
FALSE};
5389 static const char *valid_chars[17] = {
5406 "0123456789ABCDEF"};
5414 if ((
u = (
char *)strchr(tempstr,
'<')) !=
NULL) *
u =
'\0';
5442 if (strchr(
c,
' ') !=
NULL)
5448 for ( ; *
c !=
'\0'; ++
c)
5456 if (has_sign && (
c == (tempstr + 1)))
5470 if ((++decimal_count) > 1)
5483 if (has_sign && (
c == (tempstr + 1)))
5530 if ((++hyphen_count) > 2)
5552 if ((++t_count) > 1)
5568 if (*(
c + 1) !=
'\0')
5598 if (decimal_count != 0)
5614 if ((last_pound = (
char *)strchr(
c+1,
'#')) ==
NULL)
5618 if (*(last_pound + 1) !=
'\0')
5628 base = atoi(tempstr);
5632 if ((*
c ==
'+') || (*
c ==
'-')) ++
c;
5642 if (
c[strspn(
c, valid_chars[
base])] !=
'\0')
5710 unsigned short type;
5752 if (type_string !=
NULL) (void)
strcpy(type_string, local_type_string);
5754 return(local_type_string);
5789 FILE *fptr = {
NULL};
5790 char *fname = {
NULL};
5793 (void)
strcpy(base_name,
"tmp.tmp");
5796 (void)tmpnam(temp_str);
5797 (void)
strcpy( base_name, temp_str);
5802 #if (defined( VAX) || defined( ALPHA_VMS))
5803 (void)tmpnam(temp_str);
5804 (void)sprintf(base_name,
"sys$login:%s.tmp", temp_str);
5808 (void)tmpnam(temp_str);
5809 (void)sprintf(base_name,
"%s.tmp", temp_str);
5816 (void)sprintf(base_name,
"C:\\%ld",
t);
5818 (void)strcat(base_name,
".tmp");
5824 if ((fptr = (FILE *) fopen(fname,
"w")) ==
NULL)
5837 long quote_nesting = 0;
5838 long brace_nesting = 0;
5839 long paren_nesting = 0;
5843 c1 = (
char *) strchr(text,
'=');
5846 if ((*
c ==
'(') || (*
c ==
'{'))
5851 for (; *
c !=
'\0'; ++
c)
5855 if (quote_nesting == 0)
5863 return((brace_nesting + paren_nesting + quote_nesting) == 0);