8 * _buildpath builds a list of file names and terminal descriprions extracted
9 * from its arguments. It returns a pointer to a structure that is used by
10 * other routines as the list of file names to search for terminal
11 * descriptions. It is passed a variable number of arguments consisting
12 * of file name and type pairs. The file name can actually be a list of
13 * file names seperated by spaces and any environment variables specified
14 * by a dollar sign ($) followed by its name are substituted in. A type
15 * of 1 indicates that the file name may actually be termcap description
16 * and a type of 2 indicates it may be a terminfo description. A type of 0
17 * indicates that the file name can only be a file name (or list of them).
26 static const char SCCSid[] = "@(#) mytinfo buildpath.c 3.2 92/02/01 public domain, By Ross Ridge";
29 /* more memory is allocated for file names every HUNK file names */
32 /* characters that seperate file names in a list */
33 #define SEPERATORS " :"
35 static struct term_path *path = NULL; /* the list of files */
36 static int files = 0; /* # of files in the list */
37 static int size = 0; /* # of files there is space for */
39 /* add a file name, type pair to the list */
50 } else if (file[0] == '\0')
55 printf("addfile: %s\n", file);
60 path = (struct term_path *) reallocf((anyptr) path,
61 size * sizeof(struct term_path));
66 path[files].file = file;
69 s = (char *) malloc(l * sizeof(char));
72 path[files].file = strcpy(s, file);
74 path[files].type = type;
79 /* deallocate space used by the path list */
82 struct term_path *ppath; {
86 while(p->file != NULL) {
87 free((anyptr)p->file);
94 /* build a list of paths. see above */
98 _buildpath(file, type)
103 #ifdef USE_PROTOTYPES
104 struct term_path *_buildpath(char *file, int type, ...)
106 struct term_path *_buildpath(file, type)
109 #endif /* USE_PROTOTYPES */
110 #else /* USE_STDARG */
111 struct term_path *_buildpath(va_alist)
113 #endif /* USE_STDARG */
123 register char *s, *d, *e;
125 char line[MAX_BUF+1];
126 char name[MAX_NAME+1];
140 file = va_arg(ap, char *);
141 type = va_arg(ap, int);
145 while (type >= 0 && type <= 2) {
153 while(*s != '\0' && (*s == '_' || isalnum(*s)))
169 } else if (*s == '/')
180 if (type == 0 || line[0] == '/') {
182 while ((s = strsep(&p, SEPERATORS)) != NULL && *s == '\0')
185 if (addfile(s, 0) == 0)
187 while ((s = strsep(&p, SEPERATORS)) != NULL && *s == '\0')
191 if (addfile(line, type) == 0)
193 file = va_arg(ap, char *);
194 type = va_arg(ap, int);