diff options
-rw-r--r-- | util/zerovotelimit.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/util/zerovotelimit.c b/util/zerovotelimit.c new file mode 100644 index 00000000..0405d180 --- /dev/null +++ b/util/zerovotelimit.c @@ -0,0 +1,47 @@ +#include "bbs.h" + +/* Vote limits were added in r2342 which uses previously unused pads. + * This program zero outs those pads. */ + +void transform(boardheader_t *new, boardheader_t *old) +{ + memcpy(new, old, sizeof(boardheader_t)); + new->limit_posts = (unsigned char) 0; + new->limit_logins = (unsigned char) 0; + memset(new->pad, 0, sizeof(new->pad)); + memset(new->pad2, 0, sizeof(new->pad2)); + memset(new->pad3, 0, sizeof(new->pad3)); +} + +int main(void) +{ + int fd, fdw; + boardheader_t new, old; + + printf("You're going to zero out vote limits in your .BRD\n"); + printf("The new file will be named .BRD.trans.tmp\n"); +/* + printf("Press any key to continue\n"); + getchar(); +*/ + + if (chdir(BBSHOME) < 0) { + perror("chdir"); + exit(-1); + } + + if ((fd = open(FN_BOARD, O_RDONLY)) < 0 || + (fdw = open(FN_BOARD".trans.tmp", O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 ) { + perror("open"); + exit(-1); + } + + while (read(fd, &old, sizeof(old)) > 0) { + transform(&new, &old); + write(fdw, &new, sizeof(new)); + } + + close(fd); + close(fdw); + return 0; +} |