예제 #1
0
int comment(void)
{
    int oldb;

    if (!conference()->conf.CONF_COMMENTAREA)
        return 0;

    oldb = current_msgbase->MSGBASE_NUMBER;

    if (changemsgbase(conference()->conf.CONF_COMMENTAREA, MC_QUICK | MC_NOSTAT)) {
        entermsg(0, 0, maincfg.CFG_SYSOPNAME);
        changemsgbase(oldb, MC_QUICK | MC_NOSTAT);
        return 1;
    }
    return 0;
}
예제 #2
0
int getreplyid(int msg, char *de, size_t delen)
{
	FILE *msgf;
	char buf[1024];

	snprintf(buf, sizeof buf, "%s/messages/base%3.3d/msg%5.5d", 
		conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, 
		msg);
	msgf = fopen(buf, "r");
	if (!msgf)
		return 0;
	while (fgets(buf, 1024, msgf)) {
		if (!strncmp(buf, "\001MSGID:", 7)) {
			buf[1] = 'R';
			buf[2] = 'E';
			buf[3] = 'P';
			buf[4] = 'L';
			buf[5] = 'Y';
			fclose(msgf);
			strlcpy(de, buf, delen);
			return 1;
		}
	}
	fclose(msgf);
	return 0;
}
예제 #3
0
Tip* TipCollection::canvasObjectToTip(CanvasObjectManager::Object obj)
{
   switch(obj) {
      case CanvasObjectManager::Object::DialInfo:
         return dialPad();
      case CanvasObjectManager::Object::EndCall :
         return endCall();
      case CanvasObjectManager::Object::Ringing :
         return ringing();
      case CanvasObjectManager::Object::Network :
         return connectionLost();
      case CanvasObjectManager::Object::DropInfo:
         return removeConference();
      case CanvasObjectManager::Object::ConfInfo:
         return conference();
      case CanvasObjectManager::Object::AccountDown:
         return networkLost();
      case CanvasObjectManager::Object::Searching:
         return searching();
      case CanvasObjectManager::Object::NoObject:
      case CanvasObjectManager::Object::AutoComplete:
         return nullptr;
   }
   return nullptr;
}
예제 #4
0
int prevconf(void)
{
	conference_t *mc;
	
	for (mc = conference()->prev; mc->prev; mc = mc->prev)
		if (checkconfaccess(mc->conf.CONF_NUMBER, &user))
			return joinconf(mc->conf.CONF_NUMBER, 0);
	
	return joinconf(-1, JC_LIST);
}
예제 #5
0
static void do_conference_wide_scan(void)
{
	int i, cm;
		
	if (!isanybasestagged(conference()->conf.CONF_NUMBER)) {
		ddprintf("%s", errstr[TS_NO_BASES_TAGGED]);
		return;
	}
	
	cm = current_msgbase->MSGBASE_NUMBER;
		
	for (i = 1; i <= conference()->conf.CONF_MSGBASES; i++) {
		if (!isbasetagged(conference()->conf.CONF_NUMBER, i))
			continue;
		scan_msgbase(i);
	}
	
	changemsgbase(cm, MC_QUICK | MC_NOSTAT);
}
예제 #6
0
void getmsgptrs(void)
{
    struct DayDream_MsgPointers ptrs;

    ddmsg_getptrs(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, &ptrs);

    highest = ptrs.msp_high;
    lowest = ptrs.msp_low;

}
예제 #7
0
int setmsgptrs(void)
{
    int msgfd;
    struct DayDream_MsgPointers ptrs;

    ptrs.msp_high = highest;
    ptrs.msp_low = lowest;

    if(ddmsg_setptrs(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, &ptrs) < 0) {
        DDPut(sd[setptrserrstr]);
        return 0;
    }

    return 1;
}
예제 #8
0
static int simple_search(int num)
{
	int fd, retcode;
	struct stat st;
	char fname[PATH_MAX + 1], *contents;

	snprintf(fname, PATH_MAX + 1, "%s/messages/base%3.3d/msg%5.5d",
		 conference()->conf.CONF_PATH,
		 current_msgbase->MSGBASE_NUMBER, num);
	if ((fd = open(fname, O_RDONLY)) == -1)
		return 0;
	fstat(fd, &st);
	contents = (char *) xmalloc(st.st_size + 1);
	contents[st.st_size] = 0;
	read(fd, contents, st.st_size);
	close(fd);
	if (pattern_type < 2)
		shrink_spaces(contents);
	retcode = strstr(contents, search_str) != NULL;
	free(contents);
	return retcode;
}
예제 #9
0
static char *get_headers(void)
{
	char *ofs;
	int fd;
	struct DayDream_Message msg;
	char fname[PATH_MAX + 1];
	
	snprintf(fname, PATH_MAX + 1, "%s/messages/base%3.3d/msgbase.dat",
		 conference()->conf.CONF_PATH,
		 current_msgbase->MSGBASE_NUMBER);
	if ((fd = open(fname, O_RDONLY)) == -1)
		return NULL;
	
	ofs = (char *) calloc(1 + highest - lowest, 1);
	
	for (;;) { 
		if (read(fd, &msg, sizeof(struct DayDream_Message)) !=
		    sizeof(struct DayDream_Message)) 
			break;
		
		if (msg.MSG_NUMBER < lowest ||
		    msg.MSG_NUMBER > highest)
			continue;
		/* no deleted messages */
		if (msg.MSG_FLAGS & (1L << 1))
			continue;
		
		/* keep privacy */
		if (msg.MSG_FLAGS & (1L << 0) && !read_all &&
		    findusername(msg.MSG_RECEIVER) != user.user_account_id) 
			continue;

		ofs[msg.MSG_NUMBER - lowest] = 1;
	}
	
	close(fd);
	return ofs;
}	       
예제 #10
0
int bulletins(char *params)
{
	char bdir[200];
	char menunam[240];
	char bullb[500];
	char tbuf[400];
	char nbu[240];
	int first = 0;

	int menfd;
	const char *srcstrh;

	changenodestatus("Viewing bulletins");

	snprintf(bdir, sizeof bdir, "%s/bulletins/",
			conference()->conf.CONF_PATH);
	snprintf(menunam, sizeof menunam, 
			"%sbulletinmenu.%s", bdir, ansi ? "gfx" : "txt");

	menfd = open(menunam, O_RDONLY);
	if (menfd == -1) {
		snprintf(bdir, sizeof bdir, "bulletins/");
		snprintf(menunam, sizeof menunam, "bulletins/bulletinmenu.%s",
				ansi ? "gfx" : "txt");
		menfd = open(menunam, O_RDONLY);
		if (menfd == -1) {
			DDPut(sd[bunobullsstr]);
			return 0;
		}
	}
	close(menfd);
	srcstrh = params;

	for (;;) {
		int bulnum;
		
		if (strtoken(bullb, &srcstrh, sizeof bullb) > sizeof bullb)
			continue;
		
		if (!*bullb) {
			if (!first)
				TypeFile(menunam, TYPE_WARN);
			DDPut(sd[bumenustr]);
			*tbuf = 0;
			if (!(Prompt(tbuf, 60, 0)))
				return 0;
			srcstrh = tbuf;
			
			if (strtoken(bullb, &srcstrh, 
				     sizeof bullb) > sizeof bullb)
				return 0;
			if (!*bullb)
				return 0;
		}
		first = 1;
		if (*bullb == 'q' || *bullb == 'Q')
			return 0;
		if (*bullb == 'l' || *bullb == 'L' || *bullb == '?') {
			TypeFile(menunam, TYPE_WARN);
		} else if ((bulnum = atoi(bullb))) {
			snprintf(nbu, sizeof nbu, "%sbulletin.%d.%s", bdir, 
					bulnum, ansi ? "gfx" : "txt");
			if (TypeFile(nbu, TYPE_WARN)) {
				if (!(user.user_toggles & (1L << 4))) {
					DDPut(sd[pause2str]);
					HotKey(0);
				}
			}
		}
	}
}
예제 #11
0
int download(const char *params)
{
	char parbuf[512];
	char bigbuf[10000];
	const char *srcstrh;
	int discon = 0;
	struct FFlag *myf;
	FILE *listh;
	char lastfile[100];
	int keepc = 1;

	bgrun = 0;
	wasbg = 0;

	setprotocol();
	changenodestatus("Downloading");
	TypeFile("download", TYPE_MAKE | TYPE_CONF | TYPE_WARN);

	if (!conference()->conf.CONF_FILEAREAS) {
		DDPut(sd[dlnoareasstr]);
		return 0;
	}
	if ((protocol->PROTOCOL_TYPE == 3 || protocol->PROTOCOL_TYPE == 2) && !conference()->conf.CONF_UPLOADAREA) {
		DDPut(sd[dlnouploadsstr]);
		return 0;
	}
	if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) {
		if (cleantemp() == -1) {
			DDPut(sd[tempcleanerrstr]);
			return 0;
		}
		if (!freespace())
			return 0;
		maketmplist();
	}
	srcstrh = params;

	for (;;) {
		if (strtoken(parbuf, &srcstrh, sizeof parbuf) > sizeof parbuf)
			continue;
		if (!*parbuf)
			break;
		flagfile(parbuf, 1);
	}
	for (;;) {
		typedlprompt();
		bigbuf[0] = 0;
		if (!(Prompt(bigbuf, 200, 0)))
			return 0;
		if (!bigbuf[0]) {
			break;
		} else if (!strcasecmp(bigbuf, "a")) {
			return 0;
		} else {
			srcstrh = bigbuf;
			for (;;) {
				if (strtoken(parbuf, &srcstrh, 
					     sizeof parbuf) > sizeof parbuf)
					continue;
				if (!*parbuf)
					break;
				flagfile(parbuf, 1);
			}
		}
	}
	if (!filestagged)
		return 0;
	listtags();
	if (estimsecs(bytestagged) > timeleft) {
		DDPut(sd[dlnotimestr]);
		return 0;
	}
	for (;;) {
		DDPut(sd[dlproceedstr]);
		bigbuf[0] = 0;
		if (!(Prompt(bigbuf, 3, 0)))
			return 0;
		if (!bigbuf[0] || bigbuf[0] == 'p' || bigbuf[0] == 'P')
			break;
		else if (bigbuf[0] == 'e' || bigbuf[0] == 'E') {
			taged(0);
		} else if (bigbuf[0] == 'd' || bigbuf[0] == 'D') {
			discon = 1;
			break;
		} else if (bigbuf[0] == 'a' || bigbuf[0] == 'A') {
			return 0;
		}
	}
	snprintf(parbuf, sizeof parbuf, "%s/dszlog.%d", DDTMP, node);

	sprintf(&parbuf[250], "%s/ddfilelist.%d", DDTMP, node);
	unlink(&parbuf[250]);

	if (!(listh = fopen(&parbuf[250], "w")))
		return 0;

	myf = (struct FFlag *) flaggedfiles->lh_Head;
	while (myf->fhead.ln_Succ) {
		char tbu[256];
		snprintf(tbu, sizeof tbu, "%s%s\n", 
			myf->f_path, myf->f_filename);
		fputs(tbu, listh);
		myf = (struct FFlag *) myf->fhead.ln_Succ;
	}
	fclose(listh);
	*lastfile = 0;

	if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) {
		if ((!(user.user_toggles & (1L << 15))) && (maincfg.CFG_FLAGS & (1L << 11))) {
			initbgchecker();

		}
	}
	sendfiles(&parbuf[250], lastfile, sizeof lastfile);


	if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) {
		upload(2);
	}
	if (*lastfile) {
		myf = (struct FFlag *) flaggedfiles->lh_Head;
		while (myf->fhead.ln_Succ && keepc) {
			struct FFlag *oldf;
			struct DD_DownloadLog ddl;
			char lbuf[100];
			int logfd;

			snprintf(lbuf, sizeof lbuf, 
				"%s/logfiles/downloadlog.dat", origdir);
			logfd = open(lbuf, O_WRONLY | O_CREAT, 0666);
			if (logfd != -1) {
				fsetperm(logfd, 0666);
				memset((char *) &ddl, 0, sizeof(struct DD_DownloadLog));
				ddl.DL_SLOT = user.user_account_id;
				strlcpy(ddl.DL_FILENAME, myf->f_filename, sizeof ddl.DL_FILENAME);
				ddl.DL_FILESIZE = myf->f_size;
				ddl.DL_TIME = time(0);
				ddl.DL_BPSRATE = bpsrate;
				ddl.DL_NODE = node;
				ddl.DL_CONF = (unsigned char) myf->f_conf;
				lseek(logfd, 0, SEEK_END);
				safe_write(logfd, &ddl, sizeof(struct DD_DownloadLog));
				close(logfd);
			}
			if (!(myf->f_flags & FLAG_FREE)) {
				user.user_dlbytes += myf->f_size;
				user.user_dlfiles++;
			}
			if (!strcasecmp(lastfile, myf->f_filename))
				keepc = 0;
			Remove((struct Node *) myf);
			oldf = myf;
			myf = (struct FFlag *) myf->fhead.ln_Succ;
			free(oldf);
		}
	}
	recountfiles();

	unlink(&parbuf[250]);

	if (discon) {
		if (autodisconnect())
			return 2;
	}
	return 1;
}
예제 #12
0
int changemsgbase(int newb, int flags)
{
	char cbuffer[500];
	int basen;
	int i;	
	struct DayDream_LRP lrpd;
	int lrpfd;
	struct stat st;
	msgbase_t *cb;

	if (!conference()->conf.CONF_MSGBASES) {
		current_msgbase = NULL;
		return 0;
	}
       			
	basen = newb;
	
	if (basen > conference()->conf.CONF_MSGBASES)
		basen = 0;
	
	/* The MC_QUICK flag is used on non-interactive occasions. */
	if (!basen && (flags & MC_QUICK))
		return 0;
	
	if (!basen) {
		if (conference()->conf.CONF_MSGBASES == 1) {
			DDPut(sd[cmbonlymsgsstr]);
			return 0;
		}
		TypeFile("messagebases", TYPE_WARN | TYPE_CONF | TYPE_MAKE);
	}	      
	
	while (!basen) {
		DDPut(sd[cmbselectstr]);
		cbuffer[0] = 0;
		if (!(Prompt(cbuffer, 3, 0)))
			return 0;
		if (!strcasecmp(cbuffer, "?") || (!strcasecmp(cbuffer, "l"))) {
			TypeFile("messagebases", TYPE_WARN | TYPE_CONF | TYPE_MAKE);
		} else if (cbuffer[0] == 0) {
			return 0;
		} else
			basen = atoi(cbuffer);
	}
	for (i = 0; i < conference()->conf.CONF_MSGBASES; i++) {
		cb = conference()->msgbases[i];		
		
		if (cb->MSGBASE_NUMBER != basen)
			continue;
		
		current_msgbase = cb;
		getmsgptrs();
		if (lrpdatname[0] && (oldlrp != lrp || oldlsp != lsp)) {
			lrpfd = open(lrpdatname, O_WRONLY | O_CREAT, 0666);
			if (lrpfd == -1) {
				DDPut(sd[cmberrlrpstr]);
				return 0;
			}
			fsetperm(lrpfd, 0666);
			fstat(lrpfd, &st);
			lrpd.lrp_read = lrp;
			lrpd.lrp_scan = lsp;
			lseek(lrpfd, sizeof(struct DayDream_LRP) * user.user_account_id, SEEK_SET);
			safe_write(lrpfd, &lrpd, sizeof(struct DayDream_LRP));
			close(lrpfd);
		}
		snprintf(lrpdatname, sizeof lrpdatname,
			"%s/messages/base%3.3d/msgbase.lrp", 
			conference()->conf.CONF_PATH, cb->MSGBASE_NUMBER);
		lrpfd = open(lrpdatname, O_RDONLY);
		
		lrp = 0;
		lsp = 0;
		oldlrp = 0;
		oldlsp = 0;
		
		if (lrpfd != -1) {
			if ((lseek(lrpfd, sizeof(struct DayDream_LRP) * user.user_account_id, SEEK_SET)) != -1) {
				if (read(lrpfd, &lrpd, sizeof(struct DayDream_LRP))) {
					oldlrp = lrp = lrpd.lrp_read;
					oldlsp = lsp = lrpd.lrp_scan;
				}
			}
			close(lrpfd);
		}
		current_msgbase = cb;
		getmsgptrs();
		
		if ((flags & MC_NOSTAT) == 0) {
			ddprintf(sd[cmbstat1str], current_msgbase->MSGBASE_NAME, highest - lowest);
			ddprintf(sd[cmbstat2str], lrp, lsp);
			ddprintf(sd[cmbstat3str], lowest, highest);
		}
		
		return 1;
	}

	DDPut(sd[cmbunkbasestr]);
	return 0;
}
예제 #13
0
int joinconf(int confn, int flags)
{
	int newconfnum;
	conference_t *mc;
	struct iterator *iterator;

	char jbuffer[100];
	
	newconfnum = confn;

	changenodestatus("Changing conference");

	if ((flags & JC_LIST) && newconfnum == -1)
		TypeFile("joinconference", TYPE_WARN | TYPE_MAKE);


	while (newconfnum == -1) {		
		jbuffer[0] = 0;
		DDPut(sd[jcpromptstr]);
		if (!(Prompt(jbuffer, 3, 0)))
			return 0;
		if ((!strcasecmp(jbuffer, "l")) || jbuffer[0] == '?')
			TypeFile("joinconference", TYPE_WARN | TYPE_MAKE);
		else if (jbuffer[0] == 0)
			return 0;
		else {
			char *endptr;
			newconfnum = strtol(jbuffer, &endptr, 10);
			if (*jbuffer && !*endptr)
				break;
		}
		
		newconfnum = -1;
	}
	
	iterator = conference_iterator();
	while ((mc = (conference_t *) iterator_next(iterator))) {
		if (mc->conf.CONF_NUMBER != newconfnum)
			continue;
		
		if (!checkconfaccess(newconfnum, &user)) {
			if (!(flags & JC_SHUTUP)) {
				DDPut(sd[jcnoaccessstr]);
			}
			iterator_discard(iterator);
			return 0;
		}
				
		if (*mc->conf.CONF_PASSWD && !(flags & JC_SHUTUP) && !(flags & JC_QUICK)) {
			conference_t *oldconf = conference();
			
			set_conference(mc);
			TypeFile("conferencepw", TYPE_CONF | TYPE_MAKE);
			set_conference(oldconf);
			
			DDPut("Conference password: ");
			*jbuffer = 0;
			if (!(Prompt(jbuffer, 16, PROMPT_SECRET))) {
				iterator_discard(iterator);
				return 0;
			}
			if (strcasecmp(jbuffer, mc->conf.CONF_PASSWD)) {
				iterator_discard(iterator);
				return 0;
			}
		}
		
		if (!(flags & JC_NOUPDATE))
			user.user_joinconference = newconfnum;
		set_conference(mc);
		
		if (conference()->conf.CONF_MSGBASES)
			current_msgbase = conference()->msgbases[0];
		else 
			current_msgbase = NULL;

		if (!(flags & JC_QUICK)) {
			TypeFile("conferencejoined", TYPE_MAKE | TYPE_CONF);
		}
		
		if (current_msgbase) {
			if (flags & JC_QUICK) {
				changemsgbase(current_msgbase->MSGBASE_NUMBER, MC_QUICK | MC_NOSTAT);
			} else {
				changemsgbase(current_msgbase->MSGBASE_NUMBER, MC_QUICK);
			}
		}
		iterator_discard(iterator);
		return 1;
	}
	iterator_discard(iterator);
		
	if (!(flags & JC_SHUTUP)) {
		DDPut(sd[jcnoconfstr]);
	}

	return 0;
}
예제 #14
0
int entermsg(struct DayDream_Message *msg, int reply, char *params)
{
    char ebuf[1024];
    int hola;
    int msgfd;
    char *s;
    struct DayDream_Message header;
    char *lineedmem;

    int recoff;

    if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E' && ((access1 & (1L << SECB_FIDOMESSAGE)) == 0)) {
        DDPut(sd[emnofidomsgstr]);
        return 0;
    }
    if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N' && ((access2 & (1L << SECB_SENDNETMAIL)) == 0)) {
        DDPut(sd[emnonetmsgstr]);
        return 0;
    }
    changenodestatus("Entering a message");
    if (msg) {
        memcpy(&header, msg, sizeof(struct DayDream_Message));
    } else {
        s = (char *) &header;
        memset(&header, 0, sizeof(struct DayDream_Message));
        if (params)
            strncpy(header.MSG_RECEIVER, params, 25);
    }

    if (current_msgbase->MSGBASE_FLAGS & (1L << 0) && current_msgbase->MSGBASE_FLAGS & (1L << 1)) {
        DDPut(sd[emnomsgsstr]);
        return 0;
    }
    DDPut(sd[emhead1str]);
    DDPut(current_msgbase->MSGBASE_NAME);
    ebuf[0] = 0;
    strlcat(ebuf, sd[emhead2str], sizeof ebuf);
    hola = 61 - strlen(current_msgbase->MSGBASE_NAME);
    while (hola) {
        strlcat(ebuf, "-", sizeof ebuf);
        hola--;
    }
    DDPut(ebuf);
    ddprintf(sd[emhead3str], highest);
    DDPut(sd[emhead4str]);

    if ((current_msgbase->MSGBASE_FLAGS & (1L << 0)) || (header.MSG_FLAGS & (1L << 0))) {
        DDPut(sd[emprvstr]);
        header.MSG_FLAGS |= (1L << 0);
    } else {
        DDPut(sd[empubstr]);
    }
    header.MSG_CREATION = time(0);
    DDPut(sd[emhead5str]);
    DDPut(ctime(&header.MSG_CREATION));

    DDPut(sd[emhead6str]);
    if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) {
        strlcpy(header.MSG_AUTHOR, user.user_handle, sizeof header.MSG_AUTHOR);
    } else {
        strlcpy(header.MSG_AUTHOR, user.user_realname, sizeof header.MSG_AUTHOR);
    }
    DDPut(header.MSG_AUTHOR);
    for (;;) {
askrec:
        DDPut(sd[emhead7str]);
        if (!(Prompt(header.MSG_RECEIVER, 25, 0)))
            return 0;
        if (header.MSG_RECEIVER[0] == 0 || (!strcasecmp(header.MSG_RECEIVER, "all")) || (!strcasecmp(header.MSG_RECEIVER, "all users"))) {
            if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) {
                DDPut(sd[emhead8str]);
                HotKey(0);
                header.MSG_RECEIVER[0] = 0;
            } else {
                DDPut(sd[emhead9str]);
                header.MSG_RECEIVER[0] = 0;
                break;
            }
        } else if (!strcasecmp(header.MSG_RECEIVER, "eall")) {
            if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) {
                DDPut(sd[emhead8str]);
                HotKey(0);
                header.MSG_RECEIVER[0] = 0;
            } else if (access1 & (1L << SECB_EALLMESSAGE)) {
                header.MSG_RECEIVER[0] = -1;
                DDPut(sd[emhead10str]);
                break;
            } else {
                DDPut(sd[emnopoststr]);
                HotKey(0);
                header.MSG_RECEIVER[0] = 0;
            }
        } else {
            if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'L') {
                struct userbase user;

                if (!strcasecmp(header.MSG_RECEIVER, "sysop")) {
                    recoff = 0;
                } else {
                    recoff = findusername(header.MSG_RECEIVER);
                }
                if (recoff == -1 ||
                        getubentbyid(recoff, &user) == -1) {
                    DDPut(sd[emnouserstr]);
                    HotKey(0);
                    goto askrec;
                }

                if (!checkconfaccess(conference()->conf.CONF_NUMBER, &user)) {
                    DDPut(sd[emnoaccessstr]);
                    HotKey(0);
                }
                DDPut("                     ");
                if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) {
                    strlcpy(header.MSG_RECEIVER,
                            user.user_handle,
                            sizeof header.MSG_RECEIVER);
                } else {
                    strlcpy(header.MSG_RECEIVER,
                            user.user_realname,
                            sizeof header.MSG_RECEIVER);
                }
                DDPut(header.MSG_RECEIVER);
                break;
            } else
                break;
        }
    }
    DDPut(sd[emsubjectstr]);
    if (!(Prompt(header.MSG_SUBJECT, 67, 0)))
        return 0;
    if (header.MSG_SUBJECT[0] == 0) {
        DDPut(sd[emabortedstr]);
        return 0;
    }
    DDPut("                                                                       ");
    if (header.MSG_RECEIVER[0] == 0 || header.MSG_RECEIVER[0] == -1 || header.MSG_FLAGS & (1L << 0) || current_msgbase->MSGBASE_FLAGS & (1L << 1)) {

    } else {
        DDPut(sd[emisprivatestr]);
        hola = HotKey(HOT_NOYES);
        if (hola == 0)
            return 0;
        if (hola == 1)
            header.MSG_FLAGS |= MSG_FLAGS_PRIVATE;
    }

    if ((header.MSG_FLAGS & (1L << 0)) == 0 && (access1 & (1L << SECB_PUBLICMESSAGE)) == 0) {
        DDPut(sd[emnopubstr]);
        return 0;
    }
    if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') {
        if (header.MSG_FN_DEST_NET) {
            snprintf(ebuf, sizeof ebuf, "%d:%d/%d.%d",
                     header.MSG_FN_DEST_ZONE,
                     header.MSG_FN_DEST_NET,
                     header.MSG_FN_DEST_NODE,
                     header.MSG_FN_DEST_POINT);
        } else {
            *ebuf = 0;
        }
        DDPut(sd[emnetaddstr]);
        if (!(Prompt(ebuf, 30, 0)))
            return 0;
        if (!str2addr(ebuf, &header.MSG_FN_DEST_ZONE, &header.MSG_FN_DEST_NET,
                      &header.MSG_FN_DEST_NODE, &header.MSG_FN_DEST_POINT))
            return 0;
        if(access2 & (1L << SECB_CRASH)) {
            DDPut(sd[emnetcrashstr]);
            if(HotKey(HOT_NOYES) == 1) {
                header.MSG_FLAGS |= MSG_FLAGS_CRASH;
            }
        }
        DDPut(sd[emnetkillstr]);
        if(HotKey(HOT_YESNO) == 1) {
            header.MSG_FLAGS |= MSG_FLAGS_KILL_SENT;
        }
    }
    *header.MSG_ATTACH = 0;

    if (current_msgbase->MSGBASE_FLAGS & (1L << 5)) {
        if ((header.MSG_FLAGS & (1L << 0)) && (access2 & (1L << SECB_PVTATTACH))) {
            *header.MSG_ATTACH = 1;
        } else if (((header.MSG_FLAGS & (1L << 0)) == 0) && (access2 & (1L << SECB_PUBATTACH))) {
            *header.MSG_ATTACH = 1;
        }
    }
    if (reply) {
        if (!askqlines()) {
            snprintf(ebuf, sizeof ebuf, "%s/daydream%d.msg",
                     DDTMP, node);
            unlink(ebuf);
        }
        DDPut("\n\n");
    }
    /* XXX: size should be replaced by a constant! */
    lineedmem = (char *) xmalloc(80 * 500);
    hola = edfile(lineedmem, 80 * 500, reply, &header);
    if (hola == 0) {
        char fabuf[1024];

        DDPut(sd[emaborted2str]);
        free(lineedmem);
        if (cleantemp() == -1) {
            DDPut(sd[tempcleanerrstr]);
            return 0;
        }
        snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node);
        unlink(fabuf);

        return 0;
    }
    DDPut(sd[emsavingstr]);

    getmsgptrs();
    highest++;
    header.MSG_NUMBER = highest;
    if (setmsgptrs() == 0) {
        free(lineedmem);
        return 0;
    }
    if (*header.MSG_ATTACH) {
        char fabuf[1024];
        FILE *fd;

        snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node);
        if ((fd = fopen(fabuf, "r"))) {
            char hoobab[1024];

            snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/fa%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER);
            mkdir(hoobab, 0777);
            setperm(hoobab, 0777);

            while (fgetsnolf(hoobab, 1024, fd)) {
                char sr[1024];
                char de[1024];
                snprintf(sr, sizeof sr, "%s/%s", currnode->MULTI_TEMPORARY, hoobab);
                snprintf(de, sizeof de, "%s/messages/base%3.3d/fa%5.5d/%s", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, hoobab);
                newrename(sr, de);
            }
            fclose(fd);
            snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/msf%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER);
            newrename(fabuf, hoobab);
        } else {
            *header.MSG_ATTACH = 0;
        }
    }

    if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') {
        header.MSG_FN_ORIG_ZONE = current_msgbase->MSGBASE_FN_ZONE;
        header.MSG_FN_ORIG_NET = current_msgbase->MSGBASE_FN_NET;
        header.MSG_FN_ORIG_NODE = current_msgbase->MSGBASE_FN_NODE;
        header.MSG_FN_ORIG_POINT = current_msgbase->MSGBASE_FN_POINT;
        header.MSG_FLAGS |= (1L << 2);
    }
    if ((msgfd = ddmsg_open_base(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, O_RDWR | O_CREAT, 0666)) == -1) {
        DDPut(sd[emwriteerrstr]);
        free(lineedmem);
        return 0;
    }
    fsetperm(msgfd, 0666);
    lseek(msgfd, 0, SEEK_END);
    safe_write(msgfd, &header, sizeof(struct DayDream_Message));
    ddmsg_close_base(msgfd);

    if ((msgfd = ddmsg_open_msg(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) {
        DDPut(sd[emwriteerrstr]);
        free(lineedmem);
        return 0;
    }
    fsetperm(msgfd, 0666);
    if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') {
        char ub[128];
        int uq;

        strlcpy(ub, current_msgbase->MSGBASE_FN_TAG, sizeof ub);
        strupr(ub);
        snprintf(ebuf, sizeof ebuf, "AREA:%s\n", ub);
        safe_write(msgfd, ebuf, strlen(ebuf));
        if ((uq = getfidounique())) {
            snprintf(ebuf, sizeof ebuf, "\001MSGID: %d:%d/%d.%d %8.8x\n", current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_POINT, uq);
            safe_write(msgfd, ebuf, strlen(ebuf));
            if (header.MSG_ORIGINAL) {
                if (getreplyid(header.MSG_ORIGINAL, ebuf, sizeof ebuf))
                    safe_write(msgfd, ebuf, strlen(ebuf));
            }
        }
    } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') {
        snprintf(ebuf, sizeof ebuf, "\001INTL %d:%d/%d %d:%d/%d\n",
                 header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET,
                 header.MSG_FN_DEST_NODE, header.MSG_FN_ORIG_ZONE,
                 header.MSG_FN_ORIG_NET, header.MSG_FN_ORIG_NODE);
        safe_write(msgfd, ebuf, strlen(ebuf));

        if (header.MSG_FN_DEST_POINT) {
            snprintf(ebuf, sizeof ebuf, "\001TOPT %d\n", header.MSG_FN_DEST_POINT);
            safe_write(msgfd, ebuf, strlen(ebuf));
        }
        if (header.MSG_FN_ORIG_POINT) {
            snprintf(ebuf, sizeof ebuf, "\001FMPT %d\n", header.MSG_FN_ORIG_POINT);
            safe_write(msgfd, ebuf, strlen(ebuf));
        }
    }
    s = lineedmem;
    while (hola) {
        snprintf(ebuf, sizeof ebuf, "%s\n", s);
        safe_write(msgfd, ebuf, strlen(ebuf));
        hola--;
        s = &s[80];
    }

//	place holder, user auto-sig goes here
//	snprintf(ebuf, sizeof ebuf, "signature here");
//	safe_write(msgfd, ebuf, strlen(ebuf));

    if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') {
        snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n * Origin: %s (%d:%d/%d)\nSEEN-BY: %d/%d\n", versionstring, current_msgbase->MSGBASE_FN_ORIGIN, current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE);
        safe_write(msgfd, ebuf, strlen(ebuf));
    } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') {
        snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n", versionstring);
        safe_write(msgfd, ebuf, strlen(ebuf));
    }
    ddmsg_close_msg(msgfd);

    DDPut(sd[emdonestr]);
    free(lineedmem);

    if (header.MSG_FLAGS & (1L << 0)) {
        user.user_pvtmessages++;
        clog.cl_pvtmessages++;
    } else {
        user.user_pubmessages++;
        clog.cl_pubmessages++;
    }
    return 1;
}
예제 #15
0
int tagmessageareas(void)
{
	uint8_t backup[32];
	char tbuf[500];
	const char *sta;
	msgbase_t *mb;
	int bcnt;
	char inp[90];
	const char *s;
	char tok[90];
        int screenl;        

	int i, j;

	memcpy(backup, &selcfg[(conference()->conf.CONF_NUMBER - 1) * 32],
	       sizeof backup);
	       
	vagain:
	DDPut("");

	screenl = user.user_screenlength;
	bcnt = conference()->conf.CONF_MSGBASES;

	for (i = j = 0; j < bcnt; j++) {
		mb = conference()->msgbases[j];
		
		i++;
		if (i == 3) {
			DDPut("\n");
			i = 1;
			screenl--;
			if (screenl == 1) {
				int hot;

				DDPut(sd[morepromptstr]);
				hot = HotKey(0);
				DDPut("\r                                                         \r");
				if (hot == 'N' || hot == 'n' || !checkcarrier())
					break;
				if (hot == 'C' || hot == 'c') {
					screenl = 20000000;
				} else {
					screenl = user.user_screenlength;
				}
			}
		}
		if (isbasetagged(conference()->conf.CONF_NUMBER, mb->MSGBASE_NUMBER)) {
			sta = "ON";
		} else
			sta = "OFF";

		ddprintf(sd[tbclinestr], mb->MSGBASE_NUMBER, mb->MSGBASE_NAME, sta);
	}

	DDPut("\n");
	for (;;) {
		DDPut(sd[tbpromptstr]);
		inp[0] = 0;
		if (!(Prompt(inp, 80, 0)))
			return 0;
		s = inp;
		if (!*inp) {
			strlcpy(inp, "s", sizeof inp);
		}
		
		for (;;) {
			if (strtoken(tok, &s, sizeof tok) > sizeof tok)
				continue;
			if (!*tok)
				break;

			if (!strcasecmp(tok, "c")) {
				memcpy(&selcfg[(conference()->conf.CONF_NUMBER - 1) * 32],
				       backup, sizeof backup);
				
				return 0;
			} else if (!strcasecmp(tok, "v")) {
				goto vagain;
			} else if (!strcasecmp(tok, "s")) {
				int selfd;
				snprintf(tbuf, sizeof tbuf,
					"users/%d/selected.dat", 
					user.user_account_id);
				selfd = open(tbuf, O_WRONLY | O_CREAT, 0666);
				if (selfd != -1) {
					fsetperm(selfd, 0666);
					safe_write(selfd, &selcfg, 2056);
					close(selfd);
				}
				return 0;
			} else if (!strcasecmp(tok, "-")) {
				for (i = 0; i < 32; i++) {
					selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + i] = 0;
				}
				DDPut(sd[tballoffstr]);
			} else if (!strcasecmp(tok, "+")) {
				bcnt = conference()->conf.CONF_MSGBASES;
				
				for (i = 0; i < bcnt; i++) {
					mb = conference()->msgbases[i];
					selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] |= (1L << (mb->MSGBASE_NUMBER - 1) % 8);
				}
				DDPut(sd[tballonstr]);
			} else {
				i = atoi(tok);
				if (i) {
					for (j = 0; j < conference()->conf.CONF_MSGBASES; j++) {
						mb = conference()->msgbases[j];
						if (i == mb->MSGBASE_NUMBER) {
							if (selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] & (1L << (mb->MSGBASE_NUMBER - 1) % 8)) {
								selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] &= ~(1L << (mb->MSGBASE_NUMBER - 1) % 8);
							} else {
								selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] |= (1L << (mb->MSGBASE_NUMBER - 1) % 8);
							}
							break;
						}
					}

				}
			}
		}
	}
}
예제 #16
0
int replymessage(struct DayDream_Message *msgd)
{
	char qbuffer[4096];
	char input[2048];
	char msgin[10];
	FILE *msgfd;
	FILE *quotefd;
	char *s, *t;
	int i;
	int hola;
	int l = 0;

	struct DayDream_Message header;

	s = (char *) &header;
	for (hola = 0; hola < sizeof(struct DayDream_Message); hola++) {
		*s++ = 0;
	}

	snprintf(qbuffer, sizeof qbuffer, "%s/messages/base%3.3d/msg%5.5d", 
		conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, 
		msgd->MSG_NUMBER);

	if (!(msgfd = fopen(qbuffer, "r")))
		return 0;

	snprintf(qbuffer, sizeof qbuffer, "%s/daydream%d.mtm", DDTMP, node);
	unlink(qbuffer);

	if (!(quotefd = fopen(qbuffer, "w"))) {
		fclose(msgfd);
		return 0;
	}
	if (current_msgbase->MSGBASE_FLAGS & (1L << 3)) {
		if (current_msgbase->MSGBASE_FLAGS & (1L << 4)) {
			s = msgd->MSG_AUTHOR;
			t = msgin;
			*t++ = *s++;
			while (*s) {
				if (*s == ' ' && *(s + 1)) {
					s++;
					*t++ = *s;
				}
				s++;
			}
			*t++ = '>';
			*t = 0;
		} else {
			msgin[0] = '>';
			msgin[1] = 0;
		}
	} else {
		msgin[0] = 0;
	}


	while (fgets(input, 2048, msgfd)) {
		if (l == 0 && !strncmp("AREA:", input, 5))
			continue;
		l++;
		if (*input == 1)
			continue;
		if (!strncmp("SEEN-BY:", input, 8))
			break;

		stripansi(input);
		snprintf(qbuffer, sizeof qbuffer, "%s%s", msgin, input);
		t = qbuffer;
		for (;;) {
			if (strlen(t) > 76) {
				char k;

				s = &t[75];
				for (;;) {
					if (s == t) {
						k = t[75];
						t[75] = 0;
						s = &t[75];
						break;
					} else {
						if (*s == ' ') {
							k = *s;
							*s = 0;
							break;
						}
						s--;
					}

				}
				fputs(t, quotefd);
				fputs("\n", quotefd);
				*s = k;
				if (k == ' ')
					s++;
				t = s;
				snprintf(qbuffer, sizeof qbuffer, "%s%s", 
					msgin, t);
				t = qbuffer;
			} else {
				fputs(t, quotefd);
				break;
			}
		}
	}

	if (!msgin[0]) {
		snprintf(qbuffer, sizeof qbuffer, "---[ %s ]", 
			msgd->MSG_AUTHOR);

		for (i = strlen(qbuffer); i < 75; i++) {
			strlcat(qbuffer, "-", sizeof qbuffer);
		}
		strlcat(qbuffer, "\n\n", sizeof qbuffer);
		fputs(qbuffer, quotefd);
	}
	fclose(msgfd);
	fclose(quotefd);

	strlcpy(header.MSG_RECEIVER, msgd->MSG_AUTHOR, sizeof header.MSG_RECEIVER);
	strlcpy(header.MSG_SUBJECT, msgd->MSG_SUBJECT, sizeof header.MSG_SUBJECT);
	header.MSG_ORIGINAL = msgd->MSG_NUMBER;
	if (msgd->MSG_FLAGS & (1L << 0))
		header.MSG_FLAGS |= (1L << 0);
	if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') {
		if (msgd->MSG_FN_ORIG_ZONE) {
			header.MSG_FN_DEST_ZONE = msgd->MSG_FN_ORIG_ZONE;
		} else {
			header.MSG_FN_DEST_ZONE = msgd->MSG_FN_PACKET_ORIG_ZONE;
		}
		header.MSG_FN_DEST_NET = msgd->MSG_FN_ORIG_NET;
		header.MSG_FN_DEST_NODE = msgd->MSG_FN_ORIG_NODE;
		header.MSG_FN_DEST_POINT = msgd->MSG_FN_ORIG_POINT;

	}
	i = entermsg(&header, 1, 0);
	getmsgptrs();
	return i;
}