Removed timebank and nextuser doors, added signature editor
This commit is contained in:
@@ -4,25 +4,25 @@
|
||||
|
||||
include ../Makefile.global
|
||||
|
||||
SRCS = bank.c filesub.c language.c mbtoberep.c \
|
||||
SRCS = signature.c filesub.c language.c mbtoberep.c \
|
||||
msgutil.c oneline.c bbslist.c morefile.c \
|
||||
email.c fsedit.c lineedit.c mblang.c mbuser.c page.c \
|
||||
bye.c funcs.c mail.c \
|
||||
newuser.c pinfo.c timecheck.c change.c \
|
||||
exitinfo.c mball.c mbsebbs.c menu.c nextuser.c pop3.c lastcallers.c \
|
||||
exitinfo.c mball.c mbsebbs.c menu.c pop3.c lastcallers.c \
|
||||
safe.c timeout.c chat.c file.c mbchat.c mbstat.c misc.c \
|
||||
offline.c user.c mbnewusr.c input.c whoson.c \
|
||||
door.c dispfile.c userlist.c timestats.c logentry.c
|
||||
HDRS = bank.h filesub.h language.h mbsebbs.h misc.h offline.h \
|
||||
HDRS = signature.h filesub.h language.h mbsebbs.h misc.h offline.h \
|
||||
timeout.h bbslist.h email.h fsedit.h lineedit.h \
|
||||
mbstat.h msgutil.h oneline.h user.h bye.h morefile.h \
|
||||
funcs.h mail.h mbuser.h page.h \
|
||||
change.h exitinfo.h mball.h newuser.h \
|
||||
pinfo.h chat.h file.h menu.h \
|
||||
nextuser.h pop3.h safe.h timecheck.h mbnewusr.h input.h whoson.h \
|
||||
pop3.h safe.h timecheck.h mbnewusr.h input.h whoson.h \
|
||||
door.h dispfile.h userlist.h timestats.h logentry.h lastcallers.h
|
||||
MBSEBBS_OBJS = bank.o bbslist.o chat.o file.o funcs.o mail.o menu.o \
|
||||
misc.o pinfo.o nextuser.o oneline.o page.o fsedit.o \
|
||||
MBSEBBS_OBJS = signature.o bbslist.o chat.o file.o funcs.o mail.o menu.o \
|
||||
misc.o pinfo.o oneline.o page.o fsedit.o \
|
||||
bye.o change.o mbsebbs.o safe.o timeout.o user.o timecheck.o \
|
||||
exitinfo.o filesub.o lineedit.o offline.o language.o msgutil.o \
|
||||
pop3.o email.o input.o whoson.o door.o dispfile.o userlist.o timestats.o \
|
||||
@@ -134,7 +134,7 @@ depend:
|
||||
|
||||
# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
|
||||
# Dependencies generated by make depend
|
||||
bank.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h bank.h input.h language.h dispfile.h timeout.h timecheck.h whoson.h exitinfo.h
|
||||
signature.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/ansi.h ../lib/clcomm.h ../lib/common.h signature.h funcs.h input.h language.h timeout.h
|
||||
filesub.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h funcs.h language.h input.h misc.h timeout.h exitinfo.h change.h
|
||||
language.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h input.h language.h
|
||||
mbtoberep.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/mberrors.h
|
||||
@@ -158,8 +158,7 @@ change.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/struc
|
||||
exitinfo.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h funcs.h input.h language.h oneline.h misc.h bye.h timeout.h timecheck.h exitinfo.h
|
||||
mball.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/mbse.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbcfg.h ../lib/clcomm.h ../lib/mberrors.h mball.h
|
||||
mbsebbs.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/mberrors.h mbsebbs.h user.h dispfile.h language.h menu.h misc.h bye.h timeout.h funcs.h
|
||||
menu.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h oneline.h mail.h bbslist.h change.h bank.h chat.h file.h funcs.h input.h misc.h nextuser.h safe.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h userlist.h timestats.h logentry.h morefile.h lastcallers.h
|
||||
nextuser.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/ansi.h ../lib/clcomm.h ../lib/common.h nextuser.h funcs.h input.h language.h timeout.h
|
||||
menu.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h oneline.h mail.h bbslist.h change.h chat.h file.h funcs.h input.h misc.h safe.h timeout.h menu.h page.h pinfo.h bye.h timecheck.h whoson.h language.h offline.h email.h door.h dispfile.h userlist.h timestats.h logentry.h morefile.h lastcallers.h signature.h
|
||||
pop3.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h
|
||||
lastcallers.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h input.h language.h lastcallers.h
|
||||
safe.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h whoson.h dispfile.h input.h misc.h safe.h timeout.h language.h
|
||||
|
580
mbsebbs/bank.c
580
mbsebbs/bank.c
@@ -1,580 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
* Purpose ...............: Time/Bytes Bank
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
*
|
||||
* Michiel Broek FIDO: 2:2801/16
|
||||
* Beekmansbos 10 Internet: mbroek@ux123.pttnwb.nl
|
||||
* 1971 BV IJmuiden
|
||||
* the Netherlands
|
||||
*
|
||||
* This file is part of MBSE BBS.
|
||||
*
|
||||
* This BBS is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* MBSE BBS is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../config.h"
|
||||
#include "../lib/libs.h"
|
||||
#include "../lib/memwatch.h"
|
||||
#include "../lib/mbse.h"
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/users.h"
|
||||
#include "../lib/records.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/common.h"
|
||||
#include "bank.h"
|
||||
#include "input.h"
|
||||
#include "language.h"
|
||||
#include "dispfile.h"
|
||||
#include "timeout.h"
|
||||
#include "timecheck.h"
|
||||
#include "whoson.h"
|
||||
#include "exitinfo.h"
|
||||
|
||||
|
||||
/*
|
||||
* internal function prototypes
|
||||
*/
|
||||
int BankMenu(void);
|
||||
void AddAccount(void);
|
||||
void Deposit(void);
|
||||
void Withdraw(void);
|
||||
void DepositTime(void);
|
||||
void WithdrawTime(void);
|
||||
|
||||
void DepositBytes(void);
|
||||
void WithdrawBytes(void);
|
||||
|
||||
FILE *pBank;
|
||||
int usernum = 0;
|
||||
long bankset;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Timebank, called from the menu system.
|
||||
*/
|
||||
void Bank()
|
||||
{
|
||||
int FoundName = FALSE;
|
||||
int Loop = TRUE;
|
||||
char *temp, temp1[81];
|
||||
|
||||
DisplayFile((char *)"bank");
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
while(Loop) {
|
||||
FoundName = FALSE;
|
||||
usernum = 0;
|
||||
WhosDoingWhat(TIMEBANK);
|
||||
|
||||
sprintf(temp, "%s/etc/bank.data", getenv("MBSE_ROOT"));
|
||||
if ((pBank = fopen(temp, "r+")) == NULL) {
|
||||
/* Create a new database */
|
||||
pBank = fopen(temp, "a+");
|
||||
bankhdr.hdrsize = sizeof(bankhdr);
|
||||
bankhdr.recsize = sizeof(bank);
|
||||
fwrite(&bankhdr, sizeof(bankhdr), 1, pBank);
|
||||
fclose(pBank);
|
||||
chmod(temp, 0660);
|
||||
Syslog('-', "Created %s", temp);
|
||||
AddAccount();
|
||||
if ((pBank = fopen(temp, "r+")) == NULL) {
|
||||
WriteError("Unable to open %s", temp);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fread(&bankhdr, sizeof(bankhdr), 1, pBank);
|
||||
fseek(pBank, bankhdr.hdrsize, 0);
|
||||
while (fread(&bank, bankhdr.recsize, 1, pBank) == 1) {
|
||||
if((strcmp(bank.Name, exitinfo.sUserName)) == 0) {
|
||||
FoundName = TRUE;
|
||||
break;
|
||||
} else
|
||||
usernum++;
|
||||
} /* End of while */
|
||||
|
||||
fclose(pBank);
|
||||
|
||||
if(!FoundName)
|
||||
AddAccount();
|
||||
|
||||
if ((pBank = fopen(temp, "r+")) == NULL)
|
||||
AddAccount();
|
||||
|
||||
bankset = bankhdr.hdrsize + (usernum * bankhdr.recsize);
|
||||
if (fseek(pBank, bankset, 0) != 0)
|
||||
WriteError("Can't move pointer there.");
|
||||
|
||||
fread(&bank, bankhdr.recsize, 1, pBank);
|
||||
|
||||
sprintf(temp1, "%s", (char *) GetDateDMY());
|
||||
if ((strcmp(temp1, bank.Date)) != 0) {
|
||||
bank.TimeWithdraw = 0;
|
||||
bank.KByteWithdraw = 0;
|
||||
bank.TimeDeposit = 0;
|
||||
bank.KByteDeposit = 0;
|
||||
sprintf(bank.Date, "%s", (char *) GetDateDMY());
|
||||
}
|
||||
|
||||
Loop = BankMenu();
|
||||
}
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int BankMenu()
|
||||
{
|
||||
int i;
|
||||
|
||||
clear();
|
||||
/* MBSE BBS System Bank */
|
||||
language(4, 7, 11);
|
||||
colour(15, 0);
|
||||
sLine();
|
||||
/* Bank Account: */
|
||||
language(3, 0, 12);
|
||||
poutCR(15, 0, bank.Name);
|
||||
colour(15, 0);
|
||||
sLine();
|
||||
|
||||
/* Time in account */
|
||||
language(10, 0, 13);
|
||||
colour(15, 0);
|
||||
printf("%d\n", bank.TimeBalance);
|
||||
|
||||
/* Bytes in account */
|
||||
language(10, 0, 14);
|
||||
colour(15, 0);
|
||||
printf("%d\n", bank.KByteBalance);
|
||||
|
||||
/* Time deposited today */
|
||||
language(10, 0, 15);
|
||||
colour(15, 0);
|
||||
printf("%d\n", bank.TimeDeposit);
|
||||
|
||||
/* Bytes deposited today */
|
||||
language(10, 0, 16);
|
||||
colour(15, 0);
|
||||
printf("%d\n", bank.KByteDeposit);
|
||||
|
||||
/* Time withdrawn today */
|
||||
language(10, 0, 17);
|
||||
colour(15, 0);
|
||||
printf("%d\n", bank.TimeWithdraw);
|
||||
|
||||
/* Bytes withdrawn today */
|
||||
language(10, 0, 18);
|
||||
colour(15, 0);
|
||||
printf("%d\n", bank.KByteWithdraw);
|
||||
|
||||
colour(15, 0);
|
||||
sLine();
|
||||
TimeCheck();
|
||||
/* (D)eposit, (W)ithdraw, (Q)uit */
|
||||
language(12, 0, 19);
|
||||
Enter(2);
|
||||
|
||||
/* Bank > */
|
||||
language(15, 0, 20);
|
||||
fflush(stdout);
|
||||
|
||||
alarm_on();
|
||||
i = toupper(Getone());
|
||||
|
||||
if (i == Keystroke(19, 0))
|
||||
Deposit();
|
||||
else
|
||||
if (i == Keystroke(19, 1))
|
||||
Withdraw();
|
||||
else
|
||||
if (i == Keystroke(19, 2))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AddAccount()
|
||||
{
|
||||
char *temp;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
sprintf(temp, "%s/etc/bank.data", getenv("MBSE_ROOT"));
|
||||
|
||||
if ((pBank = fopen(temp, "a+")) == NULL)
|
||||
WriteError("Can't open %s for updating", temp);
|
||||
else {
|
||||
memset(&bank, 0, sizeof(bank));
|
||||
strcpy(bank.Name, exitinfo.sUserName);
|
||||
sprintf(bank.Date, "%s", (char *) GetDateDMY());
|
||||
fwrite(&bank, sizeof(bank), 1, pBank);
|
||||
fclose(pBank);
|
||||
}
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Deposit()
|
||||
{
|
||||
int i;
|
||||
|
||||
/* (T)ime, (B)ytes, (Q)uit : */
|
||||
language(3, 0, 21);
|
||||
fflush(stdout);
|
||||
|
||||
alarm_on();
|
||||
i = toupper(Getone());
|
||||
|
||||
if (i == Keystroke(21, 0))
|
||||
DepositTime();
|
||||
else
|
||||
if (i == Keystroke(21, 1))
|
||||
DepositBytes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Withdraw()
|
||||
{
|
||||
int i;
|
||||
|
||||
/* (T)ime, (B)ytes, (Q)uit : */
|
||||
language(3, 0, 21);
|
||||
fflush(stdout);
|
||||
|
||||
alarm_on();
|
||||
i = toupper(Getone());
|
||||
|
||||
if (i == Keystroke(21, 0))
|
||||
WithdrawTime();
|
||||
else
|
||||
if (i == Keystroke(21, 1))
|
||||
WithdrawBytes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DepositTime()
|
||||
{
|
||||
int x;
|
||||
char *temp;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
ReadExitinfo();
|
||||
fflush(stdin);
|
||||
|
||||
if(exitinfo.iTimeLeft <= 5) {
|
||||
Enter(2);
|
||||
/* You must have at least 5 minutes remaining to deposit */
|
||||
language(12, 0, 22);
|
||||
Enter(2);
|
||||
Pause();
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
Enter(1);
|
||||
/* How much time. Minutes available to you is */
|
||||
language(15, 0, 23);
|
||||
printf("%d: ", exitinfo.iTimeLeft - 5);
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0) {
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
x = atoi(temp);
|
||||
bank.TimeDeposit += x;
|
||||
bank.TimeBalance += x;
|
||||
|
||||
if(bank.TimeDeposit > CFG.iMaxTimeDeposit) {
|
||||
colour(10, 0);
|
||||
Enter(1);
|
||||
/* You have tried to deposit more than the maximum limit today. */
|
||||
language(10, 0, 24);
|
||||
Enter(1);
|
||||
|
||||
/* Maximum allowed minutes to deposit per day: */
|
||||
language(12, 0, 25);
|
||||
printf("%d.\n\n", CFG.iMaxTimeDeposit);
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(bank.TimeBalance > CFG.iMaxTimeBalance) {
|
||||
Enter(1);
|
||||
/* You have exeeded your account balance. */
|
||||
language(10, 0, 26);
|
||||
/* Maximum allowable minutes in bank account is: */
|
||||
language(12, 0, 27);
|
||||
printf("%d\n", CFG.iMaxTimeBalance);
|
||||
/* You are allowed to deposit: */
|
||||
language(14, 0, 28);
|
||||
printf("%d\n\n", CFG.iMaxTimeBalance - (bank.TimeBalance - x) );
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
Time2Go -= (x * 60);
|
||||
TimeCheck();
|
||||
|
||||
bankset = bankhdr.hdrsize + (usernum * bankhdr.recsize);
|
||||
if(fseek(pBank, bankset, 0) != 0)
|
||||
WriteError("Can't move pointer there.");
|
||||
|
||||
fwrite(&bank, sizeof(bank), 1, pBank);
|
||||
fclose(pBank);
|
||||
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WithdrawTime()
|
||||
{
|
||||
char *temp;
|
||||
int x;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
ReadExitinfo();
|
||||
|
||||
/* How much time. Minutes available to you is */
|
||||
Enter(1);
|
||||
language(15, 0, 23);
|
||||
printf("%d: ", bank.TimeBalance);
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0) {
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
x = atoi(temp);
|
||||
|
||||
bank.TimeWithdraw += x;
|
||||
bank.TimeBalance -= x;
|
||||
|
||||
if(bank.TimeWithdraw > CFG.iMaxTimeWithdraw) {
|
||||
Enter(1);
|
||||
/* You have tried to withdraw more than the maximum limit today. */
|
||||
language(10, 0, 29);
|
||||
/* Maximum allowed to withdraw per day: */
|
||||
language(12, 0, 30);
|
||||
printf("%d.\n\n", CFG.iMaxTimeWithdraw);
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(x > bank.TimeBalance + x) {
|
||||
Enter(1);
|
||||
/* You have tried to withdraw more time than is in your bank account. */
|
||||
language(10, 0, 31);
|
||||
/* Current bank balance: */
|
||||
language(10, 0, 32);
|
||||
printf("%d.\n\n", bank.TimeBalance + x);
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
Time2Go += (x * 60);
|
||||
TimeCheck();
|
||||
|
||||
bankset = bankhdr.hdrsize + (usernum * bankhdr.recsize);
|
||||
|
||||
if(fseek(pBank, bankset, 0) != 0)
|
||||
WriteError("Can't move pointer there.");
|
||||
|
||||
fwrite(&bank, sizeof(bank), 1, pBank);
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DepositBytes()
|
||||
{
|
||||
char *temp;
|
||||
int x;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
ReadExitinfo();
|
||||
|
||||
if(exitinfo.DownloadKToday <= 5) {
|
||||
Enter(2);
|
||||
/* You must have at least 5 bytes remaining to deposit */
|
||||
language(12, 0, 22);
|
||||
Enter(2);
|
||||
Pause();
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
Enter(1);
|
||||
/* Bytes available: */
|
||||
language(15, 0, 36);
|
||||
printf("%lu: ", exitinfo.DownloadKToday);
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0) {
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
x = atoi(temp);
|
||||
bank.KByteDeposit += x;
|
||||
bank.KByteBalance += x;
|
||||
|
||||
if(bank.KByteDeposit > CFG.iMaxByteDeposit * 1000) {
|
||||
Enter(1);
|
||||
/* You have tried to deposit more than the maximum limit today. */
|
||||
language(10, 0, 25);
|
||||
Enter(1);
|
||||
colour(12, 0);
|
||||
/* Maximum allowed kilobytes to deposit per day: */
|
||||
language(12, 0, 33);
|
||||
printf("%d.\n\n", CFG.iMaxByteDeposit);
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(bank.KByteBalance > CFG.iMaxByteBalance * 1000) {
|
||||
Enter(1);
|
||||
/* You have exeeded your account balance. */
|
||||
language(10, 0, 34);
|
||||
Enter(1);
|
||||
/* Maximum allowable kilobytes in bank account is: */
|
||||
language(12, 0, 35);
|
||||
printf("%d\n", CFG.iMaxByteBalance);
|
||||
colour(14, 0);
|
||||
/* You are allowed to deposit: */
|
||||
language(14, 0, 28);
|
||||
printf("%d\n\n", CFG.iMaxByteBalance - (bank.KByteBalance - x) );
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
exitinfo.DownloadKToday -= x;
|
||||
WriteExitinfo();
|
||||
|
||||
bankset = bankhdr.hdrsize + (usernum * bankhdr.recsize);
|
||||
|
||||
if(fseek(pBank, bankset, 0) != 0)
|
||||
WriteError("Can't move pointer there.");
|
||||
|
||||
fwrite(&bank, sizeof(bank), 1, pBank);
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WithdrawBytes()
|
||||
{
|
||||
char *temp;
|
||||
int x;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
ReadExitinfo();
|
||||
|
||||
Enter(1);
|
||||
/* How many bytes. Bytes available to you is */
|
||||
language(15, 0, 36);
|
||||
printf("%d: ", bank.KByteBalance);
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0) {
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
x = atoi(temp);
|
||||
bank.KByteWithdraw += x;
|
||||
bank.KByteBalance -= x;
|
||||
|
||||
if(bank.KByteWithdraw > CFG.iMaxByteWithdraw * 1000) {
|
||||
Enter(1);
|
||||
/* You have tried to withdraw more than the maximum limit today. */
|
||||
language(10, 0, 29);
|
||||
Enter(1);
|
||||
colour(12, 0);
|
||||
/* Maximum allowed to withdraw per day: */
|
||||
language(12, 0, 30);
|
||||
printf("%d bytes.\n\n", CFG.iMaxByteWithdraw);
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(x > bank.KByteBalance + x) {
|
||||
Enter(1);
|
||||
/* You have tried to withdraw more time than is in your bank account. */
|
||||
language(10, 0, 31);
|
||||
Enter(1);
|
||||
colour(12, 0);
|
||||
/* Current bank balance: */
|
||||
language(12, 0, 32);
|
||||
printf("%d.\n\n", bank.KByteBalance + x);
|
||||
Pause();
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
exitinfo.DownloadKToday += x;
|
||||
WriteExitinfo();
|
||||
|
||||
bankset = bankhdr.hdrsize + (usernum * bankhdr.recsize);
|
||||
|
||||
if(fseek(pBank, bankset, 0) != 0)
|
||||
WriteError("Can't move pointer there.");
|
||||
|
||||
fwrite(&bank, sizeof(bank), 1, pBank);
|
||||
fclose(pBank);
|
||||
free(temp);
|
||||
}
|
||||
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#ifndef _BANK_H
|
||||
#define _BANK_H
|
||||
|
||||
void Bank(void);
|
||||
|
||||
#endif
|
||||
|
@@ -763,8 +763,8 @@ char *GetFileType(char *fn)
|
||||
int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
||||
{
|
||||
char *temp, *temp1;
|
||||
int i, x;
|
||||
char *token;
|
||||
// int i, x;
|
||||
// char *token;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
@@ -794,12 +794,12 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
||||
* Give back the user his bytes from the upload
|
||||
* Work out byte ratio, then give time back to user
|
||||
*/
|
||||
strcpy(temp, CFG.sByteRatio);
|
||||
token = strtok(temp, ":");
|
||||
i = atoi(token);
|
||||
token = strtok(NULL, "\0");
|
||||
x = atoi(token);
|
||||
Size *= i / x;
|
||||
// strcpy(temp, CFG.sByteRatio);
|
||||
// token = strtok(temp, ":");
|
||||
// i = atoi(token);
|
||||
// token = strtok(NULL, "\0");
|
||||
// x = atoi(token);
|
||||
// Size *= i / x;
|
||||
/* You have */ /* extra download KBytes. */
|
||||
printf("%s %ld %s\n", (char *) Language(249), (long)(Size / 1024), (char *) Language(250));
|
||||
|
||||
@@ -812,13 +812,13 @@ int ImportFile(char *fn, int Area, int fileid, time_t iTime, off_t Size)
|
||||
* Work out time ratio, then give time back to user
|
||||
* Ratio 3:1, Upload time: times by 3 / 1
|
||||
*/
|
||||
strcpy(temp, CFG.sTimeRatio);
|
||||
token = strtok(temp, ":");
|
||||
i = atoi(token);
|
||||
token = strtok(NULL, "\0");
|
||||
x = atoi(token);
|
||||
// strcpy(temp, CFG.sTimeRatio);
|
||||
// token = strtok(temp, ":");
|
||||
// i = atoi(token);
|
||||
// token = strtok(NULL, "\0");
|
||||
// x = atoi(token);
|
||||
|
||||
iTime *= i / x;
|
||||
// iTime *= i / x;
|
||||
iTime /= 60; /* Divide Seconds by 60 to give minutes */
|
||||
/* You have */ /* extra minutes. */
|
||||
printf("%s %ld %s\n", (char *) Language(249), iTime, (char *) Language(259));
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Display and handle the menus.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@@ -42,13 +42,11 @@
|
||||
#include "mail.h"
|
||||
#include "bbslist.h"
|
||||
#include "change.h"
|
||||
#include "bank.h"
|
||||
#include "chat.h"
|
||||
#include "file.h"
|
||||
#include "funcs.h"
|
||||
#include "input.h"
|
||||
#include "misc.h"
|
||||
#include "nextuser.h"
|
||||
#include "safe.h"
|
||||
#include "timeout.h"
|
||||
#include "menu.h"
|
||||
@@ -67,6 +65,7 @@
|
||||
#include "logentry.h"
|
||||
#include "morefile.h"
|
||||
#include "lastcallers.h"
|
||||
#include "signature.h"
|
||||
|
||||
|
||||
|
||||
@@ -419,19 +418,7 @@ void DoMenu(int Type)
|
||||
/* display menuline only */
|
||||
break;
|
||||
|
||||
case 22:
|
||||
/* nextuser door */
|
||||
nextuser();
|
||||
break;
|
||||
|
||||
case 23:
|
||||
/* timebank door */
|
||||
Bank();
|
||||
break;
|
||||
|
||||
case 24:
|
||||
/* voting door Not anymore */
|
||||
break;
|
||||
/* Menus 22, 23 and 24 were obsolete doors */
|
||||
|
||||
case 25:
|
||||
/* safe cracker door */
|
||||
@@ -661,6 +648,10 @@ void DoMenu(int Type)
|
||||
Chg_Address();
|
||||
break;
|
||||
|
||||
case 319:
|
||||
signature();
|
||||
break;
|
||||
|
||||
case 401:
|
||||
Oneliner_Add();
|
||||
break;
|
||||
|
@@ -1,362 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
* Purpose ...............: Message to next User door
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
* 1971 BV IJmuiden
|
||||
* the Netherlands
|
||||
*
|
||||
* This file is part of MBSE BBS.
|
||||
*
|
||||
* This BBS is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* MBSE BBS is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../config.h"
|
||||
#include "../lib/libs.h"
|
||||
#include "../lib/memwatch.h"
|
||||
#include "../lib/mbse.h"
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/users.h"
|
||||
#include "../lib/records.h"
|
||||
#include "../lib/ansi.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/common.h"
|
||||
#include "nextuser.h"
|
||||
#include "funcs.h"
|
||||
#include "input.h"
|
||||
#include "language.h"
|
||||
#include "timeout.h"
|
||||
|
||||
|
||||
int iLoop, iLine = 1;
|
||||
|
||||
char sFrom[81];
|
||||
char To[81];
|
||||
char Subject[81];
|
||||
|
||||
int finish(void);
|
||||
void addlines(void);
|
||||
|
||||
char *sLiNE[11];
|
||||
|
||||
|
||||
|
||||
void nextuser(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
*(sLiNE + i) = (char *) calloc(81, sizeof(char));
|
||||
|
||||
addlines();
|
||||
while (TRUE) {
|
||||
if (finish() == TRUE)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
free(*(sLiNE + i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void addlines(void)
|
||||
{
|
||||
iLine = 1;
|
||||
clear();
|
||||
|
||||
/* Message to Nextuser Door */
|
||||
pout(15, 0, (char *) Language(107));
|
||||
Enter(2);
|
||||
|
||||
Syslog('+', "%s ran Nextuser Door", exitinfo.sUserName);
|
||||
|
||||
/* The FROM, TO and SUBJECT fields are optional. */
|
||||
pout(14, 0, (char *) Language(108));
|
||||
Enter(1);
|
||||
|
||||
Enter(1);
|
||||
/* From: */
|
||||
pout(12, 0, (char *) Language(109));
|
||||
colour(9, 0);
|
||||
fflush(stdout);
|
||||
Getname(sFrom, 50);
|
||||
|
||||
/* To: */
|
||||
pout(12, 0, (char *) Language(110));
|
||||
colour(9, 0);
|
||||
fflush(stdout);
|
||||
Getname(To, 50);
|
||||
|
||||
/* Subject: */
|
||||
pout(12, 0, (char *) Language(111));
|
||||
colour(9, 0);
|
||||
fflush(stdout);
|
||||
GetstrC(Subject, 80);
|
||||
|
||||
Enter(2);
|
||||
/* Type up to 10 lines 74 Characters per line */
|
||||
pout(10 , 0, (char *) Language(112));
|
||||
Enter(1);
|
||||
|
||||
colour(14, 0);
|
||||
printf(" <20>");
|
||||
for(iLoop = 0; iLoop <= 75; iLoop++)
|
||||
printf("<EFBFBD>");
|
||||
printf("<EFBFBD>");
|
||||
|
||||
while (1) {
|
||||
colour(12, 0);
|
||||
printf("%d: ", iLine);
|
||||
colour(9, 0);
|
||||
fflush(stdout);
|
||||
GetstrC(*(sLiNE + iLine), 75);
|
||||
|
||||
if ((strcmp(*(sLiNE + iLine), "")) == 0)
|
||||
return;
|
||||
|
||||
iLine++;
|
||||
if(iLine >= 11)
|
||||
break;
|
||||
}
|
||||
|
||||
pout(14, 0, (char *)" <20>");
|
||||
for(iLoop = 0; iLoop <= 75; iLoop++)
|
||||
printf("<EFBFBD>");
|
||||
printf("<EFBFBD>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Save Abort File */
|
||||
int finish(void)
|
||||
{
|
||||
FILE *pTextFileANS, *pTextFileASC;
|
||||
int iStrLen, i, x, NLChk = FALSE;
|
||||
char *temp, *temp1;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
while (TRUE) {
|
||||
Enter(1);
|
||||
poutCR(15, 0, (char *) Language(113));
|
||||
Enter(1);
|
||||
/* (L)ist, (R)eplace text, (E)dit line, (A)bort, (S)ave */
|
||||
pout(15, 1, (char *) Language(114));
|
||||
Enter(2);
|
||||
|
||||
/* Select: */
|
||||
pout(15, 0, (char *) Language(115));
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
alarm_on();
|
||||
i = toupper(Getone());
|
||||
|
||||
if (i == Keystroke(114, 3)) {
|
||||
/* Aborting... */
|
||||
pout(15, 0, (char *) Language(116));
|
||||
Enter(1);
|
||||
Enter(1);
|
||||
pout(15, 0, (char *) Language(117));
|
||||
poutCR(15, 0, CFG.bbs_name);
|
||||
sleep(2);
|
||||
Syslog('+', "User aborted message and exited door");
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return TRUE;
|
||||
} else
|
||||
|
||||
if (i == Keystroke(114, 2)) {
|
||||
/* Edit which line: */
|
||||
printf("\n %s", (char *) Language(118));
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0)
|
||||
break;
|
||||
|
||||
i = atoi(temp);
|
||||
if( i > iLine - 1) {
|
||||
/* Line does not exist. */
|
||||
printf("%s\n", (char *) Language(119));
|
||||
break;
|
||||
}
|
||||
x = strlen(sLiNE[i]);
|
||||
printf("%d : %s", i, *(sLiNE + i));
|
||||
fflush(stdout);
|
||||
GetstrP(sLiNE[i],74, x);
|
||||
} else
|
||||
|
||||
if (i == Keystroke(114, 0)) {
|
||||
colour(14, 0);
|
||||
printf("\n\n <20>");
|
||||
for (iLoop = 0; iLoop <= 75; iLoop++)
|
||||
printf("<EFBFBD>");
|
||||
printf("<EFBFBD>");
|
||||
|
||||
for(i = 1; i < iLine; i++) {
|
||||
colour(12, 0);
|
||||
printf("%d: ", i);
|
||||
colour(9, 0);
|
||||
printf("%s\n", *(sLiNE + i));
|
||||
}
|
||||
|
||||
colour(14, 0);
|
||||
printf(" <20>");
|
||||
for (iLoop = 0; iLoop <= 75; iLoop++)
|
||||
printf("<EFBFBD>");
|
||||
printf("<EFBFBD>\n");
|
||||
} else
|
||||
|
||||
if (i == Keystroke(114, 4)) {
|
||||
/* Open TextFile for Writing NextUser Info */
|
||||
sprintf(temp, "%s/%s.ans", CFG.bbs_txtfiles, CFG.sNuScreen);
|
||||
sprintf(temp1, "%s/%s.ans.bak", CFG.bbs_txtfiles, CFG.sNuScreen);
|
||||
rename(temp, temp1);
|
||||
|
||||
if((pTextFileANS = fopen(temp, "w")) == NULL) {
|
||||
perror("");
|
||||
WriteError("NextUser: Can't open file: %s", temp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
sprintf(temp, "%s/%s.asc", CFG.bbs_txtfiles, CFG.sNuScreen);
|
||||
if(( pTextFileASC = fopen(temp, "w")) == NULL) {
|
||||
perror("");
|
||||
WriteError("NextUser: Can't open file: %s", temp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
fprintf(pTextFileANS,"%s%s%s%s",ANSI_CLEAR,ANSI_NORMAL,ANSI_WHITE,ANSI_BOLD);
|
||||
|
||||
if((iStrLen = strlen(sFrom)) > 1) {
|
||||
fprintf(pTextFileANS,"%s\x1B[1;4HFrom:%s %s\n",ANSI_RED,ANSI_BLUE,sFrom);
|
||||
fprintf(pTextFileASC,"\n From: %s\n", sFrom);
|
||||
Syslog('+', " From: %s", sFrom);
|
||||
NLChk = TRUE;
|
||||
}
|
||||
|
||||
if((iStrLen = strlen(To)) > 1) {
|
||||
fprintf(pTextFileANS,"%s\x1B[2;6HTo:%s %s\n",ANSI_RED,ANSI_BLUE,To);
|
||||
fprintf(pTextFileASC," To: %s\n", To);
|
||||
Syslog('+', " To: %s", To);
|
||||
NLChk = TRUE;
|
||||
}
|
||||
|
||||
if((iStrLen = strlen(Subject)) > 1) {
|
||||
fprintf(pTextFileANS,"%sSubject:%s %s\n\n",ANSI_RED,ANSI_BLUE,Subject);
|
||||
fprintf(pTextFileASC,"Subject: %s\n\n", Subject);
|
||||
Syslog('+', "Subject: %s", Subject);
|
||||
NLChk = TRUE;
|
||||
}
|
||||
|
||||
if(!NLChk) {
|
||||
fprintf(pTextFileANS, "\n");
|
||||
fprintf(pTextFileASC, "\n");
|
||||
}
|
||||
|
||||
fprintf(pTextFileANS,"%s<>",ANSI_YELLOW);
|
||||
for(iLoop = 0; iLoop <= 75; iLoop++) {
|
||||
fprintf(pTextFileANS,"<EFBFBD>");
|
||||
fprintf(pTextFileASC,"=");
|
||||
}
|
||||
fprintf(pTextFileANS,"<EFBFBD>\n");
|
||||
fprintf(pTextFileASC,"\n");
|
||||
|
||||
for(i = 0; i < iLine; i++) {
|
||||
if((iStrLen = strlen( *(sLiNE + i) )) > 0) {
|
||||
fprintf(pTextFileANS," %s%s\n",ANSI_BLUE, *(sLiNE + i));
|
||||
fprintf(pTextFileASC," %s\n", *(sLiNE + i));
|
||||
}
|
||||
}
|
||||
|
||||
Enter(2);
|
||||
pout(12, 0, (char *) Language(340));
|
||||
fprintf(pTextFileANS,"%s<>",ANSI_YELLOW);
|
||||
for(iLoop = 0; iLoop <= 75; iLoop++) {
|
||||
fprintf(pTextFileANS,"<EFBFBD>");
|
||||
fprintf(pTextFileASC,"=");
|
||||
}
|
||||
fprintf(pTextFileANS,"<EFBFBD>\n");
|
||||
fprintf(pTextFileASC,"\n");
|
||||
|
||||
fprintf(pTextFileANS,"%s%s",ANSI_RED,CFG.sNuQuote);
|
||||
fprintf(pTextFileASC,"%s", CFG.sNuQuote);
|
||||
|
||||
fclose(pTextFileANS);
|
||||
fclose(pTextFileASC);
|
||||
colour(9, 0);
|
||||
/* Returning to */
|
||||
printf("\n%s%s\n", (char *) Language(117), CFG.bbs_name);
|
||||
|
||||
Syslog('+', "User Saved Nextuser message and exited door");
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return TRUE;
|
||||
} else
|
||||
|
||||
if (i == Keystroke(114, 1)) {
|
||||
/* Edit which line: */
|
||||
colour(15, 0);
|
||||
printf("\n%s", (char *) Language(118));
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0)
|
||||
break;
|
||||
|
||||
i = atoi(temp);
|
||||
|
||||
if( i > iLine - 1) {
|
||||
/* Line does not exist. */
|
||||
printf("\n%s", (char *) Language(119));
|
||||
break;
|
||||
}
|
||||
|
||||
Enter(1);
|
||||
/* Line reads: */
|
||||
colour(15, 0);
|
||||
poutCR(15, 0, (char *) Language(186));
|
||||
printf("%2d: %s\n", i, *(sLiNE + i));
|
||||
|
||||
Enter(1);
|
||||
/* Text to replace: */
|
||||
pout(15, 0, (char *) Language(195));
|
||||
GetstrC(temp, 80);
|
||||
|
||||
if((strcmp(temp, "")) == 0)
|
||||
break;
|
||||
|
||||
/* Replacement text: */
|
||||
pout(15, 0, (char *) Language(196));
|
||||
GetstrC(temp1, 80);
|
||||
|
||||
if((strcmp(temp1, "")) == 0)
|
||||
break;
|
||||
|
||||
strreplace(*(sLiNE + i), temp, temp1);
|
||||
} else
|
||||
printf("\n");
|
||||
}
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#ifndef _NEXTUSER_H
|
||||
#define _NEXTUSER_H
|
||||
|
||||
void nextuser(void);
|
||||
|
||||
#endif
|
||||
|
307
mbsebbs/signature.c
Normal file
307
mbsebbs/signature.c
Normal file
@@ -0,0 +1,307 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
* Purpose ...............: Edit message signature.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
* 1971 BV IJmuiden
|
||||
* the Netherlands
|
||||
*
|
||||
* This file is part of MBSE BBS.
|
||||
*
|
||||
* This BBS is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* MBSE BBS is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../config.h"
|
||||
#include "../lib/libs.h"
|
||||
#include "../lib/memwatch.h"
|
||||
#include "../lib/mbse.h"
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/users.h"
|
||||
#include "../lib/records.h"
|
||||
#include "../lib/ansi.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/common.h"
|
||||
#include "signature.h"
|
||||
#include "funcs.h"
|
||||
#include "input.h"
|
||||
#include "language.h"
|
||||
#include "timeout.h"
|
||||
|
||||
|
||||
#define MAXSIGLINES 4
|
||||
#define LENSIGLINES 74
|
||||
|
||||
char sLiNE[MAXSIGLINES+1][LENSIGLINES+1]; /* Edit buffer */
|
||||
|
||||
|
||||
/*
|
||||
* Internal prototypes
|
||||
*/
|
||||
int editsignature(void);
|
||||
int loadsignature(void);
|
||||
|
||||
|
||||
/*
|
||||
* Edit signature file, called by menu 319
|
||||
*/
|
||||
void signature(void)
|
||||
{
|
||||
memset(&sLiNE, 0, sizeof(sLiNE));
|
||||
|
||||
if (loadsignature()) {
|
||||
while (TRUE) {
|
||||
if (editsignature() == TRUE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Enter(2);
|
||||
/* Returning to */
|
||||
pout(CFG.MoreF, CFG.MoreB, (char *) Language(117));
|
||||
poutCR(CFG.MoreF, CFG.MoreB, CFG.bbs_name);
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void toprow(void);
|
||||
void toprow(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
pout(YELLOW, BLACK, (char *)" <20>");
|
||||
for (i = 0; i < LENSIGLINES; i++)
|
||||
printf("<EFBFBD>");
|
||||
printf("<EFBFBD>\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void botrow(void);
|
||||
void botrow(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
pout(YELLOW, BLACK, (char *)" <20>");
|
||||
for (i = 0; i < LENSIGLINES; i++)
|
||||
printf("<EFBFBD>");
|
||||
printf("<EFBFBD>\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Load signature file in memory for editing.
|
||||
*/
|
||||
int loadsignature(void)
|
||||
{
|
||||
char *temp;
|
||||
FILE *fp;
|
||||
int i;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
|
||||
|
||||
if ((fp = fopen(temp, "r")) == NULL) {
|
||||
WriteError("$Can't load %s", temp);
|
||||
free(temp);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
clear();
|
||||
|
||||
/* Edit message signature */
|
||||
pout(WHITE, BLACK, (char *) Language(107));
|
||||
Enter(2);
|
||||
|
||||
Syslog('+', "%s will edit his .signature", exitinfo.sUserName);
|
||||
|
||||
i = 0;
|
||||
while (fgets(temp, LENSIGLINES+1, fp)) {
|
||||
Striplf(temp);
|
||||
strcpy(sLiNE[i], temp);
|
||||
i++;
|
||||
}
|
||||
fclose(fp);
|
||||
free(temp);
|
||||
|
||||
toprow();
|
||||
for (i = 0; i < MAXSIGLINES; i++) {
|
||||
colour(LIGHTRED, BLACK);
|
||||
printf("%d:", i+1);
|
||||
colour(CFG.MoreF, CFG.MoreB);
|
||||
printf("%s\n", sLiNE[i]);
|
||||
fflush(stdout);
|
||||
}
|
||||
botrow();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Edit signature file with a simple line editor.
|
||||
*/
|
||||
int editsignature(void)
|
||||
{
|
||||
FILE *fp;
|
||||
int i, x;
|
||||
char *temp, *temp1;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
|
||||
|
||||
while (TRUE) {
|
||||
Enter(1);
|
||||
/* Functions available: */
|
||||
poutCR(CFG.HiliteF, CFG.HiliteB, (char *) Language(113));
|
||||
Enter(1);
|
||||
/* (L)ist, (R)eplace text, (E)dit line, (A)bort, (S)ave */
|
||||
pout(YELLOW, RED, (char *) Language(114));
|
||||
Enter(2);
|
||||
|
||||
/* Select: */
|
||||
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(115));
|
||||
fflush(stdout);
|
||||
|
||||
alarm_on();
|
||||
i = toupper(Getone());
|
||||
Enter(1);
|
||||
|
||||
if (i == Keystroke(114, 3)) {
|
||||
/* Aborting... */
|
||||
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(116));
|
||||
Syslog('+', "User aborted .signature editor");
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return TRUE;
|
||||
|
||||
} else if (i == Keystroke(114, 2)) {
|
||||
/* Edit which line: */
|
||||
colour(CFG.HiliteF, CFG.HiliteB);
|
||||
printf("\n %s", (char *) Language(118));
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, 3);
|
||||
|
||||
if ((strcmp(temp, "")) == 0)
|
||||
break;
|
||||
|
||||
i = atoi(temp);
|
||||
if ((i < 1) || (i > MAXSIGLINES)) {
|
||||
/* Line does not exist. */
|
||||
printf("%s\n", (char *) Language(119));
|
||||
break;
|
||||
}
|
||||
|
||||
x = strlen(sLiNE[i-1]);
|
||||
colour(LIGHTRED, BLACK);
|
||||
printf("%d:", i);
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
printf("%s", sLiNE[i-1]);
|
||||
fflush(stdout);
|
||||
GetstrP(sLiNE[i-1], LENSIGLINES-1, x);
|
||||
|
||||
} else if (i == Keystroke(114, 0)) {
|
||||
/* List lines */
|
||||
toprow();
|
||||
for (i = 0; i < MAXSIGLINES; i++) {
|
||||
colour(LIGHTRED, BLACK);
|
||||
printf("%d:", i+1);
|
||||
colour(CFG.MoreF, CFG.MoreB);
|
||||
printf("%s\n", sLiNE[i]);
|
||||
}
|
||||
botrow();
|
||||
|
||||
} else if (i == Keystroke(114, 4)) {
|
||||
Enter(1);
|
||||
/* Saving... */
|
||||
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(340));
|
||||
|
||||
/* Open TextFile for Writing NextUser Info */
|
||||
sprintf(temp, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name);
|
||||
if ((fp = fopen(temp, "w")) == NULL) {
|
||||
WriteError("$Can't open %s", temp);
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return TRUE;
|
||||
}
|
||||
for (i = 0; i < MAXSIGLINES; i++) {
|
||||
if (strlen(sLiNE[i]))
|
||||
fprintf(fp, "%s\n", sLiNE[i]);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
Syslog('+', "User Saved .signature");
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return TRUE;
|
||||
|
||||
} else if (i == Keystroke(114, 1)) {
|
||||
/* Edit which line: */
|
||||
colour(CFG.HiliteF, CFG.HiliteB);
|
||||
printf("\n%s", (char *) Language(118));
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, 3);
|
||||
|
||||
if ((strcmp(temp, "")) == 0)
|
||||
break;
|
||||
|
||||
i = atoi(temp);
|
||||
|
||||
if ((i < 1) || (i > MAXSIGLINES)) {
|
||||
/* Line does not exist. */
|
||||
printf("\n%s", (char *) Language(119));
|
||||
break;
|
||||
}
|
||||
|
||||
Enter(1);
|
||||
/* Line reads: */
|
||||
poutCR(CFG.MoreF, CFG.MoreB, (char *) Language(186));
|
||||
printf("%d:%s\n", i, sLiNE[i-1]);
|
||||
|
||||
Enter(1);
|
||||
/* Text to replace: */
|
||||
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(195));
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp, LENSIGLINES-1);
|
||||
|
||||
if ((strcmp(temp, "")) == 0)
|
||||
break;
|
||||
|
||||
/* Replacement text: */
|
||||
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(196));
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(temp1, LENSIGLINES-1);
|
||||
|
||||
if ((strcmp(temp1, "")) == 0)
|
||||
break;
|
||||
strreplace(sLiNE[i-1], temp, temp1);
|
||||
|
||||
} else
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
free(temp);
|
||||
free(temp1);
|
||||
return FALSE;
|
||||
}
|
||||
|
8
mbsebbs/signature.h
Normal file
8
mbsebbs/signature.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _SIGNATURE_H
|
||||
#define _SIGNATURE_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
void signature(void);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user