Beispiel #1
0
static void read_int(int *pc, char ***pv, int *r) {
    enum {X, Y, Z};
    int c;
    char **v;

    c = *pc; v = *pv;

    assert_c(c, "X"); r[X] = eatoi(v[0]); shift(&c, &v);
    assert_c(c, "Y"); r[Y] = eatoi(v[0]); shift(&c, &v);
    assert_c(c, "Z"); r[Z] = eatoi(v[0]); shift(&c, &v);

    *pc = c; *pv = v;
}
Beispiel #2
0
/* Convert ascii to Value according to type of keyword -- omitted bit types */
void atoval(
cwp_String type,	/* type of header keyword		*/
cwp_String keyval,	/* value of header keyword as ascii 	*/
Value *valp	/* pointer to converted value		*/
)
{
	switch(*type) {
	case 's':
		(void) strcpy(valp->s, keyval);
	break;
	case 'h':
		valp->h = eatoh(keyval); 
	break;
	case 'u':
		valp->u = eatou(keyval); 
	break;
	case 'i':
		valp->i = eatoi(keyval); 
	break;
	case 'p':
		valp->p = eatop(keyval); 
	break;
	case 'l':
		valp->l = eatol(keyval); 
	break;
	case 'v':
		valp->v = eatov(keyval); 
	break;
	case 'f':
		valp->f = eatof(keyval); 
	break;
	case 'd':
		valp->d = eatod(keyval); 
	break;
	default:
		suerr("%s: %s: mysterious data type: %s",
					__FILE__, __LINE__, keyval);
	break;
	}

	return;
}
Beispiel #3
0
int getnpar(int n, char *name, char *type, void *ptr)
{
	int i;			/* index of name in symbol table	*/
	int nval;		/* number of parameter values found	*/
	char *aval;		/* ascii field of symbol		*/

	if (xargc == 1) return 0;
	if (!tabled) getparinit();/* Tabulate command line and parfile */
	i = getparindex(n,name);/* Get parameter index */
	if (i < 0) return 0;	/* Not there */
	
	/* 
	 * handle string type as a special case, since a string 
	 * may contain commas.  Therefore, no arrays of strings.
	 */
	if (type[0]=='s') {
		*((char**)ptr) = argtbl[i].asciival;
		return 1;
	}

	/* convert vector of ascii values to numeric values */
	for (nval=0,aval=argtbl[i].asciival; *aval; nval++) {
		switch (type[0]) {
			case 'i':
				*(int*)ptr = eatoi(aval);
				ptr = (int*)ptr+1;
				break;
			case 'p':
				*(unsigned int*)ptr = eatop(aval);
				ptr = (unsigned int*)ptr+1;
				break;
			case 'h':
				*(short*)ptr = eatoh(aval);
				ptr = (short*)ptr+1;
				break;
			case 'u':
				*(unsigned short*)ptr = eatou(aval);
				ptr = (unsigned short*)ptr+1;
				break;
			case 'l':
				*(long*)ptr = eatol(aval);
				ptr = (long*)ptr+1;
				break;
			case 'v':
				*(unsigned long*)ptr = eatov(aval);
				ptr = (unsigned long*)ptr+1;
				break;
			case 'f':
				*(float*)ptr = eatof(aval);
				ptr = (float*)ptr+1;
				break;
			case 'd':
				*(double*)ptr = eatod(aval);
				ptr = (double*)ptr+1;
				break;
			default:
				err("%s: invalid parameter type = %s",
					__FILE__,type);
		}
		while (*aval++ != ',') {
			if (!*aval) break;
		}
	}
	return nval;
}