4 * (C) Copyright 1989-1995
11 * With contributions for the
12 * object libraries from
14 * kenh@cmf.nrl.navy.mil
29 long pos = ftell (libfp);
33 if (((c = getc (libfp)) == 'X' || c == 'D' || c == 'Q') && ((c = getc (libfp)) == 'H' || c == 'L'))
38 if (getc (libfp) == '\n')
50 if (fread (buf, 1, sizeof (buf), libfp) == sizeof (buf) && memcmp (buf, "!FILE ", 6) == 0)
53 fseek (libfp, pos, SEEK_SET);
57 /* Load a .rel file embedded in a sdcclib file */
59 load_rel (FILE * libfp, long size)
67 end = ftell (libfp) + size;
71 while ((end < 0 || ftell (libfp) < end) && getline (str, sizeof (str), libfp) != NULL)
73 if (0 == strcmp (str, "</REL>"))
87 enum_symbols (FILE * fp, long size, int (*func) (const char *symvoid, void *param), void *param)
90 long end = (size >= 0) ? ftell (fp) + size : -1;
92 assert (func != NULL);
95 * Read in the object file. Look for lines that
96 * begin with "S" and end with "D". These are
97 * symbol table definitions. If we find one, see
98 * if it is our symbol. Make sure we only read in
99 * our object file and don't go into the next one.
102 while ((end <= 0 || ftell (fp) < end) && getline (buf, sizeof (buf), fp) != NULL)
104 char symname[NINPUT];
108 * When a 'T line' is found terminate file scan.
109 * All 'S line's preceed 'T line's in .REL files.
115 * Skip everything that's not a symbol record.
120 sscanf (buf, "S %s %c", symname, &c);
122 /* If it's an actual symbol, record it */
125 if ((*func) (symname, param))