summaryrefslogtreecommitdiffstats
path: root/util/broadcast.c
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-09-11 13:46:33 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-09-11 13:46:33 +0800
commit1026132bb200603a9e6ac58c986da6b227673b0c (patch)
treefa827e56a6f53485d612b268cf9de4cdd69f11c0 /util/broadcast.c
parent2e9af237bf876af34b8b53f43d27b5e850f74fa6 (diff)
downloadpttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.tar
pttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.tar.gz
pttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.tar.bz2
pttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.tar.lz
pttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.tar.xz
pttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.tar.zst
pttbbs-1026132bb200603a9e6ac58c986da6b227673b0c.zip
correct counter.
help message. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3410 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/broadcast.c')
-rw-r--r--util/broadcast.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/util/broadcast.c b/util/broadcast.c
index f270cf88..1ccf4675 100644
--- a/util/broadcast.c
+++ b/util/broadcast.c
@@ -4,6 +4,11 @@
extern SHM_t *SHM;
+void print_help(int argc, char *argv[])
+{
+ fprintf(stderr, "Usage: %s [-t sleep_time] [-n users_per_round] [-o broadcast_name] broadcast content\n\n", argv[0]);
+}
+
int main(int argc, char *argv[])
{
int sleep_time = 5;
@@ -16,8 +21,12 @@ int main(int argc, char *argv[])
time_t now;
int *sorted, UTMPnumber; // SHM snapshot
- while ((i = getopt(argc, argv, "t:n:o:")) != -1)
+ while ((i = getopt(argc, argv, "t:n:o:h")) != -1)
switch (i) {
+ case 'h':
+ print_help();
+ return 0;
+ break;
case 't':
sleep_time = atoi(optarg);
break;
@@ -49,10 +58,10 @@ int main(int argc, char *argv[])
now = time(NULL);
- for (i = 0, j = 1; i < UTMPnumber; ++i, ++j) {
+ for (i = 0, j = 0; i < UTMPnumber; ++i, ++j) {
if (j == num_per_loop) {
fprintf(stderr, "%5d/%5d\n", i + 1, UTMPnumber);
- j = 1;
+ j = 0;
now = time(NULL);
sleep(sleep_time);
}