diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-12 09:42:23 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-12 09:42:23 +0800 |
commit | 9a12adf6d29cdefc98afe2566a9e5479489f111b (patch) | |
tree | 6e2b911398cb6dcb08b183ab645817e098182968 /mbbsd/args.c | |
parent | 3d16ea67c380607528e7c8df0b2cc5a2f2636b9f (diff) | |
download | pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.tar pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.tar.gz pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.tar.bz2 pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.tar.lz pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.tar.xz pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.tar.zst pttbbs-9a12adf6d29cdefc98afe2566a9e5479489f111b.zip |
* extract common functions as library.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3673 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/args.c')
-rw-r--r-- | mbbsd/args.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/mbbsd/args.c b/mbbsd/args.c index 8d6ee98d..8a7658a7 100644 --- a/mbbsd/args.c +++ b/mbbsd/args.c @@ -10,9 +10,10 @@ initsetproctitle(int argc, char **argv, char **envp) #else -char **Argv = NULL; /* pointer to argument vector */ -char *LastArgv = NULL;/* end of argv */ -extern char **environ; +static char **Argv = NULL; /* pointer to argument vector */ +static int arg_size; /* end of argv */ + +extern char **environ; void initsetproctitle(int argc, char **argv, char **envp) @@ -20,6 +21,7 @@ initsetproctitle(int argc, char **argv, char **envp) register int i; int len=0,nenv=0; + /* * Move the environment so setproctitle can use the space at the top of * memory. @@ -40,9 +42,9 @@ initsetproctitle(int argc, char **argv, char **envp) /* Save start and extent of argv for setproctitle. */ Argv = argv; if (i > 0) - LastArgv = envp[i - 1] + strlen(envp[i - 1]); + argv_size = envp[i - 1] + strlen(envp[i - 1]) - Argv[0]; else - LastArgv = argv[argc - 1] + strlen(argv[argc - 1]); + argv_size = argv[argc - 1] + strlen(argv[argc - 1]) - Argv[0]; } static void @@ -51,9 +53,9 @@ do_setproctitle(const char *cmdline) int len; len = strlen(cmdline) + 1; // +1 for '\0' - if(len > LastArgv - Argv[0] - 2) // 2 ?? - len = LastArgv - Argv[0] - 2; - memset(Argv[0], 0, LastArgv-Argv[0]); + if(len > argv_size - 2) // 2 ?? + len = argv_size - 2; + memset(Argv[0], 0, argv_size); strlcpy(Argv[0], cmdline, len); Argv[1] = NULL; } |