parseArgs(int index, char * bp)
parseArgs(int index, const char * bp)
parseArgs(int index, char * bp){    const Commands *cp = &commands[index];    int size = strlen(cp->fname);    int i;    CK_ULONG value;    char vname[512];    Value **argList,*possible;    ConstType constType;    /*     * skip pass the command     */    if ((cp->fname[0] == 'C') && (cp->fname[1] == '_') && (bp[1] != '_')) {	size -= 2;    }    bp += size;    /*     * Initialize our argument list     */    argList = (Value **)malloc(sizeof(Value*)*MAX_ARGS);    for (i=0; i < MAX_ARGS; i++) { argList[i] = NULL; }    /*     * Walk the argument list parsing it...     */    for (i=0 ;i < MAX_ARGS; i++) {	ArgType type = cp->args[i] & ArgMask;        /* strip blanks */        bp = strip(bp);	/* if we hit ArgNone, we've nabbed all the arguments we need */	if (type == ArgNone) {		break;	}	/* if we run out of space in the line, we weren't given enough	 * arguments... */	if (*bp == '\0') {	    fprintf(stderr,"%s: only %d args found,\n",cp->fname,i);	    parseFree(argList);	    return NULL;	}	/*	 * look up the argument in our variable list first... only 	 * exception is the new argument type for set...	 */	if ((cp->args[i] != (ArgVar|ArgNew)) && 			(possible = varLookup(bp,vname,sizeof(vname)))) {	   /* ints are only compatible with other ints... all other types	    * are interchangeable... */	   if (type != ArgVar) { /* ArgVar's match anyone */		if ((type == ArgULong) ^ 				((possible->type & ArgMask) == ArgULong)) {		    fprintf(stderr,"%s: Arg %d incompatible type with <%s>\n",				cp->fname,i+1,vname);		    parseFree(argList);		    return NULL;		}		/*		 * ... that is as long as they are big enough...		 */		if (ArgSize(type) > possible->size) {		    fprintf(stderr,	        "%s: Arg %d %s is too small (%d bytes needs to be %d bytes)\n",	    		cp->fname,i+1,vname,possible->size,ArgSize(type));		    parseFree(argList);		    return NULL;		}	   }		   /* everything looks kosher here, use it */		   argList[i] = possible;	   possible->reference++;	   bp = readChars(bp,vname,sizeof(vname));	   if (cp->args[i] & ArgOut) {		possible->type |= ArgOut;	   }	   continue;	}	/* create space for our argument */	argList[i] = NewValue(type, 1);        if ((PL_strncasecmp(bp, "null", 4) == 0)  && ((bp[4] == 0) 		|| (bp[4] == ' ') || (bp[4] =='\t') || (bp[4] =='\n'))) {	    if (cp->args[i] == ArgULong) {		fprintf(stderr, "%s: Arg %d CK_ULONG can't be NULL\n",	    							cp->fname,i+1);		parseFree(argList);		return NULL;	    }	    free(argList[i]->data);	    argList[i]->data = NULL;	    argList[i]->size = 0;	    bp += 4;	    if (*bp) bp++;	    continue;        }	/* if we're an output variable, we need to add it */	if (cp->args[i] & ArgOut) {            if (PL_strncasecmp(bp,"file(",5) == 0) {	        char filename[512];		bp = readChars(bp+5,filename,sizeof(filename));		size = strlen(filename);	    	if ((size > 0) && (filename[size-1] == ')')) {		    filename[size-1] = 0; 		}		filename[size] = 0; 		argList[i]->filename = (char *)malloc(size+1);		strcpy(argList[i]->filename,filename);	    	argList[i]->type |= ArgOut|ArgFile;		break;	    }	    bp = AddVariable(bp,&argList[i]);	    argList[i]->type |= ArgOut;	    continue;	}         if (PL_strncasecmp(bp, "file(", 5) == 0) {	    char filename[512];	    bp = readChars(bp+5,filename,sizeof(filename));	    size = strlen(filename);	    if ((size > 0) && (filename[size-1] == ')')) filename[size-1] = 0; 	    if (restore(filename,argList[i]) != CKR_OK) {		parseFree(argList);		return NULL;	    }	    continue;	}	if (PL_strncasecmp(bp, "size(", 5) == 0) {	    CK_ULONG *ulong = (CK_ULONG *)argList[i]->data;	    char tmpname[512];	    bp = readChars(bp+5,tmpname,sizeof(tmpname));	    size = strlen(tmpname);	    if ((size > 0) && (tmpname[size-1] == ')')) tmpname[size-1] = 0; 	    if (argList[i]->size == sizeof(CK_ULONG) || ulong == NULL) {		fprintf(stderr,			"%s: size used for non-int argument,\n",cp->fname);		parseFree(argList);		return NULL;	    }	    *ulong = 0;   	    varLookup(tmpname, vname,sizeof(vname));	    if (!possible) {		fprintf(stderr,			"%s: %s was not found\n",cp->fname, vname);		parseFree(argList);		return NULL;	    }	    *ulong = possible->arraySize;	    continue;	}	switch (type) {    	case ArgULong:	     bp = constLookup(bp, &value, &constType);	     *(int *)argList[i]->data = value;	     argList[i]->constType = constType;	     break;    	case ArgVar:	     free(argList[i]->data);	     size = getEnd(bp);	     argList[i]->data = (void *)malloc(size);	     argList[i]->size = size;	     /* fall through */    	case ArgInfo:    	case ArgSlotInfo:    	case ArgTokenInfo:    	case ArgSessionInfo:    	case ArgAttribute:    	case ArgMechanism:    	case ArgMechanismInfo:    	case ArgInitializeArgs:	case ArgUTF8:	case ArgChar:	     bp = readChars(bp,(char *)argList[i]->data,argList[i]->size);    	case ArgNone:	default:	     break;	}    }    return argList;}