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

Diff for /src/usr.bin/rpcgen/rpc_parse.c between version 1.7 and 1.8

version 1.7, 2001/11/24 19:19:59 version 1.8, 2001/12/05 09:50:31
Line 35 
Line 35 
 #endif  #endif
   
 /*  /*
  * rpc_parse.c, Parser for the RPC protocol compiler   * rpc_parse.c, Parser for the RPC protocol compiler
  * Copyright (C) 1987 Sun Microsystems, Inc.   * Copyright (C) 1987 Sun Microsystems, Inc.
  */   */
 #include <stdio.h>  #include <stdio.h>
Line 165 
Line 165 
                 do {                  do {
                         /* get result type */                          /* get result type */
                         plist = ALLOC(proc_list);                          plist = ALLOC(proc_list);
                         get_type(&plist->res_prefix, &plist->res_type,                          get_type(&plist->res_prefix, &plist->res_type,
                                  DEF_PROGRAM);                                   DEF_PROGRAM);
                         if (streq(plist->res_type, "opaque")) {                          if (streq(plist->res_type, "opaque")) {
                                 error("illegal result type");                                  error("illegal result type");
Line 176 
Line 176 
                         /* get args - first one*/                          /* get args - first one*/
                         num_args = 1;                          num_args = 1;
                         isvoid = FALSE;                          isvoid = FALSE;
                         /* type of DEF_PROGRAM in the first                          /* type of DEF_PROGRAM in the first
                          * get_prog_declaration and DEF_STURCT in the next                           * get_prog_declaration and DEF_STURCT in the next
                          * allows void as argument if it is the only argument                           * allows void as argument if it is the only argument
                          */                           */
Line 188 
Line 188 
                         decls->decl = dec;                          decls->decl = dec;
                         tailp = &decls->next;                          tailp = &decls->next;
                         /* get args */                          /* get args */
                         while(peekscan(TOK_COMMA, &tok)) {                          while (peekscan(TOK_COMMA, &tok)) {
                           num_args++;                            num_args++;
                           get_prog_declaration(&dec, DEF_STRUCT,                            get_prog_declaration(&dec, DEF_STRUCT,
                                                num_args);                                                 num_args);
                           decls = ALLOC(decl_list);                            decls = ALLOC(decl_list);
                           decls->decl = dec;                            decls->decl = dec;
Line 203 
Line 203 
                         if( !newstyle && num_args > 1 ) {                          if( !newstyle && num_args > 1 ) {
                           error("only one argument is allowed" );                            error("only one argument is allowed" );
                         }                          }
                         if (isvoid && num_args > 1) {                          if (isvoid && num_args > 1) {
                           error("illegal use of void in program definition");                            error("illegal use of void in program definition");
                         }                          }
                         *tailp = NULL;                          *tailp = NULL;
Line 225 
Line 225 
                 scan_num(&tok);                  scan_num(&tok);
                 vlist->vers_num = tok.str;                  vlist->vers_num = tok.str;
                 /* make the argument structure name for each arg*/                  /* make the argument structure name for each arg*/
                 for(plist = vlist->procs; plist != NULL;                  for(plist = vlist->procs; plist != NULL;
                     plist = plist->next) {                      plist = plist->next) {
                         plist->args.argname = make_argname(plist->proc_name,                          plist->args.argname = make_argname(plist->proc_name,
                                                            vlist->vers_num);                                                             vlist->vers_num);
                         /* free the memory ??*/                          /* free the memory ??*/
                 }                  }
                 scan(TOK_SEMICOLON, &tok);                  scan(TOK_SEMICOLON, &tok);
Line 316 
Line 316 
     if(peekscan(TOK_CASE,&tok))      if(peekscan(TOK_CASE,&tok))
       {        {
   
         do          do
           {            {
             scan2(TOK_IDENT, TOK_CHARCONST, &tok);              scan2(TOK_IDENT, TOK_CHARCONST, &tok);
             cases->contflag=1;  /* continued case statement */              cases->contflag=1;  /* continued case statement */
Line 325 
Line 325 
             cases = ALLOC(case_list);              cases = ALLOC(case_list);
             cases->case_name = tok.str;              cases->case_name = tok.str;
             scan(TOK_COLON, &tok);              scan(TOK_COLON, &tok);
   
           }while(peekscan(TOK_CASE,&tok));            } while (peekscan(TOK_CASE,&tok));
       }        }
     else      else
       if(flag)        if(flag)
Line 359 
Line 359 
   }    }
 }  }
   
 static char* reserved_words[] = {  static char *reserved_words[] = {
         "array",          "array",
         "bytes",          "bytes",
         "destroy",          "destroy",
Line 375 
Line 375 
         NULL          NULL
 };  };
   
 static char* reserved_types[] = {  static char *reserved_types[] = {
         "opaque",          "opaque",
         "string",          "string",
         NULL          NULL
Line 385 
Line 385 
    xdr routines that would conflict with internal XDR routines. */     xdr routines that would conflict with internal XDR routines. */
 static check_type_name( name, new_type )  static check_type_name( name, new_type )
 int new_type;  int new_type;
 char* name;  char *name;
 {  {
   int i;    int i;
   char tmp[100];    char tmp[100];
   
   for( i = 0; reserved_words[i] != NULL; i++ ) {    for( i = 0; reserved_words[i] != NULL; i++ ) {
     if( strcmp( name, reserved_words[i] ) == 0 ) {      if( strcmp( name, reserved_words[i] ) == 0 ) {
       sprintf(tmp,        sprintf(tmp,
               "illegal (reserved) name :\'%s\' in type definition", name );                "illegal (reserved) name :\'%s\' in type definition", name );
       error(tmp);        error(tmp);
     }      }
Line 400 
Line 400 
   if( new_type ) {    if( new_type ) {
     for( i = 0; reserved_types[i] != NULL; i++ ) {      for( i = 0; reserved_types[i] != NULL; i++ ) {
       if( strcmp( name, reserved_types[i] ) == 0 ) {        if( strcmp( name, reserved_types[i] ) == 0 ) {
         sprintf(tmp,          sprintf(tmp,
                 "illegal (reserved) name :\'%s\' in type definition", name );                  "illegal (reserved) name :\'%s\' in type definition", name );
         error(tmp);          error(tmp);
       }        }
Line 486 
Line 486 
         token tok;          token tok;
         char name[10]; /* argument name */          char name[10]; /* argument name */
   
         if (dkind == DEF_PROGRAM) {          if (dkind == DEF_PROGRAM) {
           peek(&tok);            peek(&tok);
           if (tok.kind == TOK_RPAREN) { /* no arguments */            if (tok.kind == TOK_RPAREN) { /* no arguments */
                 dec->rel = REL_ALIAS;                  dec->rel = REL_ALIAS;
Line 500 
Line 500 
         dec->rel = REL_ALIAS;          dec->rel = REL_ALIAS;
         if (peekscan(TOK_IDENT, &tok))  /* optional name of argument */          if (peekscan(TOK_IDENT, &tok))  /* optional name of argument */
                 strcpy(name, tok.str);                  strcpy(name, tok.str);
         else          else
                 sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */                  sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */
   
         dec->name = (char *)strdup(name);          dec->name = (char *)strdup(name);
   
         if (streq(dec->type, "void")) {          if (streq(dec->type, "void")) {
                 return;                  return;
         }          }
Line 512 
Line 512 
         if (streq(dec->type, "opaque")) {          if (streq(dec->type, "opaque")) {
                 error("opaque -- illegal argument type");                  error("opaque -- illegal argument type");
         }          }
         if (peekscan(TOK_STAR, &tok)) {          if (peekscan(TOK_STAR, &tok)) {
           if (streq(dec->type, "string")) {            if (streq(dec->type, "string")) {
             error("pointer to string not allowed in program arguments\n");              error("pointer to string not allowed in program arguments\n");
           }            }
Line 535 
Line 535 
         }          }
         if (streq(dec->type, "string")) {          if (streq(dec->type, "string")) {
                 if (dec->rel != REL_ARRAY) {  /* .x specifies just string as                  if (dec->rel != REL_ARRAY) {  /* .x specifies just string as
                                                * type of argument                                                 * type of argument
                                                * - make it string<>                                                 * - make it string<>
                                                */                                                 */
                         dec->rel = REL_ARRAY;                          dec->rel = REL_ARRAY;

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