This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
/
mvctl.c
80 lines (65 loc) · 2.14 KB
/
mvctl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* minivend.c: runs as a command line or cgi program and starts up
MiniVend in various modes
$Id: mvctl.c,v 1.1 1999/11/12 08:46:23 mike Exp $
Copyright 1997 by Mike Heins <mikeh@minivend.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA.
*/
#define PERL "/usr/bin/perl"
#define VendRoot "/home/minivend"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(argc, argv)
int argc;
char** argv;
{
int r;
char minivend[255];
printf("Content-type: text/plain\r\n\r\n");
fflush(stdout);
if(argv[1] == NULL) {
printf("Requires an argument.\n", argv[1]);
exit(0);
}
strcpy(minivend, VendRoot);
if(strcmp(argv[1], "start_unix") == 0) {
printf("Starting in UNIX mode...\n");
strcat(minivend, "/bin/start_unix");
}
else if(strcmp(argv[1], "start_inet") == 0) {
printf("Starting in INET mode...\n");
strcat(minivend, "/bin/start_inet");
}
else if(strcmp(argv[1], "restart_unix") == 0) {
printf("Re-starting in UNIX mode...\n");
strcat(minivend, "/bin/restart_unix");
}
else if(strcmp(argv[1], "restart_inet") == 0) {
printf("Re-starting in INET mode...\n");
strcat(minivend, "/bin/restart_inet");
}
else if(strcmp(argv[1], "stop") == 0) {
printf("Stopping server...\n");
strcat(minivend, "/bin/stop");
}
else {
printf("Unrecognized command %s.\n", argv[1]);
exit(0);
}
execl(PERL, PERL, minivend, 0);
printf("Could not exec %s.", PERL);
exit(1);
}