ftp.nice.ch/pub/next/graphics/convertors/CmdLineGIFeditor.s.tar.gz#/GIFeditor/parse.c

This is parse.c in view mode; [Download] [Up]

/*
 *  parse.c
 *  
 *  Jim W Kiraly
 *  July 29 1991
 *
 *  includes and other things
 *
 */


#include <stdio.h>
extern char *jargv[6];


/*
 *  ParseArgs - look throught the command line and do the following
 *	put infile name into  		argv[1];
 *	put outfile name into 		argv[2];
 *	put red image info into		argv[3];
 *
 *	return 0 if there is an error in the command line
 *	return 1 if inverting image
 *	return 2 if scaling image
 *	return 3 if rgbing image
 *	return 4 if contrast image
 */


int ParseArgs ( ac, av )
int ac;
char **av;
{
  int count, argUsed[6];
  int retValue=-1;

  ac--;
  for (count=0; count<=5; argUsed[count++]=0);

  for (count=1; count<=ac; count++) {

    if (av[count][0]!='-') {		/*  In or out file  */

      if (!argUsed[1]) {		/*  Infile ??  */
        jargv[1] = av[count]; 
        argUsed[1]=1;
      }
      else	
      if (!argUsed[2]) {		/*  Outfile ??  */
        jargv[2] = av[count];
        argUsed[2]=1;
      }
      else				/*  Too many args  */
        return 0;

    }					/*  In or out file  */
    else
    if (av[count][0]=='-' ) {		/*  The main option  */
 
      if (av[count][1]=='i')		/*  Inverting  */
        retValue=1;

      if (av[count][1]=='s')		/*  Scaling  */
        retValue=2;

      if (av[count][1]=='r') {		/*  Red thingy  */
        retValue=3;
        jargv[3] = av[++count];
        argUsed[3]=1;
      }

      if (av[count][1]=='g') {		/*  Green thingy  */
        retValue=3;
        jargv[4] = av[++count];
        argUsed[4]=1;
      }

      if (av[count][1]=='b') {		/*  Blue thingy  */
        retValue=3;
        jargv[5]=av[++count];
        argUsed[5]=1;
      }

      if (av[count][1]=='c') {
        retValue=4;
        jargv[3] = av[++count];
        argUsed[3]=1;
      }
    }
  }

  if (retValue==-1)		/*  No option chosen  */
    return 0;

  if (!argUsed[1] || !argUsed[2]) 	/*  No in or out file */
    return 0;

  return retValue;
} 

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.