/* GetQuote get any name between double quotes off command line * return string as chLabel, is null terminated * lgOK TRUE if ok * OrgCard.chOrgCard * uses orifinal image of line before capitalized, * sets Cap'd version of name to spaces so later commands * do not key on it */ #include #include "cddefines.h" #include "getquote.h" #include "input.h" void GetQuote(char *chLabel, /* we will generate a label and stuff it here */ char *chCard ) /* local capd line, we will blank this out */ { char *i0, /* pointer to first " */ *i1 , /* pointer to last ", name is in between */ *iOrg; /* pointer to first " in local version of card in calling routine*/ long int i; # ifdef DEBUG_FUN fputs( "<+>GetQuote()\n", debug_fp ); # endif /*label within quotes returned within chLabel *length is nLabel, lgOK says whether found or not *label in line image is set to blanks when complete */ /* find start of string, string must begin and end with double quotes */ /* get pointer to first quote */ i0 = strchr( input.chOrgCard,'\"' ); /* get pointer to last quote */ i1 = strrchr( input.chOrgCard,'\"' ); /* chech that pointers were not NULL, and also that they were not the same */ if( (i0==NULL) || (i1==NULL) || (i0==i1) ) { fprintf( ioQQQ, " A filename or label must be specified within double quotes, but no quotes were encountered on this command.\n" ); fprintf( ioQQQ, " Name must be surrounded by exactly two double quotes, like \"name.txt\". \n" ); fprintf( ioQQQ, " The line image follows:\n" ); fprintf( ioQQQ, " %s\n", input.chOrgCard); fprintf( ioQQQ, " Sorry\n" ); puts( "[Stop in getquote]" ); exit(1); } /* get pointer to first quote in line image in calling routine */ iOrg = strchr( chCard ,'\"' ); if( iOrg == NULL ) { fprintf( ioQQQ, " Insanity in GetQuote - line image follows:\n" ); fprintf( ioQQQ, " %s\n", input.chOrgCard); puts( "[Stop in getquote]" ); exit(1); } /* increment i so that it points to the start of the label */ ++i0; ++iOrg; /* >>chng 97 july 1, blank out label once finished, to not picked up later */ i = 0; while( i0 < i1 ) { /* make copy of the name */ chLabel[i] = *i0; /* fill original image (OrgCard) with spaces */ *i0 = ' '; /* fill local copy of line in calling routine to spaces */ *iOrg = ' '; /* now increment all pointers, loop until end of file name */ ++i; ++i0; ++iOrg; } /* must terminate the label, i now points beyond valid name */ chLabel[i] = '\0'; # ifdef DEBUG_FUN fputs( " <->GetQuote()\n", debug_fp ); # endif return; }