/* pPair.c was originally generated by the autoSql program, which also * generated pPair.h and pPair.sql. This module links the database and the RAM * representation of objects. */ #include "common.h" #include "jksql.h" #include "pPair.h" void pPairInfoStaticLoad(char **row, struct pPairInfo *ret) /* Load a row from pPairInfo table into ret. The contents of ret will * be replaced at the next call to this function. */ { int sizeOne,i; char *s; ret->fRead = row[0]; ret->rRead = row[1]; ret->clone = row[2]; ret->minSize = sqlSigned(row[3]); ret->maxSize = sqlSigned(row[4]); } struct pPairInfo *pPairInfoLoad(char **row) /* Load a pPairInfo from row fetched with select * from pPairInfo * from database. Dispose of this with pPairInfoFree(). */ { struct pPairInfo *ret; int sizeOne,i; char *s; AllocVar(ret); ret->fRead = cloneString(row[0]); ret->rRead = cloneString(row[1]); ret->clone = cloneString(row[2]); ret->minSize = sqlSigned(row[3]); ret->maxSize = sqlSigned(row[4]); return ret; } struct pPairInfo *pPairInfoCommaIn(char **pS, struct pPairInfo *ret) /* Create a pPairInfo out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new pPairInfo */ { char *s = *pS; int i; if (ret == NULL) AllocVar(ret); ret->fRead = sqlStringComma(&s); ret->rRead = sqlStringComma(&s); ret->clone = sqlStringComma(&s); ret->minSize = sqlSignedComma(&s); ret->maxSize = sqlSignedComma(&s); *pS = s; return ret; } void pPairInfoFree(struct pPairInfo **pEl) /* Free a single dynamically allocated pPairInfo such as created * with pPairInfoLoad(). */ { struct pPairInfo *el; if ((el = *pEl) == NULL) return; freeMem(el->fRead); freeMem(el->rRead); freeMem(el->clone); freez(pEl); } void pPairInfoFreeList(struct pPairInfo **pList) /* Free a list of dynamically allocated pPairInfo's */ { struct pPairInfo *el, *next; for (el = *pList; el != NULL; el = next) { next = el->next; pPairInfoFree(&el); } *pList = NULL; } void pPairInfoOutput(struct pPairInfo *el, FILE *f, char sep, char lastSep) /* Print out pPairInfo. Separate fields with sep. Follow last field with lastSep. */ { int i; if (sep == ',') fputc('"',f); fprintf(f, "%s", el->fRead, sep); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->rRead, sep); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->clone, sep); if (sep == ',') fputc('"',f); fputc(sep,f); fprintf(f, "%d", el->minSize, sep); fputc(sep,f); fprintf(f, "%d", el->maxSize, lastSep); fputc(lastSep,f); }