diff options
Diffstat (limited to 'mbbsd/cal.c')
-rw-r--r-- | mbbsd/cal.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/mbbsd/cal.c b/mbbsd/cal.c index fb0c2802..ee23879b 100644 --- a/mbbsd/cal.c +++ b/mbbsd/cal.c @@ -1,4 +1,4 @@ -/* $Id: cal.c,v 1.18 2002/07/21 09:26:02 in2 Exp $ */ +/* $Id: cal.c,v 1.19 2002/07/22 19:02:00 in2 Exp $ */ #include "bbs.h" /* ���� Multi play */ @@ -63,15 +63,16 @@ vice(int money, char *item) unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100; FILE *fp; demoney(-money); - sprintf(buf, BBSHOME "/home/%c/%s/%s", - cuser.userid[0], cuser.userid, VICE_NEW); + snprintf(buf, sizeof(buf), BBSHOME "/home/%c/%s/%s", + cuser.userid[0], cuser.userid, VICE_NEW); fp = fopen(buf, "a"); if (!fp) { return 0; } fprintf(fp, "%08d\n", viceserial); fclose(fp); - sprintf(buf, "%s ��F%d$ �s��[%08d]", item, money, viceserial); + snprintf(buf, sizeof(buf), + "%s ��F%d$ �s��[%08d]", item, money, viceserial); mail_id(cuser.userid, buf, "etc/vice.txt", "Ptt�g�ٳ�"); return 0; } @@ -117,7 +118,8 @@ osong(char *defaultid) } move(12, 0); clrtobot(); - sprintf(buf, "�˷R�� %s �w��Ө�ڮ�۰��I�q�t��\n", cuser.userid); + snprintf(buf, sizeof(buf), + "�˷R�� %s �w��Ө�ڮ�۰��I�q�t��\n", cuser.userid); outs(buf); trans_buffer[0] = 0; if (!defaultid) { @@ -141,7 +143,8 @@ osong(char *defaultid) } getdata_str(14, 0, "�Q�n�n��L(�o)��..:", say, sizeof(say), DOECHO, "�ڷR�p.."); - sprintf(save_title, "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); + snprintf(save_title, sizeof(save_title), + "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); getdata_str(16, 0, "�H��֪��H�c(�i��E-mail)?", receiver, sizeof(receiver), LCECHO, destid); @@ -167,7 +170,9 @@ osong(char *defaultid) return 0; } strlcpy(mail.owner, "�I�q��", sizeof(mail.owner)); - sprintf(mail.title, "�� %s �I�� %s ", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, destid); + snprintf(mail.title, sizeof(mail.title), + "�� %s �I�� %s ", + (ano[0] == 'y') ? "�ΦW��" : cuser.userid, destid); while (fgets(buf, 200, fp)) { char *po; @@ -182,17 +187,19 @@ osong(char *defaultid) } while ((po = strstr(buf, "<~Src~>"))) { po[0] = 0; - sprintf(genbuf, "%s%s%s", buf, (ano[0] == 'y') ? "�ΦW��" : cuser.userid, po + 7); + snprintf(genbuf, sizeof(genbuf), + "%s%s%s", buf, + (ano[0] == 'y') ? "�ΦW��" : cuser.userid, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } while ((po = strstr(buf, "<~Des~>"))) { po[0] = 0; - sprintf(genbuf, "%s%s%s", buf, destid, po + 7); + snprintf(genbuf, sizeof(genbuf), "%s%s%s", buf, destid, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } while ((po = strstr(buf, "<~Say~>"))) { po[0] = 0; - sprintf(genbuf, "%s%s%s", buf, say, po + 7); + snprintf(genbuf, sizeof(genbuf), "%s%s%s", buf, say, po + 7); strlcpy(buf, genbuf, sizeof(buf)); } fputs(buf, fp1); @@ -212,7 +219,8 @@ osong(char *defaultid) /* ��Ĥ@������ */ vice(200, "�I�q"); } - sprintf(save_title, "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); + snprintf(save_title, sizeof(save_title), + "%s:%s", (ano[0] == 'y') ? "�ΦW��" : cuser.userid, say); hold_mail(filename, destid); if (receiver[0]) { @@ -304,13 +312,14 @@ p_exmail() int n; if (cuser.exmailbox >= MAX_EXKEEPMAIL) { - sprintf(buf, "�e�q�̦h�W�[ %d �ʡA����A�R�F�C", MAX_EXKEEPMAIL); + snprintf(buf, sizeof(buf), + "�e�q�̦h�W�[ %d �ʡA����A�R�F�C", MAX_EXKEEPMAIL); outs(buf); refresh(); return 0; } - sprintf(buf, "�z���W�� %d �ʮe�q�A�٭n�A�R�h��?", - cuser.exmailbox); + snprintf(buf, sizeof(buf), + "�z���W�� %d �ʮe�q�A�٭n�A�R�h��?", cuser.exmailbox); getdata_str(b_lines - 2, 0, buf, ans, sizeof(ans), LCECHO, "10"); @@ -333,7 +342,7 @@ mail_redenvelop(char *from, char *to, int money, char mode) char genbuf[200]; fileheader_t fhdr; FILE *fp; - sprintf(genbuf, "home/%c/%s", to[0], to); + snprintf(genbuf, sizeof(genbuf), "home/%c/%s", to[0], to); stampfile(genbuf, &fhdr); if (!(fp = fopen(genbuf, "w"))) return; @@ -345,12 +354,12 @@ mail_redenvelop(char *from, char *to, int money, char mode) " §�����N���A�Я���...... ^_^\033[m\n" ,from, ctime(&now), to, money); fclose(fp); - sprintf(fhdr.title, "�۰]�i�_"); + snprintf(fhdr.title, sizeof(fhdr.title), "�۰]�i�_"); strlcpy(fhdr.owner, from, sizeof(fhdr.owner)); if (mode == 'y') vedit(genbuf, NA, NULL); - sprintf(genbuf, "home/%c/%s/.DIR", to[0], to); + snprintf(genbuf, sizeof(genbuf), "home/%c/%s/.DIR", to[0], to); append_record(genbuf, &fhdr, sizeof(fhdr)); } @@ -388,8 +397,8 @@ p_give() return 0; /* ú���|�N�S�����F */ deumoney(searchuser(id), money - tax); demoney(-money); - sprintf(genbuf, "%s\t��%s\t%d\t%s", cuser.userid, id, money - tax, - ctime(&now)); + snprintf(genbuf, sizeof(genbuf), "%s\t��%s\t%d\t%s", + cuser.userid, id, money - tax, ctime(&now)); log_file(FN_MONEY, genbuf); genbuf[0] = 'n'; getdata(3, 0, "�n�ۦ�Ѽg���]�U�ܡH[y/N]", genbuf, 2, LCECHO); @@ -474,7 +483,7 @@ cal() b[0] = '0'; b[1] = 0; move(b_lines - 1, 0); - sprintf(buf, "[%13.2f] [%c] ", a, ch); + snprintf(buf, sizeof(buf), "[%13.2f] [%c] ", a, ch); outs(buf); break; case '.': @@ -495,11 +504,11 @@ cal() if (strlen(b) > 13) break; if (flo || b[0] != '0') - sprintf(b, "%s%c", b, ch); + snprintf(b, sizeof(b), "%s%c", b, ch); else b[0] = ch; move(b_lines - 1, 0); - sprintf(buf, "[%13s] [%c]", b, mode[(int)cmode]); + snprintf(buf, sizeof(buf), "[%13s] [%c]", b, mode[(int)cmode]); outs(buf); break; case 'q': |