home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include "uqwk.h"
-
- /*
- * Wrap things up
- */
-
- CloseStuff()
- {
- fclose (msg_fd);
-
- WriteControl();
- if (do_news && (!read_only) ) WriteNewsrc();
-
- if (blk_cnt >= max_blks)
- {
- fprintf (stderr,
- "%s: block count exceeded; some articles not packed\n",
- progname);
- }
-
- /* Remove reply packet */
- if ( (!read_only) && (strcmp (rep_file, DEF_REP_FILE)))
- {
- unlink (rep_file);
- }
- }
-
- WriteControl()
- /*
- * Create the CONTROL.DAT file
- */
- {
- struct conf_ent *cp;
- struct tm *t;
- char ctl_fname[PATH_LEN];
- int clock;
-
- strcpy (ctl_fname, home_dir);
- strcpy (ctl_fname, "/");
- strcpy (ctl_fname, "control.dat");
-
- if (NULL == (ctl_fd = fopen (ctl_fname, "w")))
- {
- fprintf (stderr, "%s: can't open %s\n", progname, ctl_fname);
- exit (0);
- }
-
- fprintf (ctl_fd, "%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n",
- bbs_name, bbs_city, bbs_phone, bbs_sysop, bbs_id);
-
- /* Date */
- clock = time (NULL);
- t = gmtime (&clock);
- fprintf (ctl_fd, "%02d\-%02d\-%04d,%02d\:%02d\:%02d\r\n",
- t->tm_mon+1, t->tm_mday, t->tm_year+1900,
- t->tm_hour, t->tm_min, t->tm_sec);
-
- fprintf (ctl_fd, "%s\r\n \r\n0\r\n", user_name);
- fprintf (ctl_fd, "%d\r\n%d\r\n", msg_cnt, conf_cnt-1);
-
- /* List of conferences */
- cp = conf_list;
- while (cp != NULL)
- {
- fprintf (ctl_fd, "%d\r\n%s\r\n", cp->number, cp->name);
- cp = cp->next;
- }
-
- fprintf (ctl_fd, "WELCOME.DAT\r\nNEWS.DAT\r\nLOGOFF.DAT\r\n");
- fprintf (ctl_fd, "\032");
- fclose (ctl_fd);
- }
-
- WriteNewsrc()
- /*
- * Rewrite the updated .newsrc file
- */
- {
- if (read_only) return (0);
-
- if (NULL == (nrc_fd = fopen (nrc_file, "w")))
- {
- fprintf (stderr, "%s: can't write %s\n",
- progname, nrc_file);
- return (0);
- }
-
- /* We do this recursively to preserve the order of the .newsrc */
- wn (nrc_list);
-
- fclose (nrc_fd);
- }
-
- wn (np)
- struct nrc_ent *np;
- {
- if (np == NULL) return (0);
-
- /* Write the rest of them */
- wn (np->next);
-
- /* Write this one */
- if (np->subscribed)
- {
- fprintf (nrc_fd, "%s: 1-%d\n", np->name, np->hi);
- }
- else
- {
- fprintf (nrc_fd, "%s! 1-%d\n", np->name, np->hi);
- }
- }
-
-