/* ************************************************************************ * file: rebuildMailIndex.c Part of tbaMUD * * Copyright (C) 1990, 2010 - see 'license.doc' for complete information. * * All Rights Reserved * ************************************************************************* */ #include #include #include #include #include #include #define READ_SIZE 256 #define FLAG(n) (1 << (n)) #ifndef FALSE typedef enum _boolean_type { FALSE=0, TRUE } bool; #endif /* 128-bit flag defines (from utils.h) */ #define Q_FIELD(x) ((int) (x) / 32) #define Q_BIT(x) (1 << ((x) % 32)) #define IS_SET_AR(var, bit) ((var)[Q_FIELD(bit)] & Q_BIT(bit)) #define SET_BIT_AR(var, bit) ((var)[Q_FIELD(bit)] |= Q_BIT(bit)) /* 32-bit flag defines (from utils.h) */ #define IS_SET(flag,bit) ((flag) & (bit)) #define SET_BIT(var,bit) ((var) |= (bit)) int atoi(const char *str); long atol(const char *str); /* Mail index flags - taken from mail.h */ #define MINDEX_DELETED FLAG(0) /* Mail has been marked for deletion */ #define MINDEX_URGENT FLAG(1) /* Mail is flagged as urgent by sender */ #define MINDEX_HAS_OBJ FLAG(2) /* Mail has an attached object */ #define MINDEX_HAS_GOLD FLAG(3) /* Mail contains some gold coins */ #define MINDEX_IS_COD FLAG(4) /* Mail requires some gold coins */ #define MINDEX_FROM_MOB FLAG(5) /* Mail has been sent by using scripts */ #define MINDEX_READ FLAG(6) /* Mail has been viewed but not received */ #define MINDEX_DRAFT FLAG(7) /* Mail is an unsent draft copy */ /* Mail Flags - taken from mail.h */ #define MAIL_DELETED 1 /* Marks mail for deletion with next purge */ #define MAIL_URGENT 2 /* This mail is flagged as urgent? */ #define MAIL_COD 3 /* Means coins amount is required payment */ #define MAIL_FROM_MOB 4 /* Specifies that 'sender' is a mob vnum */ #define MAIL_READ 5 /* Mail has been read by recipient */ #define MAIL_DRAFT 6 /* Mail is a draft (not yet sent) */ void walkdir(FILE* index_file, char *dir); int get_line(FILE *fl, char *buf); long asciiflag_conv(char *flag); int sprintascii(char *out, long bits); int main(int argc, char** argv) { FILE *index_file; if ( argc == 1 ) { printf("Usage: %s indexfile\n",argv[0]); return 0; } if (!(index_file = fopen(argv[1], "w"))) { perror("error opening index file"); return 1; } fprintf(index_file, "# tbaMUD mail index\n"); fprintf(index_file, "# Format: