Object *parseCode(FILE *file, Object *parent, char **propertyList) { int brakets; FILE *tmp_out; int c; char *cname = lookupList(propertyList, "cname"); if (cname == NULL) return NULL; DMSG("Found code object\n"); tmp_out = fopen("_lua_tmp.lua", "w"); fprintf(tmp_out, "function %s(id)\n", cname); DMSG("Read code object\n"); for (c = fgetc(file); ; c = fgetc(file)) { if (c == '(') brakets++; if (c == ')') { if (brakets == 0) break; else brakets--; } fputc(c, tmp_out); } fprintf(tmp_out, "\nend\n"); fclose(tmp_out); DMSG("Load code object from file\n"); luaL_dofile(l, "_lua_tmp.lua"); }
void elemSets(char *src, char **dst) { char *buffer; buffer = lookupList(elemList, src); if (buffer != NULL) *dst = buffer; }
void elemSetd(char *src, double *dst) { char *buffer; buffer = lookupList(elemList, src); if (buffer != NULL) *dst = strtod(buffer, NULL); }
int main() { List* head, *end; buildList(head,end); for (int i = 0; i < 10; ++i) { appendList(head,end,2 * i); } List* p = lookupList(head, 6); }
void elemSetp(char *src, Point *dst) { char *buffer; float x1, x2, x3; buffer = lookupList(elemList, src); if (buffer != NULL) { sscanf(buffer, "(%f %f %f)", &x1, &x2, &x3); dst->x = x1; dst->y = x2; dst->z = x3; } }
Object *usertagInit(Object *obj, char **list) { Usertag *utag; char *tagname = lookupList(list, "tagname"); int i; for (i = 0; taglist[i].name != NULL; i++) { if (strcmp(tagname, taglist[i].name) == 0) { obj->type = i; break; } } utag = newUsertag(obj); assert(strcmp(tagname, taglist[obj->type].name) == 0); return (Object *)utag; }