home *** CD-ROM | disk | FTP | other *** search
- /*
-
- MSGCHK -- Lists all users with unread messages in a specified area
-
- Version 1.2 (8/7/89)
- Written by Bob Quinlan of Austin, TX, USA
-
- Copyright 1989 by Bob Quinlan
-
- Compatible with GT version 15
-
-
- This program checks through a specified message area and makes a list of
- all users with unread messages. The path to the area you want checked
- must be specified as the first parameter on the command line. The
- second parameter should begin with a plus sign (+) if you want the
- results appended to an existing list. This option makes it easy to scan
- multiple areas by running MSGCHK on each area and using the + on all
- except the first. If you want the list written to some particular file
- you can specify that as the second parameter on the command line (after
- the + and without any spaces between if you are using that option). If
- no output file is specified the list will be written to MSGCHK.BBS in
- the GTPATH directory. The program normally returns ERRORLEVEL 0. If
- any errors occur it will return ERRORLEVEL 1.
-
- Here are a few examples along with what they do:
-
- MSGCHK C:\GT\GENERAL
-
- This will scan the general area and create a new list under the
- name MSGCHK.BBS in the GTPATH directory.
-
- MSGCHK C:\GT\GENERAL
- MSGCHK C:\GT\NETMAIL +
-
- These two calls will create a combined list of users with
- messages in either the general or the netmail areas. The
- results will be stored in MSGCHK.BBS in the GTPATH directory.
-
- MSGCHK C:\GT\GENERAL C:\GT\EXTRAS\MESSAGES.LST
-
- This will scan the general area and create a new list under the
- name MESSAGES.LST in the C:\GT\EXTRAS directory.
-
- MSGCHK C:\GT\GENERAL C:\GT\EXTRAS\MESSAGES.LST
- MSGCHK C:\GT\NETMAIL +C:\GT\EXTRAS\MESSAGES.LST
-
- These two calls will create a combined list of users with
- messages in either the general or the netmail areas. The
- results will be stored in MESSAGES.LST in the C:\GT\EXTRAS
- directory.
-
- NOTICE: You may use, copy, and distribute this program freely as long
- as you insure that both the executable and the documentation (.DOC)
- files are included in the distribution package. The source code does
- not need to be included. You may modify this program and document, so
- long as reasonable credit is given to the original author if a
- substantial portion of the original remains intact. The author is not
- responsible for any losses which may occur either directly or indirectly
- as a result of using this program.
-
- HISTORY:
- Version 1.2 (8/7/89) -- Added output file appending to support scans
- of multiple areas.
- Version 1.1 (7/22/89) -- Fixed bug that would fail to recognize unread
- messages with funny received fields.
- Version 1.0 (7/17/89) -- Original release. Written in Turbo C.
-
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "dram.h" /* From the GT Developer's Toolkit */
-
- #define MAXLINE 128
- #define MAXMODE 4
-
-
- /************/
- /* MSGCHK */
- /************/
-
- main(int argc, char *argv[])
- {
- struct msg_record msg;
-
- char msgfn[MAXLINE];
- FILE *msgfp;
-
- char outfn[MAXLINE];
- char outmode[MAXMODE];
- FILE *outfp;
-
- int i;
-
-
- printf("MSGCHK 1.2 -- Copyright 1989 by Bob Quinlan (8/7/89)\n");
-
- /* Check for message area path on command line */
- if (argc < 2)
- {
- fprintf(stderr, "MSGCHK: No message area specified on command line\n");
- exit(1);
- }
- strcpy(msgfn, argv[1]);
- /* Add final backslash to path if not already present */
- i = strlen(msgfn);
- if (--i >= 0)
- if ((msgfn[i] != '\\') && (msgfn[i] != ':'))
- strcat(msgfn, "\\");
- /* Append the message control file name */
- strcat(msgfn, "MESSAGE.CTL");
- /* Open the message file */
- if ((msgfp = fopen(msgfn, "rb")) == NULL)
- {
- fprintf(stderr, "MSGCHK: Unable to open %s for input\n", msgfn);
- exit(1);
- }
-
- /* Check for output file on command line */
- if (argc > 2)
- if (*argv[2] == '+')
- {
- strcpy(outfn, argv[2]+1);
- strcpy(outmode, "a");
- }
- else
- {
- strcpy(outfn, argv[2]);
- strcpy(outmode, "w");
- }
- else
- {
- *outfn = '\0';
- strcpy(outmode, "w");
- }
- if (*outfn == '\0')
- /* If not specified write to MSGCHK.BBS in the GTPATH directory */
- {
- /* Get the GTPATH value from the environment */
- strcpy(outfn, getenv("GTPATH"));
- /* Add final backslash to path if not already present */
- i = strlen(outfn);
- if (--i >= 0)
- if ((outfn[i] != '\\') && (outfn[i] != ':'))
- strcat(outfn, "\\");
- /* Append the default output file name */
- strcat(outfn, "MSGCHK.BBS");
- }
- if ((outfp = fopen(outfn, outmode)) == NULL)
- {
- fprintf(stderr, "MSGCHK: Unable to open %s for output\n", outfn);
- exit(1);
- }
-
- /* Skip the control record */
- fread(&msg, sizeof(struct msg_record), 1, msgfp);
- /* Scan for unread messages */
- while (fread(&msg, sizeof(struct msg_record), 1, msgfp) > 0)
- {
- if ((msg.msg_deleted == 0) && ((msg.msg_received & 0x11) == 0))
- {
- fputs(msg.msg_addressee, outfp);
- fputc('\n', outfp);
- }
- }
-
- /* Close the output file */
- fclose(outfp);
- /* Close the message file */
- fclose(msgfp);
-
- return 0;
- }