home *** CD-ROM | disk | FTP | other *** search
- /* CHANGE.C */
- static char sccsid[] = "@(#)change.c 1.3 94/01/20 (c)1993 thalerd";
- /* PHASE 1: Conference Subsystem
- Be able to enter/exit the program, and move between conferences
- Commands: join, next, quit, source
- Files: rc files, cflist, login, logout, bull
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <errno.h>
- #include <time.h>
- #include "config.h"
- #include "struct.h"
- #include "globals.h"
- #include "conf.h"
- #include "lib.h"
- #include "joq.h"
- #include "sum.h"
- #include "item.h"
- #include "range.h"
- #include "macro.h"
- #include "system.h"
- #include "sep.h"
- #include "xalloc.h"
- #include "stats.h" /* for get_config */
-
- char *cfiles[]={ "logi_n", "logo_ut", "in_dex", "b_ull",
- "we_lcome", "rc", "sec_ret", "ul_ist", "" };
-
- /******************************************************************************/
- /* CHANGE SYSTEM PARAMETERS */
- /******************************************************************************/
- int /* RETURNS: (nothing) */
- change(argc,argv) /* ARGUMENTS: */
- int argc; /* Number of arguments */
- char **argv; /* Argument list */
- {
- char buff[MAX_LINE_LENGTH];
- char done;
- short i,j;
- char **config;
-
- if (argc<2) {
- printf("Change what?\n");
- return 1;
- }
-
- for (j=1; j<argc; j++) {
-
- /* Security measure */
- if (mode==M_SANE && match(argv[j],"noverbose"))
- continue;
-
- /* Process changing flags */
- for (done=0,i=0; i<NUM_OPTIONS; i++) {
- if (match(argv[j],option[i].name)) {
- flags |= option[i].mask;
- done=1;
- break;
- } else if(!strncmp(argv[j],"no",2) && match(argv[j]+2,option[i].name)){
- flags &= ~option[i].mask;
- done=1;
- break;
- }
- }
- if (done) continue;
-
- if (match(argv[j],"n_ame")
- || match(argv[j],"u_ser")) {
- printf("Your old name is: %s\n",st_glob.fullname);
- printf("Enter replacement or return to keep old? ");
- if (ngets(buff,st_glob.inp) && strlen(buff))
- strcpy(st_glob.fullname,buff);
- else
- printf("Name not changed.\n");
- } else if (match(argv[j],"p_assword")
- || match(argv[j],"passwd")) { unix_cmd("/bin/passwd");
- } else if (match(argv[j],"li_st")) { edit(work,".cflist",0);
- } else if (match(argv[j],"ig_noreeof")) { unix_cmd("/bin/stty eof ^-");
- } else if (match(argv[j],"noig_noreeof")){ unix_cmd("/bin/stty eof ^D");
- } else if (match(argv[j],"ch_at")) { unix_cmd("mesg y");
- } else if (match(argv[j],"noch_at")) { unix_cmd("mesg n");
- } else if (match(argv[j],"resign")) { command("resign",0);
- } else if (match(argv[j],"sa_ne")) { undefine(DM_SANE);
- } else if (match(argv[j],"supers_ane")) { undefine(DM_SANE|DM_SUPERSANE);
- } else if (match(argv[j],"save_seen")) {
- if (confidx>=0) {
- if (config = get_config(confidx))
- write_part(config[CF_PARTFILE]);
- }
- } else if (match(argv[j],"sum_mary")) {
- if (!(st_glob.c_status & CS_FW)) {
- wputs("Sorry, you can't do that!\n");
- return 1;
- }
- printf("Regenerating summary file; please wait\n");
- refresh_sum(0,confidx,sum,part,&st_glob);
- save_sum(sum,(short)-1,confidx,&st_glob);
- } else if (match(argv[j],"nosum_mary")) {
- if (!(st_glob.c_status & CS_FW)) {
- wputs("Sorry, you can't do that!\n");
- return 1;
- }
- sprintf(buff,"%s/sum",conflist[confidx].location);
- rm(buff,SL_OWNER);
- } else if (match(argv[j],"rel_oad")) {
- if (confidx>=0) {
- if (config = get_config(confidx))
- read_part(config[CF_PARTFILE],part,&st_glob,confidx);
- }
- st_glob.sumtime = 0;
- } else {
- for (i=0; cfiles[i][0]; i++) {
- if (match(argv[j],cfiles[i])) {
- char file[MAX_LINE_LENGTH],bufr[MAX_LINE_LENGTH];
-
- if (!(st_glob.c_status & CS_FW)) {
- printf("You aren't a fair-witness.\n");
- return 1;
- }
- sprintf(file,"%s/%s",
- conflist[confidx].location,compress(cfiles[i]));
- sprintf(bufr,"%s/cf.buffer",work);
-
- /* Copy file to cf.buffer owned by user */
- copy_file(file,bufr,SL_USER);
-
- if (!edit(bufr,(char*)0,0))
- printf("UNK Aborting...\n");
- else {
- if (get_yes("Ok to install this? "))
- copy_file(bufr,file,SL_OWNER);
- rm(bufr,SL_USER);
- }
- return 1;
- }
- }
- printf("Bad parameters near \"%s\"\n",argv[j]);
- return 2;
- }
- }
- return 1;
- }
-
- /******************************************************************************/
- /* DISPLAY SYSTEM PARAMETERS */
- /******************************************************************************/
- int /* RETURNS: (nothing) */
- display(argc,argv) /* ARGUMENTS: */
- int argc; /* Number of arguments */
- char **argv; /* Argument list */
- {
- static time_t newmail=0;
- time_t t;
- char *noconferr="Not in a conference!\n",*var;
- short i,done,j;
- char **config;
-
- for (j=1; j<argc; j++) {
-
- /* Display flag settings */
- for (done=0,i=0; i<NUM_OPTIONS; i++) {
- if (match(argv[j],option[i].name)) {
- printf("%s flag is %s\n",compress(option[i].name),
- (flags & option[i].mask)? "on" : "off" );
- done=1;
- break;
- }
- }
- if (match(argv[j],"ma_iltext")) {
- refresh_stats(sum,part,&st_glob);
- check_mail(1);
- }
- if (done) continue;
-
- if (match(argv[j],"fl_ags")) {
- for (done=0,i=0; i<NUM_OPTIONS; i++) {
- printf("%-10s : %s%s",compress(option[i].name),
- (flags & option[i].mask)? "ON " : "off",
- (i%4 == 3)? "\n":" ");
- }
- if (NUM_OPTIONS%4) printf("\n");
- } else if (match(argv[j],"c_onference")) {
- sepinit(IS_START);
- confsep("confmsg",confidx,&st_glob,part,0);
- } else if (match(argv[j],"conferences")) {
- command("list",0);
- } else if (match(argv[j],"d_ate") || match(argv[j],"t_ime")) {
- (void)time(&t);
- (void)printf("Time is %s",ctime(&t));
- } else if (match(argv[j],"def_initions") || match(argv[j],"ma_cros")) {
- define(1,(char **)0);
- } else if (match(argv[j],"v_ersion")) {
- struct stat st;
- char path[MAX_LINE_LENGTH];
-
- (void)printf("YAPP 2.%d Copyright (c)1993 David G. Thaler\n",VERSION);
- sprintf(path,"%s/registered",bbsdir);
- if (!stat(path,&st))
- more(bbsdir,"registered");
- else
- printf("Shareware version: Currently unregistered\n");
- } else if (match(argv[j],"ret_ired")) {
- int c=0;
-
- refresh_sum(0,confidx,sum,part,&st_glob);
- printf("Items retired:");
- for (i=0; i<MAX_ITEMS; i++) {
- if (sum[i].flags & IF_RETIRED) {
- if (!c) printf("\n");
- printf("%4d",i+1);
- c++;
- }
- }
- if (c)
- printf("\nTotal: %d items retired.\n",c);
- else
- printf(" <none>\n");
- } else if (match(argv[j],"fro_zen")) {
- int c=0;
-
- refresh_sum(0,confidx,sum,part,&st_glob);
- printf("Items frozen:");
- for (i=0; i<MAX_ITEMS; i++) {
- if (sum[i].flags & IF_FROZEN) {
- if (!c) printf("\n");
- printf("%4d",i+1);
- c++;
- }
- }
- if (c)
- printf("\nTotal: %d items frozen.\n",c);
- else
- printf(" <none>\n");
- } else if (match(argv[j],"f_orgotten")) {
- int c=0;
- printf("Items forgotten:");
- for (i=0; i<MAX_ITEMS; i++) {
- if (part[i].nr<0) {
- if (!c) printf("\n");
- printf("%4d",i+1);
- c++;
- }
- }
- if (c)
- printf("\nTotal: %d items forgotten.\n",c);
- else
- printf(" <none>\n");
- } else if (match(argv[j],"sup_eruser")) {
- printf("fw superuser %s\n",(st_glob.c_status & CS_FW)?"yes":"no");
- } else if (match(argv[j],"fw_slist")
- || match(argv[j],"fair_witnesslist")
- || match(argv[j],"fair_witnesses")) {
- if (confidx<0) wputs(noconferr);
- else {
- if (config = get_config(confidx))
- printf("fair witnesses: %s\n",config[CF_FWLIST]);
- }
- } else if (match(argv[j],"i_ndex")
- || match(argv[j],"ag_enda")) {
- sepinit(IS_START);
- confsep("indxmsg",confidx,&st_glob,part,0);
- } else if (match(argv[j],"li_st")) {
- refresh_list();
- for (i=0; i<xsizeof(cflist); i++)
- printf("%s %s\n",(current==i)? "-->" : " ",cflist[i]);
- } else if (match(argv[j],"b_ulletin")) {
- sepinit(IS_START);
- confsep("bullmsg",confidx,&st_glob,part,0);
- } else if (match(argv[j],"w_elcome")) {
- sepinit(IS_START);
- confsep("wellmsg",confidx,&st_glob,part,0);
- } else if (match(argv[j],"logi_n")) {
- sepinit(IS_START);
- confsep("linmsg",confidx,&st_glob,part,0);
- } else if (match(argv[j],"logo_ut")) {
- sepinit(IS_START);
- confsep("loutmsg",confidx,&st_glob,part,0);
- } else if (match(argv[j],"ul_ist")) {
- if (confidx<0) wputs(noconferr);
- else more(conflist[confidx].location,"ulist");
- } else if (match(argv[j],"rc")) {
- if (confidx<0) wputs(noconferr);
- else more(conflist[confidx].location,"rc");
- } else if (match(argv[j],"log_messages")) {
- if (confidx<0) wputs(noconferr);
- else {
- printf("login message:\n");
- more(conflist[confidx].location,"login");
- printf("logout message:\n");
- more(conflist[confidx].location,"logout");
- }
- } else if (match(argv[j],"n_ew")) {
- refresh_sum(0,confidx,sum,part,&st_glob);
- sepinit(IS_ITEM);
- open_pipe();
- confsep("linmsg",confidx,&st_glob,part,0);
- check_mail(1);
- } else if (match(argv[j],"n_ame") || match(argv[j],"u_ser"))
- (void)printf("User: %s\n",st_glob.fullname);
- else if (match(argv[j],"p_articipants")) {
- participants(0,(char**)0);
- } else if (match(argv[j],"s_een")) {
- int c=0;
- FILE *fp;
-
- refresh_sum(0,confidx,sum,part,&st_glob);
-
- /* Display seen item status */
- open_pipe();
- if (status & S_REDIRECT) fp = st_glob.outp;
- else fp = stdout;
- fprintf(fp,"item se re fl lastseen etime mtime\n\n");
- for (i=0; i<MAX_ITEMS; i++) {
- if (!part[i].nr) continue;
- fprintf(fp,"%4d %2d %2d %2X %s %s %s\n",i+1,abs(part[i].nr),sum[i].nr,
- sum[i].flags, get_date(part[i].last,0)+4, get_date(sum[i].first,0)+4,
- get_date(sum[i].last,0)+4);
- c++;
- }
- fprintf(fp,"total %d items in seen map\n\n",c);
- } else if (match(argv[j],"s_ize"))
- xstat();
- else if (match(argv[j],"strings"))
- xdump();
- else if (match(argv[j],"fds"))
- mdump();
- else if (match(argv[j],"w_hoison"))
- unix_cmd("who");
- else if (var=expand(argv[j],~0))
- printf("%s = %s\n",argv[j],var);
- else {
- printf("Bad parameters near \"%s\"\n",argv[j]);
- return 2;
- }
- }
- return 1;
- }
-