summaryrefslogtreecommitdiffstats
path: root/util/openvice.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /util/openvice.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/openvice.c')
-rw-r--r--util/openvice.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/util/openvice.c b/util/openvice.c
new file mode 100644
index 00000000..9b5e438f
--- /dev/null
+++ b/util/openvice.c
@@ -0,0 +1,54 @@
+/* $Id: openvice.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */
+/* 發票開獎小程式 */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "config.h"
+#include "pttstruct.h"
+#include "util.h"
+
+#define VICE_SHOW BBSHOME "/etc/vice.show1"
+#define VICE_BINGO BBSHOME "/etc/vice.bingo"
+#define VICE_NEW "vice.new"
+#define VICE_DATA "vice.data"
+#define MAX_BINGO 99999999
+
+int main()
+{
+ char TABLE[5][3] =
+ {"一", "二", "三", "四", "五"};
+
+ int i = 0, bingo, base = 0;
+
+
+ FILE *fp = fopen(VICE_SHOW, "w"), *fb = fopen(VICE_BINGO, "w");
+
+ extern struct utmpfile_t *utmpshm;
+ resolve_utmp();
+
+ srand(utmpshm->number);
+
+ if (!fp || !fb )
+ perror("error open file");
+
+
+ bingo = rand() % MAX_BINGO;
+ fprintf(fp, "%1c統一發票中獎號碼\n", ' ');
+ fprintf(fp, "%1c================\n", ' ');
+ fprintf(fp, "%1c特別獎: %08d\n\n", ' ', bingo);
+ fprintf(fb, "%d\n", bingo);
+
+ while (i < 5)
+ {
+ bingo = (base + rand()) % MAX_BINGO;
+ fprintf(fp, "%1c第%s獎: %08d\n", ' ', TABLE[i], bingo);
+ fprintf(fb, "%08d\n", bingo);
+ i++;
+ }
+ fclose(fp);
+ fclose(fb);
+ return 0;
+}