e70152e44cc66cc599ff6b699eb8adc07f3e656a kent Sat May 24 21:09:34 2014 -0700 Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment. diff --git src/hg/lib/kgAlias.c src/hg/lib/kgAlias.c index d7601d6..7cb4b73 100644 --- src/hg/lib/kgAlias.c +++ src/hg/lib/kgAlias.c @@ -1,123 +1,126 @@ /* kgAlias.c was originally generated by the autoSql program, which also * generated kgAlias.h and kgAlias.sql. This module links the database and * the RAM representation of objects. */ +/* Copyright (C) 2014 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + #include "common.h" #include "linefile.h" #include "dystring.h" #include "jksql.h" #include "kgAlias.h" void kgAliasStaticLoad(char **row, struct kgAlias *ret) /* Load a row from kgAlias table into ret. The contents of ret will * be replaced at the next call to this function. */ { ret->kgID = row[0]; ret->alias = row[1]; } struct kgAlias *kgAliasLoad(char **row) /* Load a kgAlias from row fetched with select * from kgAlias * from database. Dispose of this with kgAliasFree(). */ { struct kgAlias *ret; AllocVar(ret); ret->kgID = cloneString(row[0]); ret->alias = cloneString(row[1]); return ret; } struct kgAlias *kgAliasLoadAll(char *fileName) /* Load all kgAlias from a whitespace-separated file. * Dispose of this with kgAliasFreeList(). */ { struct kgAlias *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[2]; while (lineFileRow(lf, row)) { el = kgAliasLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct kgAlias *kgAliasLoadAllByChar(char *fileName, char chopper) /* Load all kgAlias from a chopper separated file. * Dispose of this with kgAliasFreeList(). */ { struct kgAlias *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[2]; while (lineFileNextCharRow(lf, chopper, row, ArraySize(row))) { el = kgAliasLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct kgAlias *kgAliasCommaIn(char **pS, struct kgAlias *ret) /* Create a kgAlias out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new kgAlias */ { char *s = *pS; if (ret == NULL) AllocVar(ret); ret->kgID = sqlStringComma(&s); ret->alias = sqlStringComma(&s); *pS = s; return ret; } void kgAliasFree(struct kgAlias **pEl) /* Free a single dynamically allocated kgAlias such as created * with kgAliasLoad(). */ { struct kgAlias *el; if ((el = *pEl) == NULL) return; freeMem(el->kgID); freeMem(el->alias); freez(pEl); } void kgAliasFreeList(struct kgAlias **pList) /* Free a list of dynamically allocated kgAlias's */ { struct kgAlias *el, *next; for (el = *pList; el != NULL; el = next) { next = el->next; kgAliasFree(&el); } *pList = NULL; } void kgAliasOutput(struct kgAlias *el, FILE *f, char sep, char lastSep) /* Print out kgAlias. Separate fields with sep. Follow last field with lastSep. */ { if (sep == ',') fputc('"',f); fprintf(f, "%s", el->kgID); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->alias); if (sep == ',') fputc('"',f); fputc(lastSep,f); } /* -------------------------------- End autoSql Generated Code -------------------------------- */