Lines Matching defs:ifile
1 /* $NetBSD: ifile.c,v 1.5 2023/10/06 05:49:49 simonb Exp $ */
14 * An IFILE represents an input file.
16 * It is actually a pointer to an ifile structure,
18 * Ifile structures are kept in a linked list in the order they
26 extern IFILE curr_ifile;
28 struct ifile {
29 struct ifile *h_next; /* Links for command line list */
30 struct ifile *h_prev;
36 char h_opened; /* Has this ifile been opened? */
43 * Convert an IFILE (external representation)
46 #define int_ifile(h) ((struct ifile *)(h))
47 #define ext_ifile(h) ((IFILE)(h))
52 static struct ifile anchor = { &anchor, &anchor, NULL, NULL, NULL, 0, 0, '\0',
56 static void incr_index(struct ifile *p, int incr)
63 * Link an ifile into the ifile list.
65 static void link_ifile(struct ifile *p, struct ifile *prev)
86 * Unlink an ifile from the ifile list.
88 static void unlink_ifile(struct ifile *p)
97 * Allocate a new ifile structure and stick a filename in it.
100 * Return a pointer to the new ifile structure.
102 static struct ifile * new_ifile(char *filename, struct ifile *prev)
104 struct ifile *p;
109 p = (struct ifile *) ecalloc(1, sizeof(struct ifile));
129 * Delete an existing ifile structure.
131 public void del_ifile(IFILE h)
133 struct ifile *p;
138 * If the ifile we're deleting is the currently open ifile,
152 * Get the ifile after a given one in the list.
154 public IFILE next_ifile(IFILE h)
156 struct ifile *p;
165 * Get the ifile before a given one in the list.
167 public IFILE prev_ifile(IFILE h)
169 struct ifile *p;
178 * Return a different ifile from the given one.
180 public IFILE getoff_ifile(IFILE ifile)
182 IFILE newifile;
184 if ((newifile = prev_ifile(ifile)) != NULL_IFILE)
186 if ((newifile = next_ifile(ifile)) != NULL_IFILE)
200 * Find an ifile structure, given a filename.
202 static struct ifile * find_ifile(char *filename)
204 struct ifile *p;
230 * Get the ifile associated with a filename.
232 * insert the new ifile after "prev" in the list.
234 public IFILE get_ifile(char *filename, IFILE prev)
236 struct ifile *p;
244 * Get the display filename associated with a ifile.
246 public char * get_filename(IFILE ifile)
248 if (ifile == NULL)
250 return (int_ifile(ifile)->h_filename);
254 * Get the canonical filename associated with a ifile.
256 public char * get_real_filename(IFILE ifile)
258 if (ifile == NULL)
260 return (int_ifile(ifile)->h_rfilename);
264 * Get the index of the file associated with a ifile.
266 public int get_index(IFILE ifile)
268 return (int_ifile(ifile)->h_index);
274 public void store_pos(IFILE ifile, struct scrpos *scrpos)
276 int_ifile(ifile)->h_scrpos = *scrpos;
283 public void get_pos(IFILE ifile, struct scrpos *scrpos)
285 *scrpos = int_ifile(ifile)->h_scrpos;
289 * Mark the ifile as "opened".
291 public void set_open(IFILE ifile)
293 int_ifile(ifile)->h_opened = 1;
297 * Return whether the ifile has been opened previously.
299 public int opened(IFILE ifile)
301 return (int_ifile(ifile)->h_opened);
304 public void hold_ifile(IFILE ifile, int incr)
306 int_ifile(ifile)->h_hold += incr;
309 public int held_ifile(IFILE ifile)
311 return (int_ifile(ifile)->h_hold);
314 public void * get_filestate(IFILE ifile)
316 return (int_ifile(ifile)->h_filestate);
319 public void set_filestate(IFILE ifile, void *filestate)
321 int_ifile(ifile)->h_filestate = filestate;
324 public void set_altpipe(IFILE ifile, void *p)
326 int_ifile(ifile)->h_altpipe = p;
329 public void *get_altpipe(IFILE ifile)
331 return (int_ifile(ifile)->h_altpipe);
334 public void set_altfilename(IFILE ifile, char *altfilename)
336 struct ifile *p = int_ifile(ifile);
342 public char * get_altfilename(IFILE ifile)
344 return (int_ifile(ifile)->h_altfilename);
350 struct ifile *p;