#define RET_OK 0 /* command completed sucessfully */
#define RET_FAIL 1 /* command completed unsucessfully [?] */
#define RET_SYN 2 /* syntax error in command */
-#define RET_SYS 3 /* system error (missing file, etc) */
extern char *getstarg(char *input, char *prompt, char buf[]);
extern char *getstring(char *prompt, char buf[]);
return RET_OK;
}
if (!getloan(ltcp->num, lp)) {
- pr("loan_accept: can't read loan; get help!\n");
- return RET_SYS;
+ logerror("loan_accept: can't read loan");
+ pr("can't read loan; get help!\n");
+ return RET_FAIL;
}
if (lp->l_status == LS_FREE) { /* other guy retratcted already */
late(ltcp);
lp = <cp->u.l;
if (!getloan(ltcp->num, lp)) {
- pr("Decline: can't read loan; get help!\n");
- return RET_SYS;
+ logerror("loan_decline: can't read loan");
+ pr("can't read loan; get help!\n");
+ return RET_FAIL;
}
/* loan got accepted somehow between now and last time we checked */
if (lp->l_status == LS_SIGNED) {
}
lp->l_status = LS_FREE;
if (!putloan(ltcp->num, lp)) {
- pr("loan_decline: can't write loan; get help!\n");
- return RET_SYS;
+ logerror("loan_decline: can't write loan");
+ pr("can't write loan; get help!\n");
+ return RET_FAIL;
}
decline(ltcp);
return RET_OK;
return RET_OK;
}
if (!gettre(ltcp->num, tp)) {
- pr("Accept: can't read treaty; get help!\n");
- return RET_SYS;
+ pr("treaty_accept: can't read treaty");
+ pr("can't read treaty; get help!\n");
+ return RET_FAIL;
}
if (tp->trt_status == TS_FREE) { /* treaty offer withdrawn */
late(ltcp);
}
tp->trt_status = TS_SIGNED;
if (!puttre(ltcp->num, tp)) {
+ pr("treaty_accept: can't write treaty");
pr("Problem saving treaty; get help!\n");
- return RET_SYS;
+ return RET_FAIL;
}
accpt(ltcp);
pr("Treaty in effect until %s", ctime(&tp->trt_exp));
tp = <cp->u.t;
if (!gettre(ltcp->num, tp)) {
- pr("Decline: can't read treaty; get help!\n");
- return RET_SYS;
+ logerror("treaty_decline: can't read treaty");
+ pr("can't read treaty; get help!\n");
+ return RET_FAIL;
}
/* treaty got signed somehow between now and last time we read it */
if (tp->trt_status == TS_SIGNED) {
}
tp->trt_status = TS_FREE;
if (!puttre(ltcp->num, tp)) {
+ logerror("treaty_decline: can't write treaty");
pr("Problem saving treaty; get help!\n");
- return RET_SYS;
+ return RET_FAIL;
}
decline(ltcp);
return RET_OK;
if (info_dp == 0) {
pr("Can't open info dir\n");
logerror("Can't open info dir \"%s\"\n", infodir);
- return RET_SYS;
+ return RET_FAIL;
}
while ((dp = readdir(info_dp)) != 0) {
logerror("Cannot fstat for \"%s\" info file (%s)",
filename, strerror(errno));
fclose(fp);
- return RET_SYS;
+ return RET_FAIL;
}
if ((statb.st_mode & S_IFREG) == 0) {
pr("Error reading info file for %s\n", name);
logerror("The info file \"%s\" is not regular file\n", filename);
fclose(fp);
- return RET_SYS;
+ return RET_FAIL;
}
pr("Information on: %s Last modification date: %s",
name, ctime(&statb.st_mtime));
if (info_dp == NULL) {
pr("Can't open info dir \n");
logerror("Can't open info dir \"%s\"", infodir);
- return RET_SYS;
+ return RET_FAIL;
}
fbuf = malloc(256);
switch (GetLastError()) {
case ERROR_FILE_NOT_FOUND:
pr("Sorry, there is no info on %s\n", name);
- return RET_FAIL;
break;
case ERROR_PATH_NOT_FOUND:
pr("Can't open info dir\n");
logerror("Error (%lu) reading info dir(%s)\\file(%s)",
GetLastError(), infodir, filename);
}
- return RET_SYS;
+ return RET_FAIL;
}
do {
if ((fData.dwFileAttributes != (DWORD)-1) &&
logerror("The info file \"%s\" is not regular file\n",
filename);
fclose(fp);
- return RET_SYS;
+ return RET_FAIL;
}
}
logerror("Error (%lu) reading info dir(%s)\\file(%s)",
GetLastError(), infodir, filename);
}
- return RET_SYS;
+ return RET_FAIL;
}
fbuf = malloc(256);
trty.trt_cnb = recipient;
trty.trt_exp = j * SECS_PER_DAY + now;
if (!puttre(nstr.cur, &trty)) {
+ logerror("do_treaty: can't write treaty");
pr("Couldn't save treaty; get help.\n");
- return RET_SYS;
+ return RET_FAIL;
}
wu(0, recipient, "Treaty #%d proposed to you by %s\n",
nstr.cur, cname(player->cnum));
(void)time(&loan.l_lastpay);
loan.l_duedate = loan.l_ldur * SECS_PER_DAY + loan.l_lastpay;
if (!putloan(nstr.cur, &loan)) {
+ logerror("do_loan: can't save loan");
pr("Couldn't save loan; get help!\n");
- return RET_SYS;
+ return RET_FAIL;
}
pr("You have offered loan %d\n", nstr.cur);
wu(0, recipient, "Country #%d has offered you a loan (#%d)\n",
if (journal_reopen() < 0) {
pr("Can't reopen journal");
- return RET_SYS;
+ return RET_FAIL;
}
pr("Journal reopened.\n");
if (logreopen() < 0) {
pr("Can't reopen log");
- return RET_SYS;
+ return RET_FAIL;
}
pr("Log reopened.\n");
loan.l_amtpaid += payment;
}
if (!putloan(loan_num, &loan)) {
+ logerror("repa: can't write loan");
pr("Can't save loan; get help!\n");
- return RET_SYS;
+ return RET_FAIL;
}
return RET_OK;
}
pr("Can't find trade #%d!\n", trade.trd_unitid);
trade.trd_unitid = -1;
if (!puttrade(lotno, &trade)) {
+ logerror("trad: can't write trade");
pr("Couldn't save after getitem failed; get help!\n");
- return RET_SYS;
+ return RET_FAIL;
}
return RET_OK;
}
if ((unlink(downfil) == -1) && (errno != ENOENT)) {
pr("Could not remove no-login file, logins still disabled.\n");
logerror("Could not remove no-login file (%s).\n", downfil);
- return RET_SYS;
+ return RET_FAIL;
}
return RET_OK;
} else {
pr("Could not remove motd.\n");
logerror("Could not remove motd file (%s).\n",
msgfilepath);
- return RET_SYS;
+ return RET_FAIL;
}
return RET_OK;
} else
if (fptr == NULL) {
pr("Something went wrong opening the message file.\n");
logerror("Could not open message file (%s).\n", msgfilepath);
- return RET_SYS;
+ return RET_FAIL;
}
if (msgfilepath == downfil)
pr("Something went wrong writing the message file.\n");
logerror("Could not properly write message file (%s).\n",
msgfilepath);
- return RET_SYS;
+ return RET_FAIL;
}
if (fclose(fptr)) {
pr("Something went wrong closing the message.\n");
logerror("Could not properly close message file (%s).\n",
msgfilepath);
- return RET_SYS;
+ return RET_FAIL;
}
pr("\n");
case RET_SYN:
pr("Usage: %s\n", command->c_form);
break;
- case RET_SYS:
- logerror("System error, command failed: %s", command->c_form);
- break;
default:
CANT_REACH();
break;
else {
pr ("Could not open motd.\n");
logerror("Could not open motd (%s).\n", motdfil);
- return RET_SYS;
+ return RET_FAIL;
}
}
if (fread(&tgm, sizeof(tgm), 1, motd_fp) != 1) {