diff options
| author | Bruce Momjian | 1997-08-19 21:40:56 +0000 |
|---|---|---|
| committer | Bruce Momjian | 1997-08-19 21:40:56 +0000 |
| commit | 1d8bbfd2e7cfb72cbe4d5c5d4fa650a28dedac0b (patch) | |
| tree | 8d3a5dac9207f22c3afb8afb563d54f88774deb3 /src/bin | |
| parent | b992e200b8872ecb6652ec85111995f8d4c5aee0 (diff) | |
Make functions static where possible, enclose unused functions in #ifdef NOT_USED.
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/pg_dump/common.c | 19 | ||||
| -rw-r--r-- | src/bin/pg_dump/pg_dump.c | 23 | ||||
| -rw-r--r-- | src/bin/pg_dump/pg_dump.h | 20 | ||||
| -rw-r--r-- | src/bin/psql/psql.c | 34 | ||||
| -rw-r--r-- | src/bin/psql/stringutils.c | 11 | ||||
| -rw-r--r-- | src/bin/psql/stringutils.h | 4 |
6 files changed, 56 insertions, 55 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1fdd8486720..15729fe7b3a 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.12 1997/06/02 02:51:49 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.13 1997/08/19 21:36:25 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -35,6 +35,15 @@ #include "pg_dump.h" +static char** findParentsByOid(TableInfo* tbinfo, int numTables, + InhInfo* inhinfo, int numInherits, + const char *oid, + int *numParents); +static int findTableByOid(TableInfo *tbinfo, int numTables, const char *oid); +static void flagInhAttrs(TableInfo* tbinfo, int numTables, + InhInfo* inhinfo, int numInherits); +static int strInArray(const char* pattern, char** arr, int arr_size); + /* * findTypeByOid * given an oid of a type, return its typename @@ -95,7 +104,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid) * returns NULL if none */ -char** +static char** findParentsByOid(TableInfo* tblinfo, int numTables, InhInfo* inhinfo, int numInherits, const char *oid, int *numParentsPtr) @@ -173,7 +182,7 @@ parseArgTypes(char **argtypes, const char* str) * */ -int +static int strInArray(const char* pattern, char** arr, int arr_size) { int i; @@ -316,7 +325,7 @@ dumpSchemaIdx(FILE *fout, int *numTablesPtr, const char *tablename, * modifies tblinfo * */ -void +static void flagInhAttrs(TableInfo* tblinfo, int numTables, InhInfo* inhinfo, int numInherits) { @@ -373,7 +382,7 @@ findTableByName(TableInfo* tblinfo, int numTables, const char* relname) * NOTE: should hash this, but just do linear search for now */ -int +static int findTableByOid(TableInfo* tblinfo, int numTables, const char* oid) { int i; diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index efd411d20d8..6c32da2e717 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.37 1997/08/19 04:44:38 vadim Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.38 1997/08/19 21:36:40 momjian Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -68,6 +68,13 @@ #include "pg_dump.h" static void dumpSequence (FILE* fout, TableInfo tbinfo); +static char *checkForQuote(const char* s); +static void clearTableInfo(TableInfo*, int); +static void dumpOneFunc(FILE* fout, FuncInfo* finfo, int i, + TypeInfo *tinfo, int numTypes); +static int findLastBuiltinOid(void); +static bool isViewRule(char *relname); +static void setMaxOid(FILE *fout); extern char *optarg; extern int optind, opterr; @@ -139,7 +146,7 @@ exit_nicely(PGconn* conn) * Determine if the relation is a VIEW * */ -bool +static bool isViewRule(char *relname) { PGresult *res; @@ -776,7 +783,7 @@ clearFuncInfo (FuncInfo *fun, int numFuncs) free(fun); } -void +static void clearTableInfo(TableInfo *tblinfo, int numTables) { int i,j; @@ -1482,7 +1489,7 @@ dumpFuncs(FILE* fout, FuncInfo* finfo, int numFuncs, * */ -void +static void dumpOneFunc(FILE* fout, FuncInfo* finfo, int i, TypeInfo *tinfo, int numTypes) { @@ -1956,6 +1963,7 @@ dumpIndices(FILE* fout, IndInfo* indinfo, int numIndices, * the attrmap passed in tells how to map the attributes copied in to the * attributes copied out */ +#ifdef NOT_USED void dumpTuples(PGresult *res, FILE *fout, int* attrmap) { @@ -1998,13 +2006,14 @@ dumpTuples(PGresult *res, FILE *fout, int* attrmap) free (outVals); } } +#endif /* * setMaxOid - * find the maximum oid and generate a COPY statement to set it */ -void +static void setMaxOid(FILE *fout) { PGresult *res; @@ -2053,7 +2062,7 @@ setMaxOid(FILE *fout) * this is probably not foolproof but comes close */ -int +static int findLastBuiltinOid(void) { PGresult* res; @@ -2083,7 +2092,7 @@ findLastBuiltinOid(void) * checkForQuote: * checks a string for quote characters and quotes them */ -char* +static char* checkForQuote(const char* s) { char *r; diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index a8df2db03ea..a537a3ff6ba 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_dump.h,v 1.18 1997/08/19 04:44:40 vadim Exp $ + * $Id: pg_dump.h,v 1.19 1997/08/19 21:36:45 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -167,20 +167,11 @@ extern void dumpSchemaIdx(FILE* fout, extern char* findTypeByOid(TypeInfo* tinfo, int numTypes, const char* oid); extern char* findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid); extern int findFuncByName(FuncInfo* finfo, int numFuncs, const char* name); -extern char** findParentsByOid(TableInfo* tbinfo, int numTables, - InhInfo* inhinfo, int numInherits, - const char *oid, - int *numParents); extern int findTableByName(TableInfo *tbinfo, int numTables, const char *relname); -extern int findTableByOid(TableInfo *tbinfo, int numTables, const char *oid); -extern void flagInhAttrs(TableInfo* tbinfo, int numTables, - InhInfo* inhinfo, int numInherits); extern void check_conn_and_db(void); -extern int strInArray(const char* pattern, char** arr, int arr_size); extern void parseArgTypes(char **argtypes, const char* str); extern int isArchiveName(const char*); -extern bool isViewRule(char *relname); /* * version specific routines @@ -195,7 +186,6 @@ extern void clearInhInfo(InhInfo*, int); extern void clearIndInfo(IndInfo*, int); extern void clearOprInfo(OprInfo*, int); extern void clearTypeInfo(TypeInfo*, int); -extern void clearTableInfo(TableInfo*, int); extern OprInfo* getOperators(int *numOperators); extern TableInfo* getTables(int *numTables); @@ -210,8 +200,6 @@ extern void dumpAggs(FILE* fout, AggInfo* agginfo, int numAggregates, TypeInfo *tinfo, int numTypes); extern void dumpOprs(FILE* fout, OprInfo* agginfo, int numOperators, TypeInfo *tinfo, int numTypes); -extern void dumpOneFunc(FILE* fout, FuncInfo* finfo, int i, - TypeInfo *tinfo, int numTypes); extern void dumpTables(FILE* fout, TableInfo* tbinfo, int numTables, InhInfo *inhinfo, int numInherits, TypeInfo *tinfo, int numTypes, const char *tablename, @@ -219,12 +207,6 @@ extern void dumpTables(FILE* fout, TableInfo* tbinfo, int numTables, extern void dumpIndices(FILE* fout, IndInfo* indinfo, int numIndices, TableInfo* tbinfo, int numTables, const char *tablename); -extern void dumpTuples(PGresult *res, FILE *fout, int *attrmap); -extern void setMaxOid(FILE *fout); -extern char* checkForQuote(const char* s); -extern int findLastBuiltinOid(void); - - /* largest query string size */ #define MAXQUERYLEN 5000 diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index b8947606be5..f7d0245091a 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.83 1997/08/19 04:45:02 vadim Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.84 1997/08/19 21:36:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,18 +88,18 @@ static void prompt_for_password(char *username, char *password); static char * make_connect_string(char *host, char *port, char *dbname, char *username, char *password); -char *gets_noreadline(char *prompt, FILE * source); -char *gets_readline(char *prompt, FILE * source); -char *gets_fromFile(char *prompt, FILE * source); -int listAllDbs(PsqlSettings * settings); -void +static char *gets_noreadline(char *prompt, FILE * source); +static char *gets_readline(char *prompt, FILE * source); +static char *gets_fromFile(char *prompt, FILE * source); +static int listAllDbs(PsqlSettings * settings); +static void SendQuery(bool * success_p, PsqlSettings * settings, const char *query, const bool copy_in, const bool copy_out, FILE * copystream); -int +static int HandleSlashCmds(PsqlSettings * settings, char *line, char *query); -int MainLoop(PsqlSettings * settings, FILE * source); +static int MainLoop(PsqlSettings * settings, FILE * source); /* probably should move this into libpq */ void PQprint(FILE * fp, @@ -107,7 +107,7 @@ PQprint(FILE * fp, PQprintOpt * po ); -FILE *setFout(PsqlSettings * ps, char *fname); +static FILE *setFout(PsqlSettings * ps, char *fname); /* * usage print out usage for command line arguments @@ -226,7 +226,7 @@ PSQLexec(PsqlSettings * ps, char *query) * */ -int +static int listAllDbs(PsqlSettings * ps) { PGresult *results; @@ -495,7 +495,7 @@ typedef char *(*READ_ROUTINE) (char *prompt, FILE * source); * gets_noreadline prompt source gets a line of input without calling * readline, the source is ignored */ -char * +static char * gets_noreadline(char *prompt, FILE * source) { fputs(prompt, stdout); @@ -507,7 +507,7 @@ gets_noreadline(char *prompt, FILE * source) * gets_readline prompt source the routine to get input from GNU readline(), * the source is ignored the prompt argument is used as the prompting string */ -char * +static char * gets_readline(char *prompt, FILE * source) { char *s; @@ -529,7 +529,7 @@ gets_readline(char *prompt, FILE * source) * the routine to read from a file, the prompt argument is ignored the source * argument is a FILE * */ -char * +static char * gets_fromFile(char *prompt, FILE * source) { char *line; @@ -557,7 +557,7 @@ gets_fromFile(char *prompt, FILE * source) * SendQuery: send the query string to the backend return *success_p = 1 if * the query executed successfully returns *success_p = 0 otherwise */ -void +static void SendQuery(bool * success_p, PsqlSettings * settings, const char *query, const bool copy_in, const bool copy_out, FILE * copystream) { @@ -1120,7 +1120,7 @@ do_shell(const char *command) * this line, continue building up query 2 - terminate processing of this * query entirely, 3 - new query supplied by edit */ -int +static int HandleSlashCmds(PsqlSettings * settings, char *line, char *query) @@ -1416,7 +1416,7 @@ HandleSlashCmds(PsqlSettings * settings, * db_ptr must be initialized and set */ -int +static int MainLoop(PsqlSettings * settings, FILE * source) { char *line; /* line of input */ @@ -1901,7 +1901,7 @@ handleCopyIn(PGresult * res, const bool mustprompt, FILE * copystream) * try to open fname and return a FILE *, if it fails, use stdout, instead */ -FILE * +static FILE * setFout(PsqlSettings * ps, char *fname) { if (ps->queryFout && ps->queryFout != stdout) { diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c index 4f7a510784a..6237aa5e301 100644 --- a/src/bin/psql/stringutils.c +++ b/src/bin/psql/stringutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.8 1997/02/13 08:31:57 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.9 1997/08/19 21:36:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,8 +28,8 @@ and both sides of a string */ /* MODIFIES the string passed in and returns the head of it */ - -char *leftTrim(char *s) +#ifdef NOT_USED +static char *leftTrim(char *s) { char *s2 = s; int shift=0; @@ -45,6 +45,7 @@ char *leftTrim(char *s) return s2; } +#endif char *rightTrim(char *s) { @@ -59,11 +60,13 @@ char *rightTrim(char *s) return s; } -char *doubleTrim(char *s) +#ifdef NOT_USED +static char *doubleTrim(char *s) { strcpy(s,leftTrim(rightTrim(s))); return s; } +#endif #ifdef STRINGUTILS_TEST void testStringUtils() diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h index 11da94449ea..c6f037ec716 100644 --- a/src/bin/psql/stringutils.h +++ b/src/bin/psql/stringutils.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: stringutils.h,v 1.3 1996/11/26 03:20:08 bryanh Exp $ + * $Id: stringutils.h,v 1.4 1997/08/19 21:36:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,9 +27,7 @@ /* removes whitespaces from the left, right and both sides of a string */ /* MODIFIES the string passed in and returns the head of it */ -extern char *leftTrim(char *s); extern char *rightTrim(char *s); -extern char *doubleTrim(char *s); #ifdef STRINGUTILS_TEST extern void testStringUtils(); |
