1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Massive commit to run PGINDENT on all *.c and *.h files.

This commit is contained in:
Bruce Momjian
1997-09-07 05:04:48 +00:00
parent 8fecd4febf
commit 1ccd423235
687 changed files with 150775 additions and 136888 deletions

View File

@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* filename.c--
*
*
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.8 1997/08/12 20:15:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.9 1997/09/07 04:50:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,95 +20,118 @@
#include "postgres.h"
#include <miscadmin.h>
#include "utils/builtins.h" /* where function declarations go */
#include "utils/builtins.h" /* where function declarations go */
char *
char *
filename_in(char *file)
{
char *str;
int ind = 0;
/*
* XXX - HACK CITY --- REDO
* should let the shell do expansions (shexpand)
*/
char *str;
int ind = 0;
str = (char *) palloc(MAXPATHLEN * sizeof(*str));
str[0] = '\0';
if (file[0] == '~') {
if (file[1] == '\0' || file[1] == '/') {
/* Home directory */
char *userName;
struct passwd *pw;
userName = GetPgUserName();
if ((pw = getpwnam(userName)) == NULL) {
elog(WARN, "User %s is not a Unix user on the db server.",
userName);
}
strcpy(str, pw->pw_dir);
ind = 1;
} else {
/* Someone else's directory */
char name[16], *p;
struct passwd *pw;
int len;
if ((p = (char *) strchr(file, '/')) == NULL) {
strcpy(name, file+1);
len = strlen(name);
} else {
len = (p - file) - 1;
strNcpy(name, file+1, len);
}
/*printf("name: %s\n");*/
if ((pw = getpwnam(name)) == NULL) {
elog(WARN, "No such user: %s\n", name);
/*
* XXX - HACK CITY --- REDO should let the shell do expansions
* (shexpand)
*/
str = (char *) palloc(MAXPATHLEN * sizeof(*str));
str[0] = '\0';
if (file[0] == '~')
{
if (file[1] == '\0' || file[1] == '/')
{
/* Home directory */
char *userName;
struct passwd *pw;
userName = GetPgUserName();
if ((pw = getpwnam(userName)) == NULL)
{
elog(WARN, "User %s is not a Unix user on the db server.",
userName);
}
strcpy(str, pw->pw_dir);
ind = 1;
}
else
{
/* Someone else's directory */
char name[16],
*p;
struct passwd *pw;
int len;
if ((p = (char *) strchr(file, '/')) == NULL)
{
strcpy(name, file + 1);
len = strlen(name);
}
else
{
len = (p - file) - 1;
strNcpy(name, file + 1, len);
}
/* printf("name: %s\n"); */
if ((pw = getpwnam(name)) == NULL)
{
elog(WARN, "No such user: %s\n", name);
ind = 0;
}
else
{
strcpy(str, pw->pw_dir);
ind = len + 1;
}
}
}
else if (file[0] == '$')
{ /* $POSTGRESHOME, etc. expand it. */
char environment[80],
*envirp,
*p;
int len;
if ((p = (char *) strchr(file, '/')) == NULL)
{
strcpy(environment, file + 1);
len = strlen(environment);
}
else
{
len = (p - file) - 1;
strNcpy(environment, file + 1, len);
}
envirp = getenv(environment);
if (envirp)
{
strcpy(str, envirp);
ind = len + 1;
}
else
{
elog(WARN, "Couldn't find %s in your environment", environment);
}
}
else
{
ind = 0;
} else {
strcpy(str, pw->pw_dir);
ind = len + 1;
}
}
} else if (file[0] == '$') { /* $POSTGRESHOME, etc. expand it. */
char environment[80], *envirp, *p;
int len;
if ((p = (char *) strchr(file, '/')) == NULL) {
strcpy(environment, file+1);
len = strlen(environment);
} else {
len = (p - file) - 1;
strNcpy(environment, file+1, len);
}
envirp = getenv(environment);
if (envirp) {
strcpy(str, envirp);
ind = len + 1;
}
else {
elog(WARN,"Couldn't find %s in your environment", environment);
}
} else {
ind = 0;
}
strcat(str, file+ind);
return(str);
strcat(str, file + ind);
return (str);
}
char *
char *
filename_out(char *s)
{
char *ret;
if (!s)
return((char *) NULL);
ret = (char *) palloc(strlen(s) + 1);
if (!ret)
elog(WARN, "filename_out: palloc failed");
return(strcpy(ret, s));
char *ret;
if (!s)
return ((char *) NULL);
ret = (char *) palloc(strlen(s) + 1);
if (!ret)
elog(WARN, "filename_out: palloc failed");
return (strcpy(ret, s));
}