From ce6749c55c2fdfc423d351acf8c7c4c71a016b55 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 29 Aug 2005 13:42:56 +0000 Subject: [PATCH] Fixed input editors --- mbsebbs/filesub.c | 2 +- mbsebbs/fsedit.c | 2 +- mbsebbs/input.c | 18 +++++++++--------- mbsebbs/oneline.c | 13 +++++++++---- mbsebbs/page.c | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/mbsebbs/filesub.c b/mbsebbs/filesub.c index 49356394..4feb137a 100644 --- a/mbsebbs/filesub.c +++ b/mbsebbs/filesub.c @@ -111,7 +111,7 @@ void GetstrD(char *sStr, int iMaxlen) if (ch > 31 && ch < 127) { if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else PUTCHAR(7); diff --git a/mbsebbs/fsedit.c b/mbsebbs/fsedit.c index e0e8f225..ec61168d 100644 --- a/mbsebbs/fsedit.c +++ b/mbsebbs/fsedit.c @@ -215,7 +215,7 @@ void GetstrLC(char *sStr, int iMaxlen) if ((ch > 31 && ch < 127) || traduce(&ch)) { if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else { Beep(); diff --git a/mbsebbs/input.c b/mbsebbs/input.c index f4778666..a50e99f7 100644 --- a/mbsebbs/input.c +++ b/mbsebbs/input.c @@ -352,7 +352,7 @@ void GetstrP(char *sStr, int iMaxLen, int Position) } else if ((ch > 31 && ch < 127) || traduce(&ch)) { if (iPos <= iMaxLen) { iPos++; - snprintf(sStr, iMaxLen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else { PUTCHAR('\007'); @@ -393,7 +393,7 @@ void GetstrC(char *sStr, int iMaxlen) if ((ch > 31) && (ch < 127) && (ch != ',')) { if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else PUTCHAR('\007'); @@ -433,7 +433,7 @@ void GetstrU(char *sStr, int iMaxlen) if (isalnum(ch) || (ch == '@') || (ch == '.') || (ch == '-') || (ch == '_')) { if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else PUTCHAR('\007'); @@ -474,7 +474,7 @@ void GetPhone(char *sStr, int iMaxlen) if ((ch >= '0' && ch <= '9') || (ch == '-') || (ch == '+')) { if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else PUTCHAR('\007'); @@ -516,7 +516,7 @@ void Getnum(char *sStr, int iMaxlen) if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else PUTCHAR('\007'); @@ -563,11 +563,11 @@ void GetDate(char *sStr, int iMaxlen) if (ch >= '0' && ch <= '9') { if (iPos < iMaxlen) { iPos++; - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); if (iPos == 2 || iPos == 5) { PUTCHAR('-'); - snprintf(sStr, iMaxlen, "%s-", sStr); + snprintf(sStr + strlen(sStr), 1, "-"); iPos++; } } else @@ -628,7 +628,7 @@ void Getname(char *sStr, int iMaxlen) if (iPos == 1 && CFG.iCapUserName) ch = toupper(ch); - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); printf("%c", ch); } else putchar('\007'); @@ -688,7 +688,7 @@ void GetnameNE(char *sStr, int iMaxlen) if (iPos == 1) ch = toupper(ch); - snprintf(sStr, iMaxlen, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); printf("%c", ch); } else putchar('\007'); diff --git a/mbsebbs/oneline.c b/mbsebbs/oneline.c index bb54ebd2..6dd40225 100644 --- a/mbsebbs/oneline.c +++ b/mbsebbs/oneline.c @@ -310,7 +310,7 @@ void Oneliner_Show() FILE *pOneline; int recno = 0; long offset; - char *sFileName, msg[11]; + char *sFileName, msg[81]; sFileName = calloc(PATH_MAX, sizeof(char)); snprintf(sFileName, PATH_MAX, "%s/etc/oneline.data", getenv("MBSE_ROOT")); @@ -320,15 +320,20 @@ void Oneliner_Show() return; } fread(&olhdr, sizeof(olhdr), 1, pOneline); + fseek(pOneline, 0, SEEK_END); + recno = (ftell(pOneline) - olhdr.hdrsize) / olhdr.recsize; Enter(1); /* Please enter number to list: */ - pout(WHITE, BLACK, Language(347)); + snprintf(msg, 81, "%s (1..%d) ", Language(347), recno -1); + pout(WHITE, BLACK, msg); colour(CFG.InputColourF, CFG.InputColourB); - scanf("%d", &recno); + msg[0] = '\0'; + Getnum(msg, 10); + recno = atoi(msg); offset = olhdr.hdrsize + (recno * olhdr.recsize); - if (fseek(pOneline, offset, 0) != 0) + if (fseek(pOneline, offset, SEEK_SET) != 0) WriteError("Can't move pointer in %s",sFileName); fread(&ol, olhdr.recsize, 1, pOneline); diff --git a/mbsebbs/page.c b/mbsebbs/page.c index b82e390a..c17f6fdb 100644 --- a/mbsebbs/page.c +++ b/mbsebbs/page.c @@ -247,7 +247,7 @@ void GetPageStr(char *sStr, int iMaxlen) if (ch > 31 && ch < 127) { if (iPos <= iMaxlen) { iPos++; - snprintf(sStr, 4, "%s%c", sStr, ch); + snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); fflush(stdout); } else