summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-02-24 06:49:59 +0000
committerStefan Metzmacher <metze@samba.org>2004-02-24 06:49:59 +0000
commit2027b1922b01d3b6af17d24ae51d33cc7048d27d (patch)
tree9a67d0c513d5ea77217bbea21f1a4e005e03f7cd /source4/lib
parent8105eb67881140da072bc7f5ad760e1569a56859 (diff)
downloadsamba-2027b1922b01d3b6af17d24ae51d33cc7048d27d.tar.gz
samba-2027b1922b01d3b6af17d24ae51d33cc7048d27d.tar.bz2
samba-2027b1922b01d3b6af17d24ae51d33cc7048d27d.zip
let the popt replacement stuff survive a make proto
metze (This used to be commit 0f1c6dd631c7a1d4be333b8e3e4ce9850752d5c2)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/popt/findme.c3
-rw-r--r--source4/lib/popt/popt.c54
-rw-r--r--source4/lib/popt/poptconfig.c10
-rw-r--r--source4/lib/popt/popthelp.c33
-rw-r--r--source4/lib/popt/poptparse.c4
5 files changed, 67 insertions, 37 deletions
diff --git a/source4/lib/popt/findme.c b/source4/lib/popt/findme.c
index f2ad05bb3f..67a535ac65 100644
--- a/source4/lib/popt/findme.c
+++ b/source4/lib/popt/findme.c
@@ -5,7 +5,8 @@
#include "system.h"
#include "findme.h"
-const char * findProgramPath(const char * argv0) {
+ const char * findProgramPath(const char * argv0)
+{
char * path = getenv("PATH");
char * pathbuf;
char * start, * chptr;
diff --git a/source4/lib/popt/popt.c b/source4/lib/popt/popt.c
index 9fa8650312..2aa80a7b7c 100644
--- a/source4/lib/popt/popt.c
+++ b/source4/lib/popt/popt.c
@@ -18,14 +18,16 @@ static char * strerror(int errno) {
}
#endif
-void poptSetExecPath(poptContext con, const char * path, int allowAbsolute) {
+ void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
+{
if (con->execPath) xfree(con->execPath);
con->execPath = xstrdup(path);
con->execAbsolute = allowAbsolute;
}
static void invokeCallbacks(poptContext con, const struct poptOption * table,
- int post) {
+ int post)
+{
const struct poptOption * opt = table;
poptCallbackType cb;
@@ -43,8 +45,9 @@ static void invokeCallbacks(poptContext con, const struct poptOption * table,
}
}
-poptContext poptGetContext(const char * name, int argc, const char ** argv,
- const struct poptOption * options, int flags) {
+ poptContext poptGetContext(const char * name, int argc, const char ** argv,
+ const struct poptOption * options, int flags)
+{
poptContext con = malloc(sizeof(*con));
memset(con, 0, sizeof(*con));
@@ -96,7 +99,8 @@ static void cleanOSE(struct optionStackEntry *os)
}
}
-void poptResetContext(poptContext con) {
+void poptResetContext(poptContext con)
+{
int i;
while (con->os > con->optionStack) {
@@ -132,7 +136,8 @@ void poptResetContext(poptContext con) {
}
/* Only one of longName, shortName may be set at a time */
-static int handleExec(poptContext con, char * longName, char shortName) {
+static int handleExec(poptContext con, char * longName, char shortName)
+{
int i;
i = con->numExecs - 1;
@@ -176,7 +181,8 @@ static int handleExec(poptContext con, char * longName, char shortName) {
/* Only one of longName, shortName may be set at a time */
static int handleAlias(poptContext con, const char * longName, char shortName,
- /*@keep@*/ const char * nextCharArg) {
+ /*@keep@*/ const char * nextCharArg)
+{
int i;
if (con->os->currAlias && con->os->currAlias->longName && longName &&
@@ -216,7 +222,8 @@ static int handleAlias(poptContext con, const char * longName, char shortName,
return 1;
}
-static void execCommand(poptContext con) {
+static void execCommand(poptContext con)
+{
const char ** argv;
int pos = 0;
const char * script = con->doExec->script;
@@ -616,23 +623,27 @@ int poptGetNextOpt(poptContext con)
return opt->val;
}
-const char * poptGetOptArg(poptContext con) {
+ const char * poptGetOptArg(poptContext con)
+{
const char * ret = con->os->nextArg;
con->os->nextArg = NULL;
return ret;
}
-const char * poptGetArg(poptContext con) {
+ const char * poptGetArg(poptContext con)
+{
if (con->numLeftovers == con->nextLeftover) return NULL;
return con->leftovers[con->nextLeftover++];
}
-const char * poptPeekArg(poptContext con) {
+ const char * poptPeekArg(poptContext con)
+{
if (con->numLeftovers == con->nextLeftover) return NULL;
return con->leftovers[con->nextLeftover];
}
-const char ** poptGetArgs(poptContext con) {
+ const char ** poptGetArgs(poptContext con)
+{
if (con->numLeftovers == con->nextLeftover) return NULL;
/* some apps like [like RPM ;-) ] need this NULL terminated */
@@ -641,7 +652,8 @@ const char ** poptGetArgs(poptContext con) {
return (con->leftovers + con->nextLeftover);
}
-void poptFreeContext(poptContext con) {
+ void poptFreeContext(poptContext con)
+{
int i;
poptResetContext(con);
@@ -669,7 +681,7 @@ void poptFreeContext(poptContext con) {
free(con);
}
-int poptAddAlias(poptContext con, struct poptAlias newAlias,
+ int poptAddAlias(poptContext con, struct poptAlias newAlias,
/*@unused@*/ int flags)
{
int aliasNum = con->numAliases++;
@@ -693,7 +705,8 @@ int poptAddAlias(poptContext con, struct poptAlias newAlias,
return 0;
}
-const char * poptBadOption(poptContext con, int flags) {
+ const char * poptBadOption(poptContext con, int flags)
+{
struct optionStackEntry * os;
if (flags & POPT_BADOPTION_NOALIAS)
@@ -710,7 +723,8 @@ const char * poptBadOption(poptContext con, int flags) {
#define POPT_ERROR_BADQUOTE -15 /* only from poptParseArgString() */
#define POPT_ERROR_ERRNO -16 /* only from poptParseArgString() */
-const char *poptStrerror(const int error) {
+ const char *poptStrerror(const int error)
+{
switch (error) {
case POPT_ERROR_NOARG:
return POPT_("missing argument");
@@ -731,7 +745,8 @@ const char *poptStrerror(const int error) {
}
}
-int poptStuffArgs(poptContext con, const char ** argv) {
+ int poptStuffArgs(poptContext con, const char ** argv)
+{
int argc;
if ((con->os - con->optionStack) == POPT_OPTION_DEPTH)
@@ -752,11 +767,12 @@ int poptStuffArgs(poptContext con, const char ** argv) {
return 0;
}
-const char * poptGetInvocationName(poptContext con) {
+ const char * poptGetInvocationName(poptContext con)
+{
return con->os->argv[0];
}
-int poptStrippedArgv(poptContext con, int argc, char **argv)
+ int poptStrippedArgv(poptContext con, int argc, char **argv)
{
int i,j=1, numargs=argc;
diff --git a/source4/lib/popt/poptconfig.c b/source4/lib/popt/poptconfig.c
index eb76941363..113270a569 100644
--- a/source4/lib/popt/poptconfig.c
+++ b/source4/lib/popt/poptconfig.c
@@ -5,7 +5,8 @@
#include "system.h"
#include "poptint.h"
-static void configLine(poptContext con, char * line) {
+static void configLine(poptContext con, char * line)
+{
int nameLength = strlen(con->appName);
char * opt;
struct poptAlias alias;
@@ -54,7 +55,8 @@ static void configLine(poptContext con, char * line) {
}
}
-int poptReadConfigFile(poptContext con, const char * fn) {
+ int poptReadConfigFile(poptContext con, const char * fn)
+{
char * file=NULL, * chptr, * end;
char * buf=NULL, * dst;
int fd, rc;
@@ -118,7 +120,8 @@ int poptReadConfigFile(poptContext con, const char * fn) {
return 0;
}
-int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) {
+ int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
+{
char * fn, * home;
int rc;
@@ -139,4 +142,3 @@ int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv) {
return 0;
}
-
diff --git a/source4/lib/popt/popthelp.c b/source4/lib/popt/popthelp.c
index 6b790a63e7..562995c011 100644
--- a/source4/lib/popt/popthelp.c
+++ b/source4/lib/popt/popthelp.c
@@ -10,7 +10,8 @@
static void displayArgs(poptContext con,
/*@unused@*/ enum poptCallbackReason foo,
struct poptOption * key,
- /*@unused@*/ const char * arg, /*@unused@*/ void * data) {
+ /*@unused@*/ const char * arg, /*@unused@*/ void * data)
+{
if (key->shortName== '?')
poptPrintHelp(con, stdout, 0);
else
@@ -55,7 +56,8 @@ getArgDescrip(const struct poptOption * opt, const char *translation_domain)
static void singleOptionHelp(FILE * f, int maxLeftCol,
const struct poptOption * opt,
- const char *translation_domain) {
+ const char *translation_domain)
+{
int indentLength = maxLeftCol + 5;
int lineLength = 79 - indentLength;
const char * help = D_(translation_domain, opt->descrip);
@@ -109,7 +111,8 @@ out:
}
static int maxArgWidth(const struct poptOption * opt,
- const char * translation_domain) {
+ const char * translation_domain)
+{
int max = 0;
int this;
const char * s;
@@ -139,7 +142,8 @@ static int maxArgWidth(const struct poptOption * opt,
static void singleTableHelp(FILE * f, const struct poptOption * table,
int left,
- const char *translation_domain) {
+ const char *translation_domain)
+{
const struct poptOption * opt;
const char *sub_transdom;
@@ -167,7 +171,8 @@ static void singleTableHelp(FILE * f, const struct poptOption * table,
}
}
-static int showHelpIntro(poptContext con, FILE * f) {
+static int showHelpIntro(poptContext con, FILE * f)
+{
int len = 6;
const char * fn;
@@ -182,7 +187,8 @@ static int showHelpIntro(poptContext con, FILE * f) {
return len;
}
-void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags) {
+ void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags)
+{
int leftColWidth;
showHelpIntro(con, f);
@@ -197,7 +203,8 @@ void poptPrintHelp(poptContext con, FILE * f, /*@unused@*/ int flags) {
static int singleOptionUsage(FILE * f, int cursor,
const struct poptOption * opt,
- const char *translation_domain) {
+ const char *translation_domain)
+{
int len = 3;
char shortStr[2] = { '\0', '\0' };
const char * item = shortStr;
@@ -232,7 +239,8 @@ static int singleOptionUsage(FILE * f, int cursor,
}
static int singleTableUsage(FILE * f, int cursor, const struct poptOption * table,
- const char *translation_domain) {
+ const char *translation_domain)
+{
const struct poptOption * opt;
opt = table;
@@ -253,7 +261,8 @@ static int singleTableUsage(FILE * f, int cursor, const struct poptOption * tabl
}
static int showShortOptions(const struct poptOption * opt, FILE * f,
- char * str) {
+ char * str)
+{
char s[300]; /* this is larger then the ascii set, so
it should do just fine */
@@ -279,7 +288,8 @@ static int showShortOptions(const struct poptOption * opt, FILE * f,
return strlen(s) + 4;
}
-void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags) {
+ void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags)
+{
int cursor;
cursor = showHelpIntro(con, f);
@@ -295,7 +305,8 @@ void poptPrintUsage(poptContext con, FILE * f, /*@unused@*/ int flags) {
fprintf(f, "\n");
}
-void poptSetOtherOptionHelp(poptContext con, const char * text) {
+ void poptSetOtherOptionHelp(poptContext con, const char * text)
+{
if (con->otherHelp) xfree(con->otherHelp);
con->otherHelp = xstrdup(text);
}
diff --git a/source4/lib/popt/poptparse.c b/source4/lib/popt/poptparse.c
index 8f00769be9..93bf7acfb8 100644
--- a/source4/lib/popt/poptparse.c
+++ b/source4/lib/popt/poptparse.c
@@ -6,7 +6,7 @@
#define POPT_ARGV_ARRAY_GROW_DELTA 5
-int poptDupArgv(int argc, const char **argv,
+ int poptDupArgv(int argc, const char **argv,
int * argcPtr, const char *** argvPtr)
{
size_t nb = (argc + 1) * sizeof(*argv);
@@ -35,7 +35,7 @@ int poptDupArgv(int argc, const char **argv,
return 0;
}
-int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
+ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
{
const char * src;
char quote = '\0';