Example #1
0
int upstst_split(char *input, int * const argc, char *** const argv)
{
static char *tmp_argv[255];

*argc = 0;
#define getquote() {				\
  input++;					\
  tmp_argv[(*argc)++] = input;			\
  while (*input && *input != '"') input++;	\
  if (*input)					\
     *input = 0;				\
  else						\
      return -1;				\
  }
	
while( *input ) 
   {
   if (*input == '"') 
      { getquote(); }
   else if (!(isspace((int)*input)))		/* start of word */
      {
      tmp_argv[(*argc)++] = input;		/* take full arg as is */
      while (*input && !(isspace((int)*input))) 
         {
         input++;				/* copy full word */
	 if (*input == '"')
            { *input = 0; getquote(); input++; }
         }
      if (*input == 0) goto split_end;		/* all done */
      *input = 0;				/* null terminate */
      }

   input++;
   }

split_end:

tmp_argv[*argc] = 0;
*argv = tmp_argv; 
return 0;
}
Example #2
0
main( int argc, char **argv)
{

   long where;
   FILE *stream;

   banner( argv );

   if ( ! configure( B_GENERIC ))
      panic();

/*--------------------------------------------------------------------*/
/*                  Validate the number of arguments                  */
/*--------------------------------------------------------------------*/

      if ( argc !=  4 )
         usage();

/*--------------------------------------------------------------------*/
/*    Determine the number of the quotes available, and then          */
/*    select one                                                      */
/*--------------------------------------------------------------------*/

      where = getquote( argv[2], argv[3] );

/*--------------------------------------------------------------------*/
/*                      Open up our output file                       */
/*--------------------------------------------------------------------*/

      stream = fopen( argv[3] , "w");
      if ( stream == NULL )
      {
         perror( argv[3] );
         panic();
      }

/*--------------------------------------------------------------------*/
/*           Copy the fixed and variable parts of the file            */
/*--------------------------------------------------------------------*/

      CopyFixed( argv[1], stream );
      CopyQuote( argv[2], where, stream );

/*--------------------------------------------------------------------*/
/*                   Close up and return to caller                    */
/*--------------------------------------------------------------------*/

      fclose( stream );
      exit(0);
      return 0;

} /* main */
Example #3
0
int
POL::gettok (TOKEN *tok)
{
  int c, toktype;
  int inum;
  double fnum;
  int toksiz = MAXTOK;          /* maximum length of token string */

  while ((c = inchar()) == BLANK || c == TAB)
    ;
  ungetch (c);

  c = lookchar();
  toktype = type(c);

  fnum = 0.0;
  inum = 0;

  if (c == BLANK || c == TAB) {                 /* skip white space */
    getblank(tok->tokstr, toksiz);
    toktype = TT_BLANK;
  } else if (toktype == LETTER) {
    toktype = getalpha (tok->tokstr, toksiz);
  } else if (c == meta.str) {                   /* quoted string */
    getquote (tok->tokstr, toksiz);
    toktype = TT_STRING;
  } else if (type(c) == DIGIT || c == PLUS || c == HYPHEN || c == PERIOD) {
    toktype = getnumber (tok->tokstr, toksiz, &fnum, &inum);
  } else if (c == EOF) {
    tok->tokstr[0] = EOS;
    toktype = TT_EOF;
  } else {
    c = inchar();
    tok->tokstr[0] = c;
    tok->tokstr[1] = EOS;
    toktype = TT_SPECLCHAR;
  }

  tok->type = toktype;
  tok->ready = true;
  if (tok->type == TT_REAL || tok->type == TT_INT) {
    tok->fnum = fnum;
    tok->inum = inum;
  } else {
    tok->fnum = 0.0;
    tok->inum = 0;
  }

  return (toktype);
}
Example #4
0
void getquotes(int &nquotes)
{
  int result = 1;
  nquotes = 0;

  ifstream in("chessp.cpq");
  if (in.fail())
     {
      puts("Can't find chessp.cpq in current directory!\n");
      exit(1);
     }

  do
    result = getquote(nquotes++, in);
  while (result);

  nquotes--;

  in.close();
}