/*------------------------------------------------------------------------- * * common.c-- * common routines between pg_dump and pg4_dump * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.2 1996/07/12 05:39:33 scrappy Exp $ * *------------------------------------------------------------------------- */ #include #include #include /* for MAXHOSTNAMELEN on most */ #ifdef PORTNAME_sparc_solaris #include /* for MAXHOSTNAMELEN on some */ #endif #include "postgres.h" #include "libpq-fe.h" #include "pg_dump.h" /* dupstr : copies a string, while allocating space for it. the CALLER is responsible for freeing the space returns NULL if the argument is NULL*/ char* dupstr(char *s) { char* result; if (s == NULL) return NULL; result = (char*)malloc(strlen(s)+1); strcpy(result, s); return result; } /* * findTypeByOid * given an oid of a type, return its typename * * if oid is "0", return "opaque" -- this is a special case * * NOTE: should hash this, but just do linear search for now */ char* findTypeByOid(TypeInfo* tinfo, int numTypes, char* oid) { int i; if (strcmp(oid, "0") == 0) return g_opaque_type; for (i=0;i 0) { result = (char**)malloc(sizeof(char*) * numParents); j = 0; for (i=0;i= 0; i--) { tblinfo[i].parentRels = findParentsByOid(tblinfo, numTables, inhinfo, numInherits, tblinfo[i].oid, &tblinfo[i].numParents); for (k=0;k 1 && relname[1] == ','); }