Example #1
0
File: mball.c Project: bbs-io/mbse
void WriteFiles(FILE *fp, FILE *fu, FILE *np, FILE *nu, int New, char *temp)
{
    fprintf(fp, "%s\r\n", temp);
    fprintf(fu, "%s\r\n", chartran(temp));
    if (New) {
	fprintf(np, "%s\r\n", temp);
	fprintf(nu, "%s\r\n", chartran(temp));
    }
}
Example #2
0
File: mball.c Project: bbs-io/mbse
void MidLine(char *txt, FILE *fp, FILE *up, int doit)
{
    char    temp[256];
    int	    x, y, z;

    if (!doit)
	return;

    z = strlen(txt);
    x = 77 - z;
    x /= 2;
    strcpy(temp, "\xB3");

    for (y = 0; y < x; y++)
	strcat(temp, " ");

    strncat(temp, txt, 255);

    for (y = strlen(temp); y < 78; y++)
	strncat(temp, " ", 255);

    strncat(temp, "\xB3\r\n", 255);
    fprintf(fp, temp);
    fprintf(up, chartran(temp));
}
Example #3
0
File: fsedit.c Project: bbs-io/mbse
void Hl(int y, char *txt)
{
    Ls(y);
    strncat(hstr, colour_str(WHITE, BLUE), 80);
    strncat(hstr, padleft(txt, 58, ' '), 80);
    Rs();
    PUTSTR(chartran(hstr));
}
Example #4
0
int charwrite(char *s, FILE *fp)
{
    char    temp[2048];

    if ((strlen(s) >= 3) && (strncmp(s,"---",3) == 0) && (s[3] != '-')) {
	 putc('-',fp);
	 putc(' ',fp);
    }

    strncpy(temp, chartran(s), sizeof(temp) -1);
    fputs(temp, fp);
     
    return 0;
}
Example #5
0
File: mball.c Project: bbs-io/mbse
void BotBox(FILE *fp, FILE *up, int doit)
{
    int		y;
    char	temp[256];

    if (!doit)
	return;

    strcpy(temp, "\xC0");
    for (y = 0; y < 77; y++)
	strncat(temp, "\xC4", 255);
    strncat(temp, "\xD9\r\n\r\n", 255);
    fprintf(fp, temp);
    fprintf(up, chartran(temp));
}
Example #6
0
int StartMsg(void)
{
    Syslog('m', "StartMsg()");
    if (!Msg_Open(newfiles.Area))
	return -1;

    if (!Msg_Lock(30L)) {
	Msg_Close();
	return -1;
    }
    Msg_New();

    CountPosted(newfiles.Area);

    chartran_init((char *)"CP437", get_ic_ftn(newfiles.charset), 'f');

    snprintf(Msg.From, 101, "%s", chartran(newfiles.From));
    snprintf(Msg.To, 101, "%s", chartran(newfiles.Too));
    if (MsgCount == 1) {
	snprintf(Msg.Subject, 101, "%s", chartran(newfiles.Subject));
	TotalSize = TotalFiles = 0;
    } else
	snprintf(Msg.Subject, 101, "%s #%d", chartran(newfiles.Subject), MsgCount);
    snprintf(Msg.FromAddress, 101, "%s", aka2str(newfiles.UseAka));
    Msg.Written = time(NULL);
    Msg.Arrived = time(NULL);
    Msg.Local = TRUE;
    Msg.Echomail = TRUE;

    /*
     * Start message text including kludges
     */
    Msg_Id(newfiles.UseAka);
    Msg_Pid(newfiles.charset);
    return Msg_Top(newfiles.Template, newfiles.Language, newfiles.UseAka);
}
Example #7
0
File: fsedit.c Project: bbs-io/mbse
void Full_Help(void)
{
    strcpy(hstr, colour_str(LIGHTGREEN, BLUE));

    /* Top row */
    strncat(hstr, locate_str(1, 10), 80);
    strncat(hstr, (char *)"\xDA", 80);
    strncat(hstr, hLine_str(58), 80);
    strncat(hstr, (char *)"\xBF", 80);
    PUTSTR(chartran(hstr));

    Ws(2);
    PUTSTR(chartran(hstr));

    Ls(3);
    strncat(hstr, colour_str(YELLOW, BLUE), 80);
    strncat(hstr, padleft((char *)"                  Editor Help", 58, ' '), 80);
    Rs();
    PUTSTR(chartran(hstr));

    Ws(4);
    PUTSTR(chartran(hstr));

    Hl( 5, (char *)"Ctrl-S or LeftArrow     - Cursor left");
    Hl( 6, (char *)"Ctrl-D or RightArrow    - Cursor right");
    Hl( 7, (char *)"Ctrl-E or UpArrow       - Cursor up");
    Hl( 8, (char *)"Ctrl-X or DownArrow     - Cursor down");
    Hl( 9, (char *)"Ctrl-V or Insert        - Insert or Overwrite");
    Hl(10, (char *)"Ctrl-N                  - Insert line");
    Hl(11, (char *)"Ctrl-Y                  - Delete line");
    Ws(12);
    PUTSTR(chartran(hstr));
    Hl(13, (char *)"Ctrl-L                  - Refresh screen");
    Hl(14, (char *)"Ctrl-R                  - Read from file");
    Ws(15);
    PUTSTR(chartran(hstr));

    strcpy(hstr, locate_str(16,10));
    strncat(hstr, (char *)"\xC0", 80);
    strncat(hstr, hLine_str(58), 80);
    strncat(hstr, (char *)"\xD9", 80);
    PUTSTR(chartran(hstr));
}
Example #8
0
void DisplayLogo()
{
    FILE	*pLogo;
    char	*sString, *temp;

    temp = calloc(PATH_MAX, sizeof(char));
    sString = calloc(1024, sizeof(char));

    snprintf(temp, PATH_MAX, "%s/share/int/txtfiles/%s/%s", getenv("FTND_ROOT"), CFG.deflang, CFG.welcome_logo);
    if ((pLogo = fopen(temp,"rb")) == NULL)
	WriteError("$DisplayLogo: Can't open %s", temp);
    else {
	while (Fgets(sString, 1023, pLogo) != NULL) {
	    PUTSTR(chartran(sString));
	    Enter(1);
	}
	fclose(pLogo);
    }

    free(sString);
    free(temp);
}
Example #9
0
File: file.c Project: bbs-io/mbse
/*
 * Edit the list of tagged files.
 */
void EditTaglist()
{
    FILE    *tf;
    int	    i, x, Fg, Count;
    char    *temp;

    if ((tf = fopen("taglist", "r+")) == NULL) {
	Enter(1);
	/* No files tagged. */
	pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(361));
	Enter(2);
	Pause();
	return;
    }

    temp = calloc(81, sizeof(char));
    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'B');

    while (TRUE) {
	clear();
	fseek(tf, 0, SEEK_SET);
	Count = 0;
	/*   #  Area Active     Size  Cost File */
	/* 123 12345 123456 12345678 12345 */
	pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(355));
	Enter(1);
	colour(LIGHTGREEN, BLACK);
	PUTSTR(chartran(fLine_str(79)));

	while ((fread(&Tag, sizeof(Tag), 1, tf) == 1)) {
	    Count++;

	    if (Tag.Active)
		Fg = WHITE;
	    else
		Fg = LIGHTGRAY;

	    snprintf(temp, 81, "%3d ", Count);
	    pout(Fg, BLACK, temp);

	    Fg--;
	    snprintf(temp, 81, "%5d ", Tag.Area);
	    pout(Fg, BLACK, temp);

	    Fg--;
	    if (Tag.Active)
		/* Yes */
		snprintf(temp, 81, "%-6s ", (char *) Language(356));
	    else
		/* No */
		snprintf(temp, 81, "%-6s ", (char *) Language(357));
	    pout(Fg, BLACK, temp);

	    Fg--;
	    snprintf(temp, 81, "%8d ", (int)(Tag.Size));
	    pout(Fg, BLACK, temp);

	    Fg--;
	    snprintf(temp, 81, "%5d ", Tag.Cost);
	    pout(Fg, BLACK, temp);

	    Fg--;
	    snprintf(temp, 81, "%s", Tag.LFile);
	    pout(Fg, BLACK, temp);

	    Enter(1);
	}
	colour(LIGHTGREEN, BLACK);
	PUTSTR(chartran(fLine_str(79)));

	/* (T)oggle active, (E)rase all, (ENTER) to continue: */
	pout(WHITE, RED, (char *) Language(358));

	i = toupper(Readkey());
	colour(CFG.CRColourF, CFG.CRColourB);

	if (i == Keystroke(358, 0)) {
	    Enter(2);
	    /* Enter file number, 1.. */
	    snprintf(temp, 81, "%s%d ", (char *) Language(359), Count);
	    PUTSTR(temp);

	    GetstrC(temp, 5);
	    x = atoi(temp);

	    if ((x > 0) && (x <= Count)) {
		if (fseek(tf, (x - 1) * sizeof(Tag), SEEK_SET) == 0) {
		    if (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
			if (Tag.Active)
			    Tag.Active = FALSE;
			else
			    Tag.Active = TRUE;

			fseek(tf,(x - 1) * sizeof(Tag), SEEK_SET);
			fwrite(&Tag, sizeof(Tag), 1, tf);
		    }
		}
	    }
	}

	chartran_close();

	if (i == Keystroke(358, 1)) {
	    fclose(tf);
	    unlink("taglist");
	    free(temp);
	    return;
	}

	if ((i == '\r') || (i == '\n')) {
	    fclose(tf);
	    free(temp);
	    return;
	}
    }
}
Example #10
0
File: file.c Project: bbs-io/mbse
/*
 * Show filelist from current area, called from the menu.
 */
void File_List()
{
    int		    FileCount = 0;
    unsigned	    FileBytes = 0;
    _Tag	    T;
    struct _fdbarea *fdb_area = NULL;
    char	    temp[81];

    iLineCount = 0;
    WhosDoingWhat(FILELIST, NULL);

    Syslog('+', "Listing File Area # %d", iAreaNumber);

    if (Access(exitinfo.Security, area.LTSec) == FALSE) {
	Enter(1);
	/* You don't have enough security to list this area */
	pout(YELLOW, BLACK, (char *) Language(236));
	Enter(2);
	Pause();
	return;
    }

    InitTag();

    if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL)
	return;

    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'b');

    clear();
    Header();
    if (iLC(2) == 1) {
	mbsedb_CloseFDB(fdb_area);
	chartran_close();
	return;
    }

    while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
	memset(&T, 0, sizeof(T));
	T.Area   = iAreaNumber;
	T.Active = FALSE;
	T.Size   = fdb.Size;
	strncpy(T.SFile, fdb.Name, 12);
	strncpy(T.LFile, chartran(fdb.LName), 80);
	SetTag(T);

	if (ShowOneFile() == 1) {
	    mbsedb_CloseFDB(fdb_area);
	    chartran_close();
	    return;
	}

	if (fdb.Deleted) {
	    /* D E L E T E D */ /* Uploaded by: */
	    snprintf(temp, 81, " -- %-12s     %s     [%4d] %s%s\n", fdb.Name, (char *) Language(239), 
				fdb.TimesDL, (char *) Language(238), fdb.Uploader);
	    PUTSTR(temp);
	}

	FileCount++;			/* Increase File Counter by 1 */
	FileBytes += fdb.Size;		/* Increase File Byte Count   */
    }

    Mark();
	
    Enter(1);
    /* Total Files: */
    snprintf(temp, 81, "%s%d / %d bytes", (char *) Language(242), FileCount, FileBytes);
    pout(LIGHTCYAN, BLACK, temp);
    Enter(2);
    chartran_close();

    iLineCount = 0;
    mbsedb_CloseFDB(fdb_area);
    Pause();
}
Example #11
0
File: pinfo.c Project: bbs-io/mbse
/*
 * Product information screen
 */
void cr(void)
{
    char    *temp;

    temp       = calloc(81, sizeof(char));

    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'B');

    strncpy(pstr, clear_str(), 255);
    strncat(pstr, colour_str(DARKGRAY, BLACK), 255);

    /* Print top row */
    strncat(pstr, (char *)"\xDA", 255);
    strncat(pstr, hLine_str(76), 255);
    strncat(pstr, (char *)"\xBF\r\n", 255);
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    snprintf(temp, 80, "MBSE Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU());
    strncat(pstr, pout_str(YELLOW, BLACK, padleft(temp, 76, ' ')), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    snprintf(temp, 81, "%s", COPYRIGHT);
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, padleft(temp, 76, ' ')), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    snprintf(temp, 81, "Compiled on %s at %s", __DATE__, __TIME__);
    strncat(pstr, pout_str(LIGHTRED, BLACK, padleft(temp, 76, ' ')), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"MBSE has been written and designed by Michiel Broek. Many others have given "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"valuable time in the form of new ideas and suggestions on how to make MBSE  "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"BBS a better BBS                                                            "), 255);
    rs();
    PUTSTR(chartran(pstr));
    
    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(WHITE, BLACK, (char *)"Available from http://www.mbse.eu or 2:280/2802                             "), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner,              "),
 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"                          Mats Birch, Mats Wallin.                          "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"                          ALL RIGHTS RESERVED.                              "), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTBLUE, BLACK,  (char *)"This is free software; released under the terms of the GNU General Public   "), 255);
    rs();
    PUTSTR(chartran(pstr));

    ls();
    strncat(pstr, pout_str(LIGHTBLUE, BLACK,  (char *)"License as published by the Free Software Foundation.                       "), 255);
    rs();
    PUTSTR(chartran(pstr));

    wl();
    PUTSTR(chartran(pstr));

    strcpy(pstr, (char *)"\xC0");
    strncat(pstr, hLine_str(76), 255);
    strncat(pstr, (char *)"\xD9\r\n", 255);
    PUTSTR(chartran(pstr));

    free(temp);
    chartran_close();
    Enter(1);
    Pause();
}
Example #12
0
File: mball.c Project: bbs-io/mbse
void Masterlist()
{
    FILE	    *fp, *np, *fu, *nu, *pAreas, *pHeader;
    int		    AreaNr = 0, z, x = 0, New;
    unsigned int    AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
    unsigned int    AllAreaFiles, AllAreaBytes, popdown, down, NewAreaFiles, NewAreaBytes;
    char	    *sAreas, temp[PATH_MAX], pop[81];
    struct _fdbarea *fdb_area = NULL;

    sAreas	= calloc(PATH_MAX, sizeof(char));

    IsDoing("Create Allfiles list");

    snprintf(sAreas, PATH_MAX, "%s/etc/fareas.data", getenv("MBSE_ROOT"));

    if(( pAreas = fopen (sAreas, "r")) == NULL) {
	WriteError("Can't open File Areas File: %s", sAreas);
	mbse_colour(LIGHTGRAY, BLACK);
	die(MBERR_GENERAL);
    }
    fread(&areahdr, sizeof(areahdr), 1, pAreas);

    if (!do_quiet)
	printf("Processing file areas\n");

    if ((fp = fopen("allfiles.tmp", "a+")) == NULL) {
 	WriteError("$Can't open allfiles.tmp");
	die(MBERR_GENERAL);
    }
    if ((np = fopen("newfiles.tmp", "a+")) == NULL) {
	WriteError("$Can't open newfiles.tmp");
	fclose(fp);
	die(MBERR_GENERAL);
    }
    if ((fu = fopen("allfiles.ump", "a+")) == NULL) {
	WriteError("$Can't open allfiles.ump");
	fclose(fp);
	fclose(np);
	die(MBERR_GENERAL);
    }
    if ((nu = fopen("newfiles.ump", "a+")) == NULL) {
	WriteError("$Can't open newfiles.ump");
	fclose(fp);
	fclose(np);
	fclose(fu);
	die(MBERR_GENERAL);
    }

    chartran_init((char *)"CP437", (char *)"UTF-8", 'B');

    TopBox(fp, fu, TRUE);
    TopBox(np, nu, TRUE);
    snprintf(temp, 81, "All available files at %s", CFG.bbs_name);
    MidLine(temp, fp, fu, TRUE);
    snprintf(temp, 81, "New available files since %d days at %s", CFG.newdays, CFG.bbs_name);
    MidLine(temp, np, nu, TRUE);
    BotBox(fp, fu, TRUE);
    BotBox(np, nu, TRUE);

    snprintf(temp, PATH_MAX, "%s/etc/header.txt", getenv("MBSE_ROOT"));
    if (( pHeader = fopen(temp, "r")) != NULL) {
	Syslog('+', "Inserting %s", temp);

	while( fgets(temp, 80 ,pHeader) != NULL) {
	    Striplf(temp);
	    fprintf(fp, "%s\r\n", temp);
	    fprintf(np, "%s\r\n", temp);
	    fprintf(fu, "%s\r\n", chartran(temp));
	    fprintf(nu, "%s\r\n", chartran(temp));
	}
	fclose(pHeader);
    }

    while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
	AreaNr++;
	AllAreaFiles = 0;
	AllAreaBytes = 0;
	NewAreaFiles = 0;
	NewAreaBytes = 0;

	if (area.Available && (area.LTSec.level <= CFG.security.level)) {

	    Nopper();

	    if ((fdb_area = mbsedb_OpenFDB(AreaNr, 30)) == 0) {
		WriteError("Can't open Area %d (%s)! Skipping ...", AreaNr, area.Name);
	    } else {
		popdown = 0;
		while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
		    if (!fdb.Deleted) {
			/*
			 * The next is to reduce system load.
			 */
			x++;
			if (CFG.slow_util && do_quiet && ((x % 3) == 0))
			    msleep(1);
			AllFiles++;
			AllAreaFiles++;
			AllAreaBytes += fdb.Size;
			down = fdb.TimesDL;
			if (down > popdown) {
			    popdown = down;
			    snprintf(pop, 81, "%s", fdb.Name);
			}
			if (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays) {
			    NewFiles++;
			    NewAreaFiles++;
			    NewAreaBytes += fdb.Size;
			}
		    }
		}

		AllKBytes += AllAreaBytes / 1024;
		NewKBytes += NewAreaBytes / 1024;
				
		/*
		 * If there are files to report do it.
		 */
		if (AllAreaFiles) {
		    TopBox(fp, fu, TRUE);
		    TopBox(np, nu, NewAreaFiles);

		    snprintf(temp, 81, "Area %d - %s", AreaNr, area.Name);
		    MidLine(temp, fp, fu, TRUE);
		    MidLine(temp, np, nu, NewAreaFiles);

		    snprintf(temp, 81, "File Requests allowed");
		    MidLine(temp, fp, fu, area.FileReq);
		    MidLine(temp, np, nu, area.FileReq && NewAreaFiles);

		    snprintf(temp, 81, "%d KBytes in %d files", AllAreaBytes / 1024, AllAreaFiles);
		    MidLine(temp, fp, fu, TRUE);
		    snprintf(temp, 81, "%d KBytes in %d files", NewAreaBytes / 1024, NewAreaFiles);
		    MidLine(temp, np, nu, NewAreaFiles);
		    if (popdown) {
			snprintf(temp, 81, "Most popular file is %s", pop);
			MidLine(temp, fp, fu, TRUE);
		    }

		    BotBox(fp, fu, TRUE);
		    BotBox(np, nu, NewAreaFiles);

		    fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
		    while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
			if (!fdb.Deleted) {
			    New = (((t_start - fdb.UploadDate) / 84400) <= CFG.newdays);

			    snprintf(temp, 81, "%s", fdb.LName);
			    WriteFiles(fp, fu, np, nu, New, temp);

			    snprintf(temp, 81, "%-12s%10u K %s [%04d] Uploader: %s", 
				fdb.Name, (int)(fdb.Size / 1024), StrDateDMY(fdb.UploadDate), fdb.TimesDL, 	 
				strlen(fdb.Uploader)?fdb.Uploader:"");
			    WriteFiles(fp, fu, np, nu, New, temp);

			    for (z = 0; z < 25; z++) {
				if (strlen(fdb.Desc[z])) {
				    if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) {
					snprintf(temp, 81, "                         %s", fdb.Desc[z]+4);
				    } else {
					snprintf(temp, 81, "                         %s", fdb.Desc[z]);
				    }
				    WriteFiles(fp, fu, np, nu, New, temp);
				}
			    }

			    if (strlen(fdb.Magic)) {
				snprintf(temp, 81, "                         Magic filerequest: %s", fdb.Magic);
				WriteFiles(fp, fu, np, nu, New, temp);
			    }
			    WriteFiles(fp, fu, np, nu, New, (char *)"");
			}
		    }
		}
		mbsedb_CloseFDB(fdb_area);
    		}
	}
    } /* End of While Loop Checking for Areas Done */

    fclose(pAreas);

    TopBox(fp, fu, TRUE);
    TopBox(np, nu, TRUE);
    snprintf(temp, 81, "Total %d files, %d KBytes", AllFiles, AllKBytes);
    MidLine(temp, fp, fu, TRUE);
    snprintf(temp, 81, "Total %d files, %d KBytes", NewFiles, NewKBytes);
    MidLine(temp, np, nu, TRUE);

    MidLine((char *)"", fp, fu, TRUE);
    MidLine((char *)"", np, nu, TRUE);

    snprintf(temp, 81, "Created by MBSE BBS v%s (%s-%s) at %s", VERSION, OsName(), OsCPU(), StrDateDMY(t_start));
    MidLine(temp, fp, fu, TRUE);
    MidLine(temp, np, nu, TRUE);

    BotBox(fp, fu, TRUE);
    BotBox(np, nu, TRUE);

    snprintf(temp, PATH_MAX, "%s/etc/footer.txt", getenv("MBSE_ROOT"));
    if(( pHeader = fopen(temp, "r")) != NULL) {
	Syslog('+', "Inserting %s", temp);

	while( fgets(temp, 80 ,pHeader) != NULL) {
	    Striplf(temp);
	    fprintf(fp, "%s\r\n", temp);
	    fprintf(np, "%s\r\n", temp);
	    fprintf(fu, "%s\r\n", chartran(temp));
	    fprintf(nu, "%s\r\n", chartran(temp));
	}
	fclose(pHeader);
    }

    fclose(fp);
    fclose(np);
    fclose(fu);
    fclose(nu);
    chartran_close();

    if ((rename("allfiles.tmp", "allfiles.txt")) == 0)
	unlink("allfiles.tmp");
    if ((rename("newfiles.tmp", "newfiles.txt")) == 0)
	unlink("newfiles.tmp");
    if ((rename("allfiles.ump", "allfiles.utf")) == 0)
	unlink("allfiles.ump");
    if ((rename("newfiles.ump", "newfiles.utf")) == 0)
	unlink("newfiles.ump");

    Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
    Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
    free(sAreas);
}
Example #13
0
File: email.c Project: bbs-io/mbse
int Read_a_Email(unsigned int Num)
{
    char        *p = NULL, *fn, *charset = NULL, *charsin = NULL;
    lastread    LR;
    unsigned int	mycrc;

    LastNum = Num;
    iLineCount = 7;
    WhosDoingWhat(READ_POST, NULL);

    /*
     * The area data is already set, so we can do the next things
     */
    if (EmailBase.Total == 0) {
	Enter(1);
	/* There are no messages in this area */
	pout(WHITE, BLACK, (char *) Language(205));
	Enter(2);
	sleep(3);
	return FALSE;
    }

    if (!Msg_Open(sMailpath)) {
	WriteError("Error open JAM base %s", sMailpath);
	return FALSE;
    }

    if (!Msg_ReadHeader(Num)) {
	Enter(1);
	pout(WHITE, BLACK, (char *)Language(77));
	Enter(2);
	Msg_Close();
	sleep(3);
	return FALSE;
    }

    /*
     * Fill Quote file in case the user wants to reply. Note that line
     * wrapping is set lower then normal message read, to create room
     * for the Quote> strings at the start of each line.
     */
    fn = calloc(PATH_MAX, sizeof(char));
    snprintf(fn, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
    if ((qf = fopen(fn, "w")) != NULL) {
	if (Msg_Read(Num, 75)) {
	    if ((p = (char *)MsgText_First()) != NULL)
		do {
		    if (p[0] == '\001') {
			/*
			 * Check CHRS kludge
			 */
			if (strncmp(p, "\001CHRS: ", 7) == 0) {
			    charset = xstrcpy(p + 7);
			}
			/*
			 * While doing this, store the original Message-id in case
			 * a reply will be made.
			 */
			if (strncasecmp(p, "\001Message-id: ", 13) == 0) {
			    snprintf(Msg.Msgid, sizeof(Msg.Msgid), "%s", p+13);
			    Syslog('m', "Stored Msgid \"%s\"", Msg.Msgid);
			}
			if (Kludges) {
			    p[0] = 'a';
			    fprintf(qf, "^%s\n", p);
			}
		    } else
			fprintf(qf, "%s\n", p);
		} while ((p = (char *)MsgText_Next()) != NULL);
	}
	fclose(qf);
    } else {
	WriteError("$Can't open %s", p);
    }
    free(fn);

    if (charset == NULL) {
	charsin = xstrcpy((char *)"CP437");
    } else {
    	charsin = xstrcpy(get_ic_ftn(find_ftn_charset(charset)));
    }

    /*
     * Setup character translation
     */
    chartran_init(charsin, get_ic_ftn(exitinfo.Charset), 'b');

    ShowEmailHdr();

    /*
     * Show message text
     */
    colour(CFG.TextColourF, CFG.TextColourB);
    if (Msg_Read(Num, 79)) {
	if ((p = (char *)MsgText_First()) != NULL) {
	    do {
		if (p[0] == '\001') {
		    if (Kludges) {
			colour(LIGHTGRAY, BLACK);
			if (p[0] == '\001')
			    p[0] = 'a';
			PUTSTR(chartran(p));
			Enter(1);
			if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE))
			    break;
		    }
		} else {
		    colour(CFG.TextColourF, CFG.TextColourB);
		    if (strchr(p, '>') != NULL)
			if ((strlen(p) - strlen(strchr(p, '>'))) < 10)
			    colour(CFG.HiliteF, CFG.HiliteB);
		    PUTSTR(chartran(p));
		    Enter(1);
		    if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE))
			break;
		}
	    } while ((p = (char *)MsgText_Next()) != NULL);
	}
    }

    if (charset)
    	free(charset);
    if (charsin)
    	free(charsin);
    chartran_close();

    /*
     * Set the Received status on this message.
     */
    if (!Msg.Received) {
	Syslog('m', "Marking message received");
	Msg.Received = TRUE;
	Msg.Read = time(NULL) - (gmt_offset((time_t)0) * 60);
	if (Msg_Lock(30L)) {
	    Msg_WriteHeader(Num);
	    Msg_UnLock();
	}
    }

    /*
     * Update lastread pointer.
     */
    p = xstrcpy(exitinfo.sUserName);
    mycrc = StringCRC32(tl(p));
    free(p);
    if (Msg_Lock(30L)) {
        LR.UserID = grecno;
	LR.UserCRC = mycrc;
        if (Msg_GetLastRead(&LR) == TRUE) {
            LR.LastReadMsg = Num;
            if (Num > LR.HighReadMsg)
                LR.HighReadMsg = Num;
            if (LR.HighReadMsg > EmailBase.Highest)
                LR.HighReadMsg = EmailBase.Highest;
            LR.UserCRC = mycrc;
	    if (!Msg_SetLastRead(LR))
                WriteError("Error update lastread");
	} else {
            /*
             * Append new lastread pointer
             */
            LR.UserCRC = mycrc;
            LR.UserID  = grecno;
            LR.LastReadMsg = Num;
            LR.HighReadMsg = Num;
            if (!Msg_NewLastRead(LR))
                WriteError("Can't append lastread");
        }
        Msg_UnLock();
    }

    Msg_Close();
    return TRUE;
}
Example #14
0
File: email.c Project: bbs-io/mbse
/*
 *  Reply message, in Msg.From and Msg.Subject must be the
 *  name to reply to and the subject.
 */
void Reply_Email(int IsReply)
{
    int     i, j, x;
    char    to[101], from[101], subj[101], msgid[101], replyto[101], replyaddr[101], *tmp, *buf, qin[9], temp[81];
    faddr   *Dest = NULL;

    snprintf(from, 101, "%s", Msg.To);
    snprintf(to, 101, "%s", Msg.From);
    snprintf(replyto, 101, "%s", Msg.ReplyTo);
    snprintf(replyaddr, 101, "%s", Msg.ReplyAddr);

    if (strncasecmp(Msg.Subject, "Re:", 3) && IsReply) {
	snprintf(subj, 101, "Re: %s", Msg.Subject);
    } else {
	snprintf(subj, 101, "%s", Msg.Subject);
    }
    mbse_CleanSubject(subj);
    Syslog('m', "Reply msg to %s, subject %s", to, subj);
    Syslog('m', "Msgid was %s", Msg.Msgid);
    snprintf(msgid, 101, "%s", Msg.Msgid);

    x = 0;
    Line = 1;
    WhosDoingWhat(READ_POST, NULL);
    clear();
    snprintf(temp, 81, "   %-70s", sMailbox);
    pout(BLUE, LIGHTGRAY, temp);
    snprintf(temp, 81, "#%-5u", EmailBase.Highest + 1);
    pout(RED, LIGHTGRAY, temp);
    Enter(1);

    colour(CFG.HiliteF, CFG.HiliteB);
    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'B');
    PUTSTR(chartran(sLine_str()));
    chartran_close();
    Enter(1);

    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
    Line = 1;
    Msg_New();

    snprintf(Msg.Replyid, sizeof(Msg.Replyid), "%s", msgid);
    snprintf(Msg.ReplyTo, sizeof(Msg.ReplyTo), "%s", replyto);
    snprintf(Msg.ReplyAddr, sizeof(Msg.ReplyAddr), "%s", replyaddr);

    /* From     : */
    pout(YELLOW, BLACK, (char *) Language(209));
    if (CFG.EmailMode != E_PRMISP) {
	/*
	 * If not permanent connected to the internet, use fidonet.org style addressing.
	 */
	Dest = fido2faddr(CFG.EmailFidoAka);
	snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName);
    } else {
	snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
    }
    for (i = 0; i < strlen(Msg.From); i++) {
	if (Msg.From[i] == ' ')
	    Msg.From[i] = '_';
	if (Msg.From[i] == '@')
	    break;
    }
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
    Enter(1);
    Syslog('b', "Setting From: %s", Msg.From);

    /* To       : */
    snprintf(Msg.To, 101, "%s", to);
    pout(YELLOW, BLACK, (char *) Language(208));
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.To);
    Enter(1);

    /* Enter to keep Subject. */
    pout(LIGHTRED, BLACK, (char *) Language(219));
    Enter(1);
    /* Subject  : */
    pout(YELLOW, BLACK, (char *) Language(210));
    snprintf(Msg.Subject, 101, "%s", subj);
    pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.Subject);

    x = strlen(subj);
    colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
    GetstrP(subj, 50, x);

    if (strlen(subj))
	strcpy(Msg.Subject, subj);

    Msg.Private = TRUE;
    Enter(1);

//  Check_Attach();

    /*
     *  Quote original message now, format the original users
     *  initials into qin. If its a [email protected] the use the
     *  first 8 characters of the name part.
     */
    snprintf(Message[1], TEXTBUFSIZE +1, "%s wrote to %s:", to, from);
    memset(&qin, 0, sizeof(qin));
    if (strchr(to, '@')) {
	tmp = xstrcpy(strtok(to, "@"));
	tmp[8] = '\0';
	snprintf(qin, 9, "%s", tmp);
	free(tmp);
    } else {
	x = TRUE;
	j = 0;
	for (i = 0; i < strlen(to); i++) {
	    if (x && isalpha(to[i])) {
		qin[j] = to[i];
		j++;
		x = FALSE;
	    }
	    if (to[i] == ' ' || to[i] == '.')
		x = TRUE;
	    if (j == 6)
		break;
	}
    }

    Line = 2;
    tmp = calloc(PATH_MAX, sizeof(char));
    buf = calloc(TEXTBUFSIZE +1, sizeof(char));

    snprintf(tmp, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
    if ((qf = fopen(tmp, "r")) != NULL) {
	while ((fgets(buf, TEXTBUFSIZE, qf)) != NULL) {
	    Striplf(buf);
	    snprintf(Message[Line], TEXTBUFSIZE +1, "%s> %s", (char *)qin, buf);
	    Line++;
	    if (Line == TEXTBUFSIZE)
		break;
	}
	fclose(qf);
    } else
	WriteError("$Can't read %s", tmp);

    free(buf);
    free(tmp);

    if (Edit_Msg())
	Save_Email(IsReply);

    for (i = 0; i < (TEXTBUFSIZE + 1); i++)
	free(Message[i]);
}
Example #15
0
File: email.c Project: bbs-io/mbse
/* 
 * Show message header screen top for reading messages.
 */
void ShowEmailHdr(void)
{
    static char     Buf1[35], Buf2[35], Buf3[81], temp[81];
    struct tm       *tm;

    Buf1[0] = '\0';
    Buf2[0] = '\0';
    Buf3[0] = '\0';

    clear();
    snprintf(temp, 81, "   %-70s", sMailbox);
    pout(BLUE, LIGHTGRAY, temp);

    snprintf(temp, 81, "#%-5u", Msg.Id);
    pout(RED, LIGHTGRAY, temp);
    Enter(1);

    /* Date     : */
    pout(YELLOW, BLACK, (char *) Language(206));
    tm = gmtime(&Msg.Written);
    snprintf(temp, 81, "%02d-%02d-%d %02d:%02d:%02d", tm->tm_mday, tm->tm_mon+1, 
		tm->tm_year+1900, tm->tm_hour, tm->tm_min, tm->tm_sec);
    pout(LIGHTGREEN, BLACK, temp);
    colour(LIGHTRED, BLACK);
    if (Msg.Local)          PUTSTR((char *)" Local");
    if (Msg.Intransit)      PUTSTR((char *)" Transit");
    if (Msg.Private)        PUTSTR((char *)" Priv.");
    if (Msg.Received)       PUTSTR((char *)" Rcvd");
    if (Msg.Sent)           PUTSTR((char *)" Sent");
    if (Msg.KillSent)       PUTSTR((char *)" KillSent");
    if (Msg.ArchiveSent)    PUTSTR((char *)" ArchiveSent");
    if (Msg.Hold)           PUTSTR((char *)" Hold");
    if (Msg.Crash)          PUTSTR((char *)" Crash");
    if (Msg.Immediate)      PUTSTR((char *)" Imm.");
    if (Msg.Direct)         PUTSTR((char *)" Dir");
    if (Msg.Gate)           PUTSTR((char *)" Gate");
    if (Msg.FileRequest)    PUTSTR((char *)" Freq");
    if (Msg.FileAttach)     PUTSTR((char *)" File");
    if (Msg.TruncFile)      PUTSTR((char *)" TruncFile");
    if (Msg.KillFile)       PUTSTR((char *)" KillFile");
    if (Msg.ReceiptRequest) PUTSTR((char *)" RRQ");
    if (Msg.ConfirmRequest) PUTSTR((char *)" CRQ");
    if (Msg.Orphan)         PUTSTR((char *)" Orphan");
    if (Msg.Encrypt)        PUTSTR((char *)" Crypt");
    if (Msg.Compressed)     PUTSTR((char *)" Comp");
    if (Msg.Escaped)        PUTSTR((char *)" 7bit");
    if (Msg.ForcePU)        PUTSTR((char *)" FPU");
    if (Msg.Localmail)      PUTSTR((char *)" Localmail");
    if (Msg.Netmail)        PUTSTR((char *)" Netmail");
    if (Msg.Echomail)       PUTSTR((char *)" Echomail");
    if (Msg.News)           PUTSTR((char *)" News");
    if (Msg.Email)          PUTSTR((char *)" E-mail");
    if (Msg.Nodisplay)      PUTSTR((char *)" Nodisp");
    if (Msg.Locked)         PUTSTR((char *)" LCK");
    if (Msg.Deleted)        PUTSTR((char *)" Del");
    Enter(1);

    /* From    : */
    pout(YELLOW, BLACK, (char *) Language(209));
    colour(LIGHTGREEN, BLACK);
    PUTSTR(chartran(Msg.From));
    Enter(1);

    /* To      : */
    pout(YELLOW, BLACK, (char *) Language(208));
    colour(LIGHTGREEN, BLACK);
    PUTSTR(chartran(Msg.To));
    Enter(1);

    /* Subject : */
    pout(YELLOW, BLACK, (char *) Language(210));
    colour(LIGHTGREEN, BLACK);
    PUTSTR(chartran(Msg.Subject));
    Enter(1);
    
    if (Msg.Reply)
	snprintf(Buf1, 35, "\"+\" %s %u", (char *)Language(211), Msg.Reply);
    if (Msg.Original)
	snprintf(Buf2, 35, "   \"-\" %s %u", (char *)Language(212), Msg.Original);
    snprintf(Buf3, 35, "%s%s ", Buf1, Buf2);
    snprintf(temp, 81, "%78s  ", Buf3);
    pout(YELLOW, BLUE, temp);
    Enter(1);
}
Example #16
0
/*
 * Display last callers screen.
 */
void LastCallers(char *OpData)
{
    FILE		    *fp;
    int			    LineCount = 5, count = 0;
    char		    lstr[201], *sFileName, *Heading;
    struct lastcallers	    lcall;
    struct lastcallershdr   lcallhdr;

    sFileName = calloc(PATH_MAX, sizeof(char));
    Heading   = calloc(81, sizeof(char));

    if (utf8)
        chartran_init((char *)"CP437", (char *)"UTF-8", 'B');

    strcpy(lstr, clear_str());
    PUTSTR(chartran(lstr));

    snprintf(sFileName, PATH_MAX, "%s/etc/lastcall.data", getenv("FTND_ROOT"));
    if ((fp = fopen(sFileName,"r")) == NULL)
        WriteError("$LastCallers: Can't open %s", sFileName);
    else {
        fread(&lcallhdr, sizeof(lcallhdr), 1, fp);

        strcpy(lstr, colour_str(WHITE, BLACK));
        /* Todays callers to */
        snprintf(Heading, 81, "%s%s", (char *) Language(84), CFG.bbs_name);
        strncat(lstr, Center_str(Heading), 200);
        PUTSTR(chartran(lstr));

        strcpy(lstr, colour_str(LIGHTRED, BLACK));
        strncat(lstr, Center_str(hLine_str(strlen(Heading))), 200);
        PUTSTR(chartran(lstr));
        Enter(1);

        /* #  User Name               Device  timeOn  Calls Location */
        strcpy(lstr, poutCR_str(LIGHTGREEN, BLACK, (char *) Language(85)));
        PUTSTR(chartran(lstr));

        strcpy(lstr, colour_str(GREEN, BLACK));
        strncat(lstr, fLine_str(cols -1), 200);
        PUTSTR(chartran(lstr));

        while (fread(&lcall, lcallhdr.recsize, 1, fp) == 1) {
            if (!lcall.Hidden) {
                count++;

                strcpy(lstr, colour_str(WHITE, BLACK));
                snprintf(Heading, 80, "%-5d", count);
                strncat(lstr, Heading, 200);

                strncat(lstr, colour_str(LIGHTCYAN, BLACK), 200);
                if ((strcasecmp(OpData, "/H")) == 0) {
                    if ((strcmp(lcall.Handle, "") != 0 && *(lcall.Handle) != ' '))
                        snprintf(Heading, 80, "%-20s", lcall.Handle);
                    else
                        snprintf(Heading, 80, "%-20s", lcall.UserName);
                } else if (strcasecmp(OpData, "/U") == 0) {
                    snprintf(Heading, 80, "%-20s", lcall.Name);
                } else {
                    snprintf(Heading, 80, "%-20s", lcall.UserName);
                }
                strncat(lstr, Heading, 200);

                snprintf(Heading, 80, "%-8s", lcall.Device);
                strncat(lstr, pout_str(LIGHTBLUE, BLACK, Heading), 200);

                snprintf(Heading, 80, "%-8s", lcall.TimeOn);
                strncat(lstr, pout_str(LIGHTMAGENTA, BLACK, Heading), 200);

                snprintf(Heading, 80, "%-7d", lcall.Calls);
                strncat(lstr, pout_str(YELLOW, BLACK, Heading), 200);

                snprintf(Heading, 80, "%-32s", lcall.Location);
                strncat(lstr, pout_str(LIGHTRED, BLACK, Heading), 200);
                PUTSTR(chartran(lstr));
                Enter(1);

                LineCount++;
                if (LineCount == (rows -2)) {
                    Pause();
                    LineCount = 0;
                }

            } /* End of check if user is hidden */
        }

        strcpy(lstr, colour_str(GREEN, BLACK));
        strncat(lstr, fLine_str(cols -1), 200);
        PUTSTR(chartran(lstr));

        fclose(fp);
        Enter(1);
        Pause();
    }

    free(sFileName);
    free(Heading);
    chartran_close();
}
Example #17
0
int Report(gr_list *ta, int filepos)
{
    FILE	    *fp, *fi;
    char	    *temp, *line;
    int		    i, Total = 0;
    unsigned int    Size = 0;
    int		    filepos1 = 0, filepos2, filepos3 = 0, finalpos = 0;
    time_t	    ftime;

    temp = calloc(PATH_MAX, sizeof(char));
    snprintf(temp, PATH_MAX, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
    if ((fp = fopen(temp, "r")) == NULL) {
	WriteError("$Can't open %s", temp);
	return 0;
    }

    MacroVars("GJZ", "ssd", "", "", 0);
    MacroVars("slbkdt", "ssddss", "", "", 0, 0, "", "");
    MacroVars("ABZ", "ddd", 0, 0, 0);

    while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
	if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group)))
	    break;
    }

	Syslog('m', "Announce %s %s %s", T_File.Echo, T_File.Name, chartran(T_File.LName));
    if ((fi = OpenMacro(newfiles.Template, newfiles.Language, FALSE)) != NULL) {
	/*
	 * Area block header
	 */
	MacroVars("GJZ", "ssd", T_File.Echo, chartran(T_File.Comment), 0);
	fseek(fi, filepos, SEEK_SET);
	Msg_Macro(fi);
	filepos1 = ftell(fi);
    } else {
	free(temp);
	return 0;
    }

    fseek(fp, 0, SEEK_SET);
    while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
	if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group))) {

	    if (CFG.slow_util && do_quiet)
		msleep(1);

	    /*
	     * Report one newfile, first line.
	     */
	    fseek(fi, filepos1, SEEK_SET);
	    ftime = T_File.Fdate;
	    MacroVars("sl", "ss", T_File.Name, T_File.LName);
	    MacroVars("bk", "dd", T_File.Size, T_File.SizeKb);
	    MacroVars("dt", "ss", rfcdate(ftime), chartran(T_File.LDesc[0]));
	    Msg_Macro(fi);
	    filepos2 = ftell(fi);

	    /*
	     * Extra description lines follow
	     */
	    for (i = 1; i < 24; i++) {
		fseek(fi, filepos2, SEEK_SET);
		if (strlen(T_File.LDesc[i])) {
		    MacroVars("t", "s", chartran(T_File.LDesc[i]));
		    Msg_Macro(fi);
		} else {
		    line = calloc(MAXSTR, sizeof(char));
		    while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {}
		    free(line);
		}
		filepos3 = ftell(fi);
	    }

	    /*
	     * Magic request
	     */
	    if (strlen(T_File.Magic)) {
		MacroVars("u", "s", T_File.Magic);
		Msg_Macro(fi);
	    } else {
		line = calloc(MAXSTR, sizeof(char));
		while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {}
		free(line);
	    }
	    filepos3 = ftell(fi);
	    Total++;
	    Size += T_File.SizeKb;
	}
    }

    /*
     * Area block footer
     */
    if (Msg.Size > (CFG.new_split * 1024))
	MacroVars("ABZ", "ddd", Total, Size, 1);
    else
	MacroVars("ABZ", "ddd", Total, Size, 0);
    fseek(fi, filepos3, SEEK_SET);
    Msg_Macro(fi);
    finalpos = ftell(fi);
    fclose(fp);
    free(temp);

    /*
     * Split messages if too big.
     */
    if (Msg.Size > (CFG.new_split * 1024)) {
	MsgCount++;
	Syslog('m', "Report() splitting report");
	FinishMsg(FALSE, finalpos);
	StartMsg();
    }

    TotalFiles += Total;
    TotalSize += Size;

    if (fi != NULL) {
	fclose(fi);
    }
    return finalpos;
}
Example #18
0
File: file.c Project: bbs-io/mbse
/*
 * Show Raw directory
 */
void File_RawDir(char *OpData)
{
    DIR		    *dirp;
    char	    *FileName, *temp, temp2[81];
    int		    iFileCount = 0, LineCount = 2, iBytes = 0;
    struct dirent   *dp;
    struct stat	    statfile;

    FileName = calloc(PATH_MAX, sizeof(char));
    temp     = calloc(PATH_MAX, sizeof(char));

    if ((strcmp(OpData, "/F")) == 0)
	strcpy(temp, sAreaPath);
    else
	strcpy(temp, OpData);

    if ((dirp = opendir(temp)) == NULL) {
	clear();
	WriteError("$RawDir: Can't open dir: %s", temp);
	Enter(1);
	pout(LIGHTRED, BLACK, (char *)"Can't open directory for raw listing!");
	Enter(2);
	Pause();
    } else {
	if (utf8)
	    chartran_init((char *)"CP437", (char *)"UTF-8", 'b');

	clear();
	/* Filename                                   Size        Date */
	pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(261));
	Enter(1);
	PUTSTR(chartran(fLine_str(78)));

	while ((dp = readdir( dirp )) != NULL ) {
	    snprintf(FileName, PATH_MAX, "%s/%s", temp, dp->d_name);

	    if (*(dp->d_name) != '.') {
		iFileCount++;
		if (stat(FileName, &statfile) != 0) {
		    pout(LIGHTRED, BLACK, (char *)"Can't stat file ");
		    PUTSTR(FileName);
		} else {
		    iBytes += statfile.st_size;

		    snprintf(temp2, 81, "%-54s " , dp->d_name);
		    pout(YELLOW, BLACK, temp2);

		    snprintf(temp2, 81, "%-12d", (int)(statfile.st_size));
		    pout(LIGHTMAGENTA, BLACK, temp2);

		    snprintf(temp2, 81, "%-10s", StrDateDMY(statfile.st_mtime));
		    pout(LIGHTGREEN, BLACK, temp2);
		}
		Enter(1);

		LineCount++;
		if (LineCount == rows) {
		    Pause();
		    LineCount = 0;
		}
	    }
	}

	colour(CFG.HiliteF, CFG.HiliteB);
	PUTSTR(chartran(fLine_str(78)));
	/* Total Files: */ /* Bytes */
	snprintf(temp2, 81, "%s %d, %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354));
	pout(LIGHTGREEN, BLACK, temp2);
	Enter(2);

	Pause();
	closedir(dirp);
	chartran_close();
    }

    free(temp);
    free(FileName);
}
Example #19
0
/* 
 * List Oneliners
 */
void Oneliner_List()
{
    FILE    *pOneline;
    int	    recno = 0, Colour = 1;
    char    *sFileName, msg[81];
	                                                                                  
    clear();
    sFileName = calloc(PATH_MAX, sizeof(char));
    snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT"));

    if ((pOneline = fopen(sFileName, "r+")) == NULL) {
	WriteError("Can't open file: %s", sFileName);
	return;
    }
    fread(&olhdr, sizeof(olhdr), 1, pOneline);

    if ((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
	/* #  A   Date       User          Description */
	pout(LIGHTGREEN, BLACK, Language(345));
    } else {
	/* #  Description */
	pout(LIGHTGREEN, BLACK, Language(346));
    }
    Enter(1);
    colour(GREEN, BLACK);
    if (utf8)
	chartran_init((char *)"CP437", (char *)"UTF-8", 'B');
    PUTSTR(chartran(sLine_str()));
    chartran_close();

    while (fread(&ol, olhdr.recsize, 1, pOneline) == 1) {
	if ((SYSOP == TRUE) || (exitinfo.Security.level >= CFG.sysop_access)) {
	    snprintf(msg, 81, "%2d", recno);
	    pout(WHITE, BLACK, msg);

	    snprintf(msg, 81, "%2d ", ol.Available);
	    pout(LIGHTBLUE, BLACK, msg);

	    pout(LIGHTCYAN, BLACK, ol.DateOfEntry);

	    snprintf(msg, 81, "%-15s ", ol.UserName);
	    pout(CYAN, BLACK, msg);

	    snprintf(msg, 81, "%-.48s", ol.Oneline);
	    poutCR(Colour, BLACK, msg);
	} else {
	    snprintf(msg, 81, "%2d ", recno);
	    pout(WHITE, BLACK, msg);
	    snprintf(msg, 81, "%-.76s", ol.Oneline);
	    poutCR(Colour, BLACK, msg);
	}

	recno++;
	Colour++;
	if (Colour >= 16)
	    Colour = 1;
    }
    fclose(pOneline);
    Enter(1);
    Pause();
    free(sFileName);
}