I’m using Dynamic C 10.05 to develop an application for RCM4010.
To pharse form input, I wrote code listed below. (Based on some samples came with Dynamic C.)
#define MAX_FORMSIZE 32
#define FORMITEM 5
typedef struct {
char *name;
char value[MAX_FORMSIZE];
} FORMType;
int submit(HttpState* state)
{
FORMType FORMSpec[FORMITEM];
FORMSpec[0].name = "newipaddr";
FORMSpec[1].name = "newmask";
FORMSpec[2].name = "newgate";
FORMSpec[3].name = "newglbip";
FORMSpec[4].name = "newport";
…
…
…
printf("src 0 %x
", (long) FORMSpec[0].name); /*for debugging (1s)
printf("src 1 %x
", (long) FORMSpec[1].name); /*for debugging (2s)
…
…
…
if(parse_post(state, FORMSpec)) {
…
…
…
}
int parse_post(HttpState* state, FORMType* forms)
{
…
…
…
printf("dst 0 %x
", (long)((forms+0)->name)); /*for debugging (1d)
printf("dst 1 %x
", (long)((forms+1)->name)); /*for debugging (2d)
for(i=0; iname, state->buffer, (forms+i)->value, MAX_FORMSIZE);
…
…
…
}
The 1st item of the form is not correctly pharsed. The 2nd and later items are pharsed correctly. So that, I inserted printf statements for debugging.
The results were:
“address printed by printf (2d)” == “address printed by printf (2s)”
“address printed by printf (1d)” != “address printed by printf (1s)”
I guess that starting address of the string “newipaddr” is not passed to the called function correctly.
Is this a known issue? Or, am I misunderstanding?