/* sangInsert.c was originally generated by the autoSql program, which also * generated sangInsert.h and sangInsert.sql. This module links the database and the RAM * representation of objects. */ #include "common.h" #include "jksql.h" #include "sangInsert.h" void sangInsertStaticLoad(char **row, struct sangInsert *ret) /* Load a row from sangInsert table into ret. The contents of ret will * be replaced at the next call to this function. */ { int sizeOne,i; char *s; strcpy(ret->id, row[0]); strcpy(ret->name, row[1]); } struct sangInsert *sangInsertLoad(char **row) /* Load a sangInsert from row fetched with select * from sangInsert * from database. Dispose of this with sangInsertFree(). */ { struct sangInsert *ret; int sizeOne,i; char *s; AllocVar(ret); strcpy(ret->id, row[0]); strcpy(ret->name, row[1]); return ret; } struct sangInsert *sangInsertCommaIn(char **pS, struct sangInsert *ret) /* Create a sangInsert out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new sangInsert */ { char *s = *pS; int i; if (ret == NULL) AllocVar(ret); sqlFixedStringComma(&s, ret->id, sizeof(ret->id)); sqlFixedStringComma(&s, ret->name, sizeof(ret->name)); *pS = s; return ret; } void sangInsertFree(struct sangInsert **pEl) /* Free a single dynamically allocated sangInsert such as created * with sangInsertLoad(). */ { struct sangInsert *el; if ((el = *pEl) == NULL) return; freez(pEl); } void sangInsertFreeList(struct sangInsert **pList) /* Free a list of dynamically allocated sangInsert's */ { struct sangInsert *el, *next; for (el = *pList; el != NULL; el = next) { next = el->next; sangInsertFree(&el); } *pList = NULL; } void sangInsertOutput(struct sangInsert *el, FILE *f, char sep, char lastSep) /* Print out sangInsert. Separate fields with sep. Follow last field with lastSep. */ { int i; if (sep == ',') fputc('"',f); fprintf(f, "%s%c", el->id, sep); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s%c", el->name, lastSep); if (sep == ',') fputc('"',f); fputc(lastSep,f); }