#include "image.h" char *op_names[] = { "mirror", "gray", "fade", }; char *param_names[] = { "in0", "in1", "out", "dims", "factor", }; int table_lookup(char *table[], int count, char name[]) { } int consume_parameter_values(imageop_t *op, int ndx) { int howmany; switch (ndx) { case 0: // param is in0 howmany = fscanf(stdin, "%s", op->in0); // if (howmany != 1) // Print error message and exit. break; case 1: // param is in1 howmany = fscanf(stdin, "%s", op->in1); // if (howmany != 1) // Print error message and exit. break; // etc... } return(0); } int consume_parameters(imageop_t *op) { /* read a string from stdin into into character array pname; ensure that pname[0] is the { character. If not print pname in an error message and exit */ /* read a string from stdin into into character array pname */ /* while (pname[0] is not the } character and not end-of-file) */ { /* attempt to look up pname in the param_names[] table */ /* if that fails print the invalid pname and exit. */ consume_parameter_values(op, table_index); /* read next string from stdin into into character array pname; */ } return(0); } int parser(imageop_t *op) { /* read a string from stdin into into character array opname; */ /* if (no data is read) // end of file reached */ return(-1); /* attempt to look up opame in the op_names[] table */ /* if look up fails print the invalid opname and exit. */ /* save the table index that was returned in op->opcode. */ consume_parameters(op); return(0); }