home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / MBLIB10 / C_EXAMP / SCANMAIL.C < prev    next >
Text File  |  1993-03-07  |  2KB  |  45 lines

  1. /* WARNING: THIS EXAMPLE IS QUICK & DIRTY!!! Its only purpose is to         */
  2. /* demonstrate how certain MB_lib functions are used and how they work.     */
  3. /* While the code is a functional program, no attempt has been made to      */
  4. /* clean up the code or to streamline it, and I've economized a bit on      */
  5. /* error checking since I've made this in a hurry. However, if you're       */
  6. /* able to use MB_lib, odds are that you also know how to write neat code.  */
  7.  
  8. /* Scan mail to a certain user, first forward, then reverse */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include "mb_lib.h"
  13.  
  14. long recnr;
  15. MSGHDR_RECORD hdr;
  16. MSGTOIDX_RECORD to;
  17.  
  18. main () {
  19.   if (msg_open ("C:\\MSGBASE")) {
  20.     puts ("Error opening message base");
  21.     exit (1);
  22.   }
  23.   puts ("User name?");
  24.   gets (to);
  25.   puts ("Listing forward...");
  26.   recnr = msg_firstto (& to);
  27.   while (recnr != -1) {
  28.     msg_read_hdr (recnr, & hdr);     /* Ignore errors for the moment */
  29.     printf ("Board: %3d  Message: %6d\nBy: %s\nRe: %s\n\n", hdr.board,
  30.          hdr.msgnum, hdr.who_from, hdr.subject);
  31.     recnr = msg_nextto (recnr);
  32.   }
  33.   puts ("Listing reverse...");
  34.   recnr = msg_lastto (& to);
  35.   while (recnr != -1) {
  36.     msg_read_hdr (recnr, & hdr);     /* Ignore errors for the moment */
  37.     printf ("Board: %3d  Message: %6d\nBy: %s\nRe: %s\n\n", hdr.board,
  38.          hdr.msgnum, hdr.who_from, hdr.subject);
  39.     recnr = msg_prevto (recnr);
  40.   }
  41.   msg_close ();
  42.   puts ("Done.");
  43.   return (0);
  44. }
  45.