Line 101... |
Line 101... |
|
|
if(!strcmp(strtoupper(token), "ENTITY")) {
|
if(!strcmp(strtoupper(token), "ENTITY")) {
|
// Parse an entity line
|
// Parse an entity line
|
token = strtok_r(NULL, " \t", &last);
|
token = strtok_r(NULL, " \t", &last);
|
if(token != NULL) {
|
if(token != NULL) {
|
entityname = (char *) malloc(strlen(token));
|
entityname = strdup(token);
|
if(entityname != NULL) strcpy(entityname, token);
|
if(entityname != NULL)
|
|
{
|
debug("Found entity \'%s\'\n", entityname);
|
debug("Found entity \'%s\'\n", entityname);
|
|
}
|
} else {
|
} else {
|
printf("Parse error near ENTITY token in file %s\n", bsdlfilename);
|
printf("Parse error near ENTITY token in file %s\n", bsdlfilename);
|
}
|
}
|
}
|
}
|
else if(!strcmp(strtoupper(token), "CONSTANT")) {
|
else if(!strcmp(strtoupper(token), "CONSTANT")) {
|
Line 229... |
Line 231... |
|
|
// We're going to copy the entire attribute (all commands) into a temp. buffer. We need a big enough buffer,
|
// We're going to copy the entire attribute (all commands) into a temp. buffer. We need a big enough buffer,
|
// and we can't just scan for ';' to find out because there's a '\0' at the end of this line.
|
// and we can't just scan for ';' to find out because there's a '\0' at the end of this line.
|
// But, it can't be bigger than the entire rest of the file, so...
|
// But, it can't be bigger than the entire rest of the file, so...
|
cmdbuf = (char *) malloc(filesize-filepos);
|
cmdbuf = (char *) malloc(filesize-filepos);
|
|
debug("Malloc'd %i bytes for INSTRUCTION_OPCODE\n", filesize-filepos);
|
|
|
// Parse until ';', and grab everything between each pair of "" found
|
// Parse until ';', and grab everything between each pair of "" found
|
// Note that 'last' still points at "is"
|
// Note that 'last' still points at "is"
|
j = 0;
|
j = 0;
|
done = 0;
|
done = 0;
|
valid = 0;
|
valid = 0;
|
Line 251... |
Line 255... |
else if(*linedata == ';') { done = 1; break;}
|
else if(*linedata == ';') { done = 1; break;}
|
linedata++;
|
linedata++;
|
}
|
}
|
}
|
}
|
cmdbuf[j] = '\0';
|
cmdbuf[j] = '\0';
|
|
debug("Finished copying INSTRUCTION_OPCODE, copied %i bytes", j+1);
|
|
|
// Parse the opcodes attribute. This is an exercise unto itself, so do it in another function.
|
// Parse the opcodes attribute. This is an exercise unto itself, so do it in another function.
|
parse_opcodes(cmdbuf, &debug_cmd, &user1_cmd, &idcode_cmd);
|
parse_opcodes(cmdbuf, &debug_cmd, &user1_cmd, &idcode_cmd);
|
found_cmds = 1;
|
found_cmds = 1;
|
free(cmdbuf);
|
free(cmdbuf);
|