dstsedit.c 3.78 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* DSTSEDIT.C */

/* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */

#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>

#include "dirwrap.h"
#include "sbbs.h"
#include "nopen.h"
#include "sbbsdefs.h"
15
#include "conwrap.h"
16
17
18
19

int 
main(int argc, char **argv)
{
20
	char		ch, str[MAX_PATH+1], path[MAX_PATH + 1]
21
22
23
24
25
26
27
	               ,*lst = "%c) %-25s: %13lu\n"
	               ,*nv = "\nNew value: ", *p;
	int		file;
	stats_t		stats;
	time32_t		t;
	scfg_t		cfg;

28
	memset(&cfg, 0, sizeof(cfg));
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

	if (argc > 1)
		strcpy(path, argv[1]);
	else {
		p=getenv("SBBSCTRL");
		if(p)
			SAFECOPY(path, p);
		else
			getcwd(path, sizeof(path));
	}
	backslash(path);

	sprintf(str, "%sdsts.dab", path);
	if ((file = nopen(str, O_RDONLY)) == -1) {
		printf("Can't open %s\r\n", str);
		exit(1);
	}
	read(file, &t, 4L);
	if (read(file, &stats, sizeof(stats_t)) != sizeof(stats_t)) {
		close(file);
		printf("Error reading %u bytes from %s\r\n", sizeof(stats_t), str);
		exit(1);
	}
	close(file);
	while (1) {
		printf("Synchronet Daily Statistics Editor v1.01\r\n\r\n");
55
		printf("S) %-25s: %13s\n", "Date Stamp (MM/DD/YY)", unixtodstr(&cfg, t, str));
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
		printf(lst, 'L', "Total Logons", stats.logons);
		printf(lst, 'O', "Logons Today", stats.ltoday);
		printf(lst, 'T', "Total Time on", stats.timeon);
		printf(lst, 'I', "Time on Today", stats.ttoday);
		printf(lst, 'U', "Uploaded Files Today", stats.uls);
		printf(lst, 'B', "Uploaded Bytes Today", stats.ulb);
		printf(lst, 'D', "Downloaded Files Today", stats.dls);
		printf(lst, 'W', "Downloaded Bytes Today", stats.dlb);
		printf(lst, 'P', "Posts Today", stats.ptoday);
		printf(lst, 'E', "E-Mails Today", stats.etoday);
		printf(lst, 'F', "Feedback Today", stats.ftoday);
		printf("%c) %-25s: %13u\r\n", 'N', "New Users Today", stats.nusers);

		printf("Q) Quit and save changes\r\n");
		printf("X) Quit and don't save changes\r\n");

		printf("\r\nWhich: ");

		ch = toupper(getch());
		printf("%c\r\n", ch);

		switch (ch) {
		case 'S':
			printf("Date stamp (MM/DD/YY): ");
80
			fgets(str, sizeof(str), stdin);
81
82
83
84
85
			if (str[0])
				t = dstrtounix(&cfg, str);
			break;
		case 'L':
			printf(nv);
86
			fgets(str, sizeof(str), stdin);
87
88
89
90
91
			if (str[0])
				stats.logons = atol(str);
			break;
		case 'O':
			printf(nv);
92
			fgets(str, sizeof(str), stdin);
93
94
95
96
97
			if (str[0])
				stats.ltoday = atol(str);
			break;
		case 'T':
			printf(nv);
98
			fgets(str, sizeof(str), stdin);
99
100
101
102
103
			if (str[0])
				stats.timeon = atol(str);
			break;
		case 'I':
			printf(nv);
104
			fgets(str, sizeof(str), stdin);
105
106
107
108
109
			if (str[0])
				stats.ttoday = atol(str);
			break;
		case 'U':
			printf(nv);
110
			fgets(str, sizeof(str), stdin);
111
112
113
114
115
			if (str[0])
				stats.uls = atol(str);
			break;
		case 'B':
			printf(nv);
116
			fgets(str, sizeof(str), stdin);
117
118
119
120
121
			if (str[0])
				stats.ulb = atol(str);
			break;
		case 'D':
			printf(nv);
122
			fgets(str, sizeof(str), stdin);
123
124
125
126
127
			if (str[0])
				stats.dls = atol(str);
			break;
		case 'W':
			printf(nv);
128
			fgets(str, sizeof(str), stdin);
129
130
131
132
133
			if (str[0])
				stats.dlb = atol(str);
			break;
		case 'P':
			printf(nv);
134
			fgets(str, sizeof(str), stdin);
135
136
137
138
139
			if (str[0])
				stats.ptoday = atol(str);
			break;
		case 'E':
			printf(nv);
140
			fgets(str, sizeof(str), stdin);
141
142
143
144
145
			if (str[0])
				stats.etoday = atol(str);
			break;
		case 'F':
			printf(nv);
146
			fgets(str, sizeof(str), stdin);
147
148
149
150
151
			if (str[0])
				stats.ftoday = atol(str);
			break;
		case 'N':
			printf(nv);
152
			fgets(str, sizeof(str), stdin);
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
			if (str[0])
				stats.nusers = atoi(str);
			break;
		case 'Q':
			sprintf(str, "%sdsts.dab", path);
			if ((file = nopen(str, O_WRONLY)) == -1) {
				printf("Error opening %s\r\n", str);
				exit(1);
			}
			write(file, &t, 4L);
			write(file, &stats, sizeof(stats_t));
			close(file);
		case 'X':
			exit(0);
		default:
			putchar(7);
			break;
		}
	}
}