summaryrefslogtreecommitdiffstats
path: root/mbbsd/args.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
commit1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch)
treee6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/args.c
parent10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff)
downloadpttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/args.c')
-rw-r--r--mbbsd/args.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/mbbsd/args.c b/mbbsd/args.c
index 9f937723..60e1de32 100644
--- a/mbbsd/args.c
+++ b/mbbsd/args.c
@@ -1,58 +1,68 @@
-/* $Id: args.c,v 1.2 2002/06/04 13:08:33 in2 Exp $ */
+/* $Id: args.c,v 1.3 2002/07/05 17:10:26 in2 Exp $ */
#include "bbs.h"
#ifdef HAVE_SETPROCTITLE
-void initsetproctitle(int argc, char **argv, char **envp) {
+void
+initsetproctitle(int argc, char **argv, char **envp)
+{
}
#else
-char **Argv = NULL; /* pointer to argument vector */
-char *LastArgv = NULL; /* end of argv */
-extern char **environ;
+char **Argv = NULL; /* pointer to argument vector */
+char *LastArgv = NULL;/* end of argv */
+extern char **environ;
-void initsetproctitle(int argc, char **argv, char **envp) {
- register int i;
-
- /* Move the environment so setproctitle can use the space at
- the top of memory. */
- for(i = 0; envp[i]; i++);
+void
+initsetproctitle(int argc, char **argv, char **envp)
+{
+ register int i;
+
+ /*
+ * Move the environment so setproctitle can use the space at the top of
+ * memory.
+ */
+ for (i = 0; envp[i]; i++);
environ = malloc(sizeof(char *) * (i + 1));
- for(i = 0; envp[i]; i++)
+ for (i = 0; envp[i]; i++)
environ[i] = strdup(envp[i]);
environ[i] = NULL;
-
+
/* Save start and extent of argv for setproctitle. */
Argv = argv;
- if(i > 0)
+ if (i > 0)
LastArgv = envp[i - 1] + strlen(envp[i - 1]);
else
LastArgv = argv[argc - 1] + strlen(argv[argc - 1]);
}
-static void do_setproctitle(const char *cmdline) {
- char buf[256], *p;
- int i;
-
+static void
+do_setproctitle(const char *cmdline)
+{
+ char buf[256], *p;
+ int i;
+
strncpy(buf, cmdline, 256);
buf[255] = '\0';
i = strlen(buf);
- if(i > LastArgv - Argv[0] - 2) {
+ if (i > LastArgv - Argv[0] - 2) {
i = LastArgv - Argv[0] - 2;
}
strcpy(Argv[0], buf);
p = &Argv[0][i];
- while(p < LastArgv)
- *p++='\0';
+ while (p < LastArgv)
+ *p++ = '\0';
Argv[1] = NULL;
}
-void setproctitle(const char* format, ...) {
- char buf[256];
- va_list args;
+void
+setproctitle(const char *format,...)
+{
+ char buf[256];
+ va_list args;
va_start(args, format);
- vsprintf(buf, format,args);
+ vsprintf(buf, format, args);
do_setproctitle(buf);
va_end(args);
}