home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / icont / lnklist.c < prev    next >
C/C++ Source or Header  |  1996-03-22  |  2KB  |  85 lines

  1. /*
  2.  * lnklist.c -- functions for handling file linking.
  3.  */
  4.  
  5. #include <ctype.h>
  6. #include "::h:gsupport.h"
  7. #include "tproto.h"
  8. #include "lfile.h"
  9.  
  10. /*
  11.  * Prototype.
  12.  */
  13. hidden    struct lfile *alclfile    Params((char *name));
  14.  
  15. struct lfile *lfiles;
  16. struct invkl *invkls;
  17.  
  18. /*
  19.  * addinvk adds an "invokable" name to the list.
  20.  *  n==1 if name is an identifier; otherwise it is a string literal.
  21.  */
  22. novalue addinvk(name, n)
  23. char *name;
  24. int n;
  25.    {
  26.    struct invkl *p;
  27.  
  28.    if (n == 1) {            /* if identifier, must be "all" */
  29.       if (strcmp(name,"all") != 0) {
  30.          tfatal("invalid operand to invocable", name);
  31.          return;
  32.          }
  33.       else
  34.          name = "0";            /* "0" represents "all" */
  35.       }
  36.    else if (!isalpha(name[1]) && (name[1] != '_'))
  37.       return;                /* if operator, ignore */
  38.  
  39.    p = (struct invkl *) alloc(sizeof(struct invkl));
  40.    if (!p)
  41.       tsyserr("not enough memory for invocable list");
  42.    p->iv_name = salloc(name);
  43.    p->iv_link = invkls;
  44.    invkls = p;
  45.    }
  46.  
  47. /*
  48.  * alclfile allocates an lfile structure for the named file, fills
  49.  *  in the name and returns a pointer to it.
  50.  */
  51. static struct lfile *alclfile(name)
  52. char *name;
  53.    {
  54.    struct lfile *p;
  55.    
  56.    p = (struct lfile *) alloc(sizeof(struct lfile));
  57.    if (!p)
  58.       tsyserr("not enough memory for file list");
  59.    p->lf_link = NULL;
  60.    p->lf_name = salloc(name);
  61.    return p;
  62.    }
  63.  
  64. /*
  65.  * addlfile creates an lfile structure for the named file and add it to the
  66.  *  end of the list of files (lfiles) to generate link instructions for.
  67.  */
  68. novalue addlfile(name)
  69. char *name;
  70. {
  71.    struct lfile *nlf, *p;
  72.    
  73.    nlf = alclfile(name);
  74.    if (lfiles == NULL) {
  75.       lfiles = nlf;
  76.       }
  77.    else {
  78.       p = lfiles;
  79.       while (p->lf_link != NULL) {
  80.          p = p->lf_link;
  81.          }
  82.       p->lf_link = nlf;
  83.       }
  84. }
  85.