Exemple #1
0
VOID open_obj(WORD sobj)
{
	LONG	tree; 
	WORD	type; 

	if (rcs_state == MENU_STATE)
		if (!in_bar(ad_view, sobj))
			if (!menu_ok(ad_view, sobj))
				return;
	if (rcs_state == FREE_STATE)
		if (sobj == ROOT)
			return;

	tree = ad_view;
	obj_redraw(tree, sobj);
	type = LLOBT(GET_TYPE(tree, sobj));

	switch (type)
	{
		case G_TITLE:
		case G_STRING:
		case G_BUTTON:
			edit_str(tree, sobj);
			break;
		case G_IBOX:
		case G_BOX:
		case G_BOXCHAR:
			edit_box(tree, sobj);
			break;
		case G_TEXT:
		case G_BOXTEXT:
		case G_FTEXT:
		case G_FBOXTEXT:
			edit_text(tree, sobj);
			break;
		case G_IMAGE:
			edit_bit(tree, sobj);
			break;
		case G_ICON:
			edit_icon(tree, sobj);
			break;
		default:
			break;
	}

	if (rcs_state == MENU_STATE || rcs_state == ALRT_STATE)
		view_objs();
	else
		obj_redraw(ad_view, sobj);
}
Exemple #2
0
void		del(char **str, int *pos,
		    UNUSED t_head *history,
		    UNUSED int *i_history)
{
  if ((*str) && *pos < (int)strlen(*str))
    {
      edit_str(str, pos, 1);
      cursor_save();
      cursor_forward(strlen(*str) - *pos);
      cursor_backward(1);
      cursor_erase(strlen(*str) + 1);
      cursor_restore();
      cursor_save();
      fflush(stdout);
      write(1, "\r", 1);
      write(1, history->prompt, strlen(history->prompt));
      write(1, *str, strlen(*str));
      cursor_restore();
      fflush(stdout);
    }
}
Exemple #3
0
void		backspace(char **str, int *pos,
			  UNUSED t_head *history,
			  UNUSED int *i_history)
{
  if (*pos > 0)
    {
      edit_str(str, pos, 0);
      --*pos;
      cursor_save();
      cursor_forward(strlen(*str) - *pos);
      cursor_backward(1);
      cursor_erase(1);
      cursor_restore();
      cursor_backward(1);
      cursor_erase(1);
      cursor_save();
      fflush(stdout);
      write(1, "\r", 1);
      write(1, history->prompt, strlen(history->prompt));
      write(1, *str, strlen(*str));
      cursor_restore();
      fflush(stdout);
    }
}
Exemple #4
0
/*
 * Edit one record, return -1 if there are errors, 0 if ok.
 */
int EditMGrpRec(int Area)
{
    FILE	    *fil;
    static char	    mfile[PATH_MAX], temp[13];
    static int	    offset;
    static int	    i, j, tmp;
    unsigned int    crc, crc1;
    int		    oldgrp, newgrp;

    clr_index();
    working(1, 0, 0);
    IsDoing("Edit MessageGroup");

    snprintf(mfile, PATH_MAX, "%s/etc/mgroups.temp", getenv("MBSE_ROOT"));
    if ((fil = fopen(mfile, "r")) == NULL) {
	working(2, 0, 0);
	return -1;
    }

    offset = sizeof(mgrouphdr) + ((Area -1) * sizeof(mgroup));
    if (fseek(fil, offset, 0) != 0) {
	working(2, 0, 0);
	return -1;
    }

    fread(&mgroup, sizeof(mgroup), 1, fil);
    fclose(fil);
    crc = 0xffffffff;
    crc = upd_crc32((char *)&mgroup, crc, sizeof(mgroup));
    MgScreen();
	
    for (;;) {
	set_color(WHITE, BLACK);
	show_str(  7,16,12, mgroup.Name);
	show_str(  8,16,55, mgroup.Comment);
	show_str(  9,16,64, mgroup.BasePath);
	show_sec( 10,16,    mgroup.RDSec);
	show_sec( 11,16,    mgroup.WRSec);
	show_sec( 12,16,    mgroup.SYSec);
	mbse_mvprintw( 13,22,    getflag(mgroup.LinkSec.flags, mgroup.LinkSec.notflags));
	show_int( 14,16,    mgroup.StartArea);
	show_int( 15,16,    mgroup.NetReply);
	show_bool(16,16,    mgroup.UsrDelete);
	show_bool(17,16,    mgroup.Aliases);
	show_bool(18,16,    mgroup.Quotes);
	show_bool(19,16,    mgroup.Active);

	show_bool(14,42,    mgroup.Deleted);
	show_bool(15,42,    mgroup.AutoChange);
	show_bool(16,42,    mgroup.UserChange);
	show_aka( 17,42,    mgroup.UseAka);
	show_aka( 18,42,    mgroup.UpLink);
	show_str( 19,42,12, mgroup.AreaFile);

	show_charset(14,70, mgroup.Charset);
	snprintf(temp, 5, "#%03d", mgroup.GoldEDgroup);
	show_str( 15,70, 5, temp);

	j = select_menu(21);
	switch(j) {
	    case 0: if (!mgroup.StartArea && strlen(mgroup.AreaFile)) {
			errmsg("Areas file defined but no BBS start area");
		        break;
		    }
		    crc1 = 0xffffffff;
		    crc1 = upd_crc32((char *)&mgroup, crc1, sizeof(mgroup));
		    if (crc != crc1) {
			if (yes_no((char *)"Record is changed, save") == 1) {
			    working(1, 0, 0);
			    if ((fil = fopen(mfile, "r+")) == NULL) {
				WriteError("$Can't reopen %s", mfile);
				working(2, 0, 0);
				return -1;
			    }
			    fseek(fil, offset, 0);
			    fwrite(&mgroup, sizeof(mgroup), 1, fil);
			    fclose(fil);
			    MGrpUpdated = 1;
			    working(6, 0, 0);
			}
		    }
		    IsDoing("Browsing Menu");
		    return 0;
	    case 1: if (CheckMgroup())
			break;
		    strcpy(mgroup.Name, edit_str(7,16,12, mgroup.Name, (char *)"The ^name^ for this message group"));
		    if (strlen(mgroup.BasePath) == 0) {
		        memset(&temp, 0, sizeof(temp));
		        strcpy(temp, mgroup.Name);
		        for (i = 0; i < strlen(temp); i++) {
			    if (temp[i] == '.')
				temp[i] = '/';
			    if (isupper(temp[i]))
			        temp[i] = tolower(temp[i]);
			}
		        snprintf(mgroup.BasePath, 65, "%s/var/mail/%s", getenv("MBSE_ROOT"), temp);
		    }
		    break;
	    case 2: E_STR(  8,16,55, mgroup.Comment,    "The ^desription^ for this message group")
	    case 3: E_PTH(  9,16,64, mgroup.BasePath,   "The ^Base path^ where new JAM areas are created", 0770)
	    case 4: E_SEC( 10,16,    mgroup.RDSec,      "9.1.4 MESSAGE GROUP READ SECURITY", MgScreen)
	    case 5: E_SEC( 11,16,    mgroup.WRSec,      "9.1.5 MESSAGE GROUP WRITE SECURITY", MgScreen)
	    case 6: E_SEC( 12,16,    mgroup.SYSec,      "9.1.6 MESSAGE GROUP SYSOP SECURITY", MgScreen)
	    case 7: mgroup.LinkSec = edit_asec(mgroup.LinkSec, (char *)"9.1.7 DEFAULT SECURITY FOR NEW AREAS");
		    MgScreen();
		    break;
	    case 8: E_INT( 14,16,    mgroup.StartArea,  "The ^Start area number^ from where to add areas")
	    case 9: E_INT( 15,16,    mgroup.NetReply,   "The ^Area Number^ for netmail replies")
	    case 10:E_BOOL(16,16,    mgroup.UsrDelete,  "Allow users to ^Delete^ their messages")
	    case 11:E_BOOL(17,16,    mgroup.Aliases,    "Allow ^Aliases^ or real names only")
	    case 12:E_BOOL(18,16,    mgroup.Quotes,     "Allow random ^quotes^ to new messages")
	    case 13:if (mgroup.Active && CheckMgroup())
		        break;
		    E_BOOL(19,16,    mgroup.Active,     "Is this message group ^active^")
	    case 14:if (CheckMgroup())
		        break;
		    E_BOOL(14,42,    mgroup.Deleted,    "Is this group ^Deleted^")
	    case 15:E_BOOL(15,42,    mgroup.AutoChange, "^Auto change^ areas from new areas lists")
	    case 16:tmp = edit_bool(16,42, mgroup.UserChange, (char *)"^Auto add/delete^ areas from downlinks requests");
		    if (tmp && !mgroup.UpLink.zone)
		        errmsg("It looks like you are the toplevel, no Uplink defined");
		    else
		        mgroup.UserChange = tmp;
		    break;
	    case 17:tmp = PickAka((char *)"9.1.17", TRUE);
		    if (tmp != -1)
		    	memcpy(&mgroup.UseAka, &CFG.aka[tmp], sizeof(fidoaddr));
		    MgScreen();
		    break;
	    case 18:mgroup.UpLink = PullUplink((char *)"9.1.18");
		    MgScreen();
		    break;
	    case 19:E_STR( 19,42,12, mgroup.AreaFile,   "The name of the ^Areas File^ from the uplink (case sensitive)")
	    case 20:mgroup.Charset = edit_charset(14, 70, mgroup.Charset);
		    break;
	    case 21:oldgrp = mgroup.GoldEDgroup;
		    newgrp = edit_int(15, 70, oldgrp, (char *)"The new groupnumber for the ^GoldED groups^ (1..999)");
		    if ((newgrp < 1) || (newgrp > 999)) {
			errmsg("Groupnumber must be between 1 and 999");
		    } else if (newgrp && (newgrp != oldgrp)) {
			if (gedgrps[newgrp] == 1) {
			    errmsg("This groupnumber is already in use");
			} else {
			    gedgrps[oldgrp] = 0;
			    gedgrps[newgrp] = 1;
			    mgroup.GoldEDgroup = newgrp;
			}
		    }
		    break;
	}
    }

    return 0;
}
Exemple #5
0
/*
 * Edit one record, return -1 if there are errors, 0 if ok.
 */
int EditFidoRec(int Area)
{
    FILE	    *fil;
    char	    mfile[PATH_MAX], *temp;
    int		    offset;
    int		    i, j = 0;
    unsigned int    crc, crc1;

    clr_index();
    working(1, 0, 0);
    IsDoing("Edit Fidonet");

    snprintf(mfile, PATH_MAX, "%s/etc/fidonet.temp", getenv("MBSE_ROOT"));
    if ((fil = fopen(mfile, "r")) == NULL) {
	working(2, 0, 0);
	return -1;
    }

    offset = sizeof(fidonethdr) + ((Area -1) * sizeof(fidonet));
    if (fseek(fil, offset, 0) != 0) {
	working(2, 0, 0);
	return -1;
    }

    fread(&fidonet, sizeof(fidonet), 1, fil);
    fclose(fil);
    crc = 0xffffffff;
    crc = upd_crc32((char *)&fidonet, crc, sizeof(fidonet));

    set_color(WHITE, BLACK);
    mbse_mvprintw( 5, 6, "2.  EDIT FIDONET NETWORK");
    set_color(CYAN, BLACK);
    mbse_mvprintw( 7, 6, "1.  Comment");
    mbse_mvprintw( 8, 6, "2.  Domain name");
    mbse_mvprintw( 9, 6, "3.  Available");
    mbse_mvprintw(10, 6, "4.  Deleted");
    mbse_mvprintw(11, 6, "5.  Main Nodelist");
    mbse_mvprintw(12, 6, "6.  Merge list #1");
    mbse_mvprintw(13, 6, "7.  Merge list #2");
    mbse_mvprintw(14, 6, "8.  Merge list #3");
    mbse_mvprintw(15, 6, "9.  Merge list #4");
    mbse_mvprintw(16, 6, "10. Merge list #5");
    mbse_mvprintw(17, 6, "11. Merge list #6");
    mbse_mvprintw(12,55, "12. Primary zone");
    mbse_mvprintw(13,55, "13. Zone number #2");
    mbse_mvprintw(14,55, "14. Zone number #3");
    mbse_mvprintw(15,55, "15. Zone number #4");
    mbse_mvprintw(16,55, "16. Zone number #5");
    mbse_mvprintw(17,55, "17. Zone number #6");
    temp = calloc(18, sizeof(char));

    for (;;) {
	set_color(WHITE, BLACK);
	show_str( 7,26,40, fidonet.comment);
	show_str( 8,26,8,  fidonet.domain);
	show_bool(9,26,    fidonet.available);
	show_bool(10,26,   fidonet.deleted);
	show_str(11,26,8,  fidonet.nodelist);
	for (i = 0; i < 6; i++) {
	    if ((fidonet.seclist[i].zone) || strlen(fidonet.seclist[i].nodelist)) {
		show_str(i + 12,26,8, fidonet.seclist[i].nodelist);
		snprintf(temp, 18, "%d:%d/%d", fidonet.seclist[i].zone, fidonet.seclist[i].net, fidonet.seclist[i].node);
		show_str(i + 12, 36,17, temp);
	    } else 
		show_str(i + 12,26,27, (char *)"                           ");
	    show_int(i + 12,74, fidonet.zone[i]);
	}

	j = select_menu(17);
	switch(j) {
	    case 0: if (fidonet.available && fidonet.deleted)
			fidonet.available = FALSE;
		    if (fidonet.available && (strlen(fidonet.domain) == 0)) {
			errmsg("You must fill in a valid domain name");
			break;
		    }
		    if (fidonet.available && (fidonet.zone[0] == 0)) {
			errmsg("The network must have a main zone number");
			break;
		    }
		    if (fidonet.available && (strlen(fidonet.nodelist) == 0)) {
			errmsg("You must fill in a nodelist for this network");
			break;
		    }
		    crc1 = 0xffffffff;
		    crc1 = upd_crc32((char *)&fidonet, crc1, sizeof(fidonet));
		    if (crc != crc1) {
			if (yes_no((char *)"Record is changed, save") == 1) {
			    working(1, 0, 0);
			    if ((fil = fopen(mfile, "r+")) == NULL) {
				working(2, 0, 0);
				free(temp);
				return -1;
			    }
			    fseek(fil, offset, 0);
			    fwrite(&fidonet, sizeof(fidonet), 1, fil);
			    fclose(fil);
			    FidoUpdated = 1;
			    working(6, 0, 0);
			}
		    }
		    IsDoing("Browsing Menu");
		    free(temp);
		    return 0;
	    case 1: E_STR(7,26,40, fidonet.comment, "The ^Comment^ for this network name")
	    case 2: E_STR(8, 26,8, fidonet.domain, "The ^Name^ of the network without dots")
	    case 3: E_BOOL(9,26, fidonet.available, "Is this network ^Available^ for use")
	    case 4: E_BOOL(10,26, fidonet.deleted,   "Is this netword ^Deleted^")
	    case 5: E_STR(11,26,8, fidonet.nodelist, "The name of the ^Primary Nodelist^ for this network")
	    case 6:
	    case 7:
	    case 8:
	    case 9:
	    case 10:
	    case 11: strcpy(fidonet.seclist[j-6].nodelist, 
			    edit_str(j+6,26,8, fidonet.seclist[j-6].nodelist, 
				(char *)"The secondary ^nodelist^ or ^pointlist^ name for this domain"));
		    if (strlen(fidonet.seclist[j-6].nodelist)) {
			do {
			    snprintf(temp, 18, "%d:%d/%d", fidonet.seclist[j-6].zone, 
				    fidonet.seclist[j-6].net, fidonet.seclist[j-6].node);
			    strcpy(temp, edit_str(j+6,36,17, temp, 
					(char *)"The top ^fidonet aka^ for this nodelist (zone:net/node)"));
			    if ((strstr(temp, ":") == NULL) || (strstr(temp, "/") == NULL)) {
				working(2, 0, 0);
			    }
			} while ((strstr(temp, ":") == NULL) || (strstr(temp, "/") == NULL));
			fidonet.seclist[j-6].zone = atoi(strtok(temp, ":"));
			fidonet.seclist[j-6].net  = atoi(strtok(NULL, "/"));
			fidonet.seclist[j-6].node = atoi(strtok(NULL, ""));
		    } else {
			fidonet.seclist[j-6].zone = 0;
			fidonet.seclist[j-6].net  = 0;
			fidonet.seclist[j-6].node = 0;
		    }
		    break;
	    case 12:
	    case 13:
	    case 14:
	    case 15:
	    case 16:
	    case 17:E_IRC(j,74, fidonet.zone[j-12], 0, 32767, "A ^Zone number^ which belongs to this domain (1..32767)")
	}
    }

    return 0;
}
Exemple #6
0
void ImportOneline(void)
{
    FILE    *Imp, *pOneline;
    int	    recno = 0, skipped = 0;
    struct  tm *l_date;
    char    *temp, buf[12];
    time_t  Time;

    clr_index();
    set_color(WHITE, BLACK);
    ftnd_mvprintw(5, 6, "8.7.3  IMPORT ONELINERS");
    set_color(CYAN, BLACK);
    temp = calloc(PATH_MAX, sizeof(char));
    memset(temp, 0, sizeof(temp));
    strcpy(temp, edit_str(21, 6,64, temp, (char *)"The ^full path and filename^ of the file to import"));
    if (strlen(temp) == 0) {
	free(temp);
	return;
    }

    working(1, 0, 0);
    if (config_read() == -1) {
	working(2, 0, 0);
	free(temp);
	return;
    }

    if ((Imp = fopen(temp, "r")) == NULL) {
	working(2, 0, 0);
	ftnd_mvprintw(21, 6, temp);
	readkey(22, 6, LIGHTGRAY, BLACK);
	free(temp);
	return;
    }

    snprintf(temp, PATH_MAX, "%s/etc/oneline.data", getenv("FTND_ROOT"));

    /*
     * Check if database exists, if not create a new one
     */
    if ((pOneline = fopen(temp, "r" )) == NULL) {
	if ((pOneline = fopen(temp, "w")) != NULL) {
	    olhdr.hdrsize = sizeof(olhdr);
	    olhdr.recsize = sizeof(ol);
	    fwrite(&olhdr, sizeof(olhdr), 1, pOneline);
	    fclose(pOneline);
	}
    } else
	fclose(pOneline);

    /*
     * Open database for appending
     */
    if ((pOneline = fopen(temp, "a+")) == NULL) {
	working(2, 0, 0);
	fclose(Imp);
	ftnd_mvprintw(21, 6, temp);
	readkey(22, 6, LIGHTGRAY, BLACK);
	free(temp);
	return;
    }

    Time = time(NULL);
    l_date = localtime(&Time);
    snprintf(buf, 12, "%02d-%02d-%04d", l_date->tm_mday, l_date->tm_mon+1, l_date->tm_year+1900);

    while ((fgets(temp, 80, Imp)) != NULL) {
	Striplf(temp);
	if ((strlen(temp) > 0) && (strlen(temp) < 69)) {
	    memset(&ol, 0, sizeof(ol));
	    strcpy(ol.Oneline, temp);
	    strcpy(ol.UserName, CFG.sysop_name);
	    strcpy(ol.DateOfEntry, buf);
	    ol.Available = TRUE;
	    fwrite(&ol, sizeof(ol), 1, pOneline);
	    recno++;
	} else {
	    skipped++;
	}
    }

    fclose(Imp);
    fclose(pOneline);

    snprintf(temp, 81, "Imported %d oneliners, skipped %d long/empty lines", recno, skipped);
    Syslog('+', temp);
    ftnd_mvprintw(21, 6, temp);
    readkey(21, 7 + strlen(temp), LIGHTGRAY, BLACK);
    free(temp);
}