[BACK]Return to rpc_util.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rpcgen

Diff for /src/usr.bin/rpcgen/rpc_util.c between version 1.6 and 1.7

version 1.6, 2001/11/24 19:19:59 version 1.7, 2001/12/05 09:50:31
Line 35 
Line 35 
 #endif  #endif
   
 /*  /*
  * rpc_util.c, Utility routines for the RPC protocol compiler   * rpc_util.c, Utility routines for the RPC protocol compiler
  */   */
 #include <sys/cdefs.h>  #include <sys/cdefs.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <ctype.h>  #include <ctype.h>
   #include <unistd.h>
 #include "rpc_scan.h"  #include "rpc_scan.h"
 #include "rpc_parse.h"  #include "rpc_parse.h"
 #include "rpc_util.h"  #include "rpc_util.h"
Line 66 
Line 67 
 list *defined;                  /* list of defined things */  list *defined;                  /* list of defined things */
   
 /*  /*
  * Reinitialize the world   * Reinitialize the world
  */   */
   void
 reinitialize()  reinitialize()
 {  {
         memset(curline, 0, MAXLINESIZE);          memset(curline, 0, MAXLINESIZE);
Line 77 
Line 79 
 }  }
   
 /*  /*
  * string equality   * string equality
  */   */
   int
 streq(a, b)  streq(a, b)
         char *a;          char *a;
         char *b;          char *b;
Line 87 
Line 90 
 }  }
   
 /*  /*
  * find a value in a list   * find a value in a list
  */   */
 definition *  definition *
 findval(lst, val, cmp)  findval(lst, val, cmp)
Line 96 
Line 99 
         int (*cmp) ();          int (*cmp) ();
   
 {  {
   
         for (; lst != NULL; lst = lst->next) {          for (; lst != NULL; lst = lst->next) {
                 if ((*cmp) (lst->val, val)) {                  if ((*cmp) (lst->val, val)) {
                         return (lst->val);                          return (lst->val);
Line 106 
Line 109 
 }  }
   
 /*  /*
  * store a value in a list   * store a value in a list
  */   */
 void  void
 storeval(lstp, val)  storeval(lstp, val)
Line 116 
Line 119 
         list **l;          list **l;
         list *lst;          list *lst;
   
   
         for (l = lstp; *l != NULL; l = (list **) & (*l)->next);          for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
         lst = ALLOC(list);          lst = ALLOC(list);
         lst->val = val;          lst->val = val;
Line 124 
Line 126 
         *l = lst;          *l = lst;
 }  }
   
 static  static int
 findit(def, type)  findit(def, type)
         definition *def;          definition *def;
         char *type;          char *type;
Line 193 
Line 195 
         }          }
 }  }
   
 static  static int
 typedefed(def, type)  typedefed(def, type)
         definition *def;          definition *def;
         char *type;          char *type;
Line 205 
Line 207 
         }          }
 }  }
   
   int
 isvectordef(type, rel)  isvectordef(type, rel)
         char *type;          char *type;
         relation rel;          relation rel;
Line 238 
Line 241 
         static char buf[100];          static char buf[100];
         char *p = buf;          char *p = buf;
   
         while (c = *str++) {          while ((c = *str++)) {
                 *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;                  *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
         }          }
         *p = 0;          *p = 0;
Line 262 
Line 265 
 }  }
   
 /*  /*
  * print a useful (?) error message, and then die   * print a useful (?) error message, and then die
  */   */
 void  void
 error(msg)  error(msg)
Line 276 
Line 279 
   
 /*  /*
  * Something went wrong, unlink any files that we may have created and then   * Something went wrong, unlink any files that we may have created and then
  * die.   * die.
  */   */
   void
 crash()  crash()
 {  {
         int i;          int i;
Line 304 
Line 308 
 static char *toktostr();  static char *toktostr();
   
 /*  /*
  * error, token encountered was not the expected one   * error, token encountered was not the expected one
  */   */
 void  void
 expected1(exp1)  expected1(exp1)
Line 316 
Line 320 
 }  }
   
 /*  /*
  * error, token encountered was not one of two expected ones   * error, token encountered was not one of two expected ones
  */   */
 void  void
 expected2(exp1, exp2)  expected2(exp1, exp2)
Line 329 
Line 333 
 }  }
   
 /*  /*
  * error, token encountered was not one of 3 expected ones   * error, token encountered was not one of 3 expected ones
  */   */
 void  void
 expected3(exp1, exp2, exp3)  expected3(exp1, exp2, exp3)
Line 352 
Line 356 
         }          }
 }  }
   
   
 static token tokstrings[] = {  static token tokstrings[] = {
         {TOK_IDENT, "identifier"},          {TOK_IDENT, "identifier"},
         {TOK_CONST, "const"},          {TOK_CONST, "const"},
Line 400 
Line 403 
         return (sp->str);          return (sp->str);
 }  }
   
 static  static void
 printbuf()  printbuf()
 {  {
         char c;          char c;
Line 409 
Line 412 
   
 #       define TABSIZE 4  #       define TABSIZE 4
   
         for (i = 0; c = curline[i]; i++) {          for (i = 0; (c = curline[i]); i++) {
                 if (c == '\t') {                  if (c == '\t') {
                         cnt = 8 - (i % TABSIZE);                          cnt = 8 - (i % TABSIZE);
                         c = ' ';                          c = ' ';
Line 444 
Line 447 
         (void) fputc('\n', stderr);          (void) fputc('\n', stderr);
 }  }
   
 char *  char *
 make_argname(pname, vname)  make_argname(pname, vname)
         char *pname;          char *pname;
         char *vname;          char *vname;
 {  {
         char *name;          char *name;
   
         name = (char *)malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3);          name = (char *)malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3);
         if (!name) {          if (!name) {
                 fprintf(stderr, "failed in malloc");                  fprintf(stderr, "failed in malloc");
Line 493 
Line 496 
 {  {
         bas_type * ptr;          bas_type * ptr;
   
         ptr=typ_list_h;          ptr = typ_list_h;
   
   
         while (ptr != NULL) {          while (ptr != NULL) {
                 if (strcmp(ptr->name,type) == 0)                  if (strcmp(ptr->name,type) == 0)

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7