usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / pptpd / inststr.c
blob1fcb55b069891b0e8cbb0d9562e9ae8805d95717
1 /*
2 * inststr.c
4 * Little function to change the name of a process
6 * Originally from C. S. Ananian's pptpclient
8 * $Id: inststr.c,v 1.2 2004/04/22 10:48:16 quozl Exp $
9 */
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
15 #ifndef HAVE_SETPROCTITLE
16 #include "inststr.h"
17 #include "compat.h"
18 #include <string.h>
20 void inststr(int argc, char **argv, char *src)
22 if (strlen(src) <= strlen(argv[0])) {
23 char *ptr, **pptr;
25 for (ptr = argv[0]; *ptr; *(ptr++) = '\0')
27 strcpy(argv[0], src);
28 for (pptr = argv + 1; *pptr; pptr++)
29 for (ptr = *pptr; *ptr; *(ptr++) = '\0')
31 } else {
32 /* Originally from the source to perl 4.036 (assigning to $0) */
33 char *ptr, *ptr2;
34 int count;
36 ptr = argv[0] + strlen(argv[0]);
37 for (count = 1; count < argc; count++) {
38 if (argv[count] == ptr + 1) {
39 ptr++;
40 ptr += strlen(ptr);
43 count = 0;
44 for (ptr2 = argv[0]; ptr2 <= ptr; ptr2++) {
45 *ptr2 = '\0';
46 count++;
48 strlcpy(argv[0], src, count);
51 #endif /* !HAVE_SETPROCTITLE */