/ circle3.1 / src / mail.h
mail.h
  1  /* ************************************************************************
  2  *   File: mail.h                                        Part of CircleMUD *
  3  *  Usage: header file for mail system                                     *
  4  *                                                                         *
  5  *  All rights reserved.  See license.doc for complete information.        *
  6  *                                                                         *
  7  *  Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
  8  *  CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.               *
  9  ************************************************************************ */
 10  
 11  /******* MUD MAIL SYSTEM HEADER FILE **********************
 12   ***     written by Jeremy Elson (jelson@circlemud.org) ***
 13   *********************************************************/
 14  
 15  /* INSTALLATION INSTRUCTIONS in MAIL.C */
 16  
 17  /* You can modify the following constants to fit your own MUD.  */
 18  
 19  /* minimum level a player must be to send mail	*/
 20  #define MIN_MAIL_LEVEL 2
 21  
 22  /* # of gold coins required to send mail	*/
 23  #define STAMP_PRICE 150
 24  
 25  /* Maximum size of mail in bytes (arbitrary)	*/
 26  #define MAX_MAIL_SIZE 4096
 27  
 28  /* size of mail file allocation blocks		*/
 29  #define BLOCK_SIZE 100
 30  
 31  /*
 32   * NOTE:  Make sure that your block size is big enough -- if not,
 33   * HEADER_BLOCK_DATASIZE will end up negative.  This is a bad thing.
 34   * Check the define below to make sure it is >0 when choosing values
 35   * for NAME_SIZE and BLOCK_SIZE.  100 is a nice round number for
 36   * BLOCK_SIZE and is the default ... why bother trying to change it
 37   * anyway?
 38   *
 39   * The mail system will always allocate disk space in chunks of size
 40   * BLOCK_SIZE.
 41   */
 42  
 43  /* USER CHANGABLE DEFINES ABOVE **
 44  ***************************************************************************
 45  **   DON'T TOUCH DEFINES BELOW  */
 46  
 47  int	scan_file(void);
 48  int	has_mail(long recipient);
 49  void	store_mail(long to, long from, char *message_pointer);
 50  char	*read_delete(long recipient);
 51  
 52  
 53  #define HEADER_BLOCK  (-1)
 54  #define LAST_BLOCK    (-2)
 55  #define DELETED_BLOCK (-3)
 56  
 57  /*
 58   * note: next_block is part of header_blk in a data block; we can't combine
 59   * them here because we have to be able to differentiate a data block from a
 60   * header block when booting mail system.
 61   */
 62  
 63  struct header_data_type {
 64     long	next_block;		/* if header block, link to next block	*/
 65     long from;			/* idnum of the mail's sender		*/
 66     long to;			/* idnum of mail's recipient		*/
 67     time_t mail_time;		/* when was the letter mailed?		*/
 68  };
 69  
 70  /* size of the data part of a header block */
 71  #define HEADER_BLOCK_DATASIZE \
 72  	(BLOCK_SIZE - sizeof(long) - sizeof(struct header_data_type) - sizeof(char))
 73  
 74  /* size of the data part of a data block */
 75  #define DATA_BLOCK_DATASIZE (BLOCK_SIZE - sizeof(long) - sizeof(char))
 76  
 77  /* note that an extra space is allowed in all string fields for the
 78     terminating null character.  */
 79  
 80  struct header_block_type_d {
 81     long	block_type;		/* is this a header or data block?	*/
 82     struct header_data_type header_data;	/* other header data		*/
 83     char	txt[HEADER_BLOCK_DATASIZE+1]; /* actual text plus 1 for null	*/
 84  };
 85  
 86  struct data_block_type_d {
 87     long	block_type;		/* -1 if header block, -2 if last data block
 88        				   in mail, otherwise a link to the next */
 89     char	txt[DATA_BLOCK_DATASIZE+1]; /* actual text plus 1 for null	*/
 90  };
 91  
 92  typedef struct header_block_type_d header_block_type;
 93  typedef struct data_block_type_d data_block_type;
 94  
 95  struct position_list_type_d {
 96     long	position;
 97     struct position_list_type_d *next;
 98  };
 99  
100  typedef struct position_list_type_d position_list_type;
101  
102  struct mail_index_type_d {
103     long recipient;			/* who is this mail for?	*/
104     position_list_type *list_start;	/* list of mail positions	*/
105     struct mail_index_type_d *next;	/* link to next one		*/
106  };
107  
108  typedef struct mail_index_type_d mail_index_type;