Make struct telstr members tel_type and tel_length unsigned

They are simpler to use that way.
This commit is contained in:
Markus Armbruster 2009-02-07 19:58:59 +01:00
parent d2cd46ce20
commit 4c81ca34cb
6 changed files with 23 additions and 26 deletions

View file

@ -114,11 +114,7 @@ rea(void)
lasttype = -1;
while (fread(&tgm, sizeof(tgm), 1, telfp) == 1) {
readit = 1;
if (tgm.tel_length < 0) {
logerror("bad telegram file header in %s", mbox);
break;
}
if (tgm.tel_type < 0 || tgm.tel_type > TEL_LAST) {
if (tgm.tel_type > TEL_LAST) {
pr("Bad telegram header. Skipping telegram...\n");
readit = 0;
goto skip;
@ -146,7 +142,7 @@ rea(void)
pr("\n> ");
lastcnum = tgm.tel_from;
lasttype = tgm.tel_type;
pr("%s ", telnames[(int)tgm.tel_type]);
pr("%s ", telnames[tgm.tel_type]);
if ((tgm.tel_type == TEL_NORM) ||
(tgm.tel_type == TEL_ANNOUNCE) ||
(tgm.tel_type == TEL_BULLETIN))

View file

@ -52,6 +52,7 @@ turn(void)
char buf[1024];
char msgbuf[MAXTELSIZE + 1]; /* UTF-8 */
char *msgfilepath;
int len;
p = getstarg(player->argp[1], "on, off or motd? ", buf);
if (!p)
@ -76,14 +77,14 @@ turn(void)
else
pr("Enter a new message of the day.\n");
time(&tgm.tel_date);
tgm.tel_length = getele("The World", msgbuf);
if (tgm.tel_length < 0) {
len = getele("The World", msgbuf);
if (len < 0) {
pr("Ignored\n");
if (msgfilepath == downfil)
pr("NOT disabling logins.\n");
return RET_FAIL;
} else if (tgm.tel_length == 0) {
}
if (len == 0) {
if (msgfilepath == motdfil) {
pr("Removing exsting motd.\n");
if ((unlink(msgfilepath) == -1) && (errno != ENOENT)) {
@ -108,6 +109,8 @@ turn(void)
pr("Logins disabled.\n");
memset(&tgm, 0, sizeof(tgm));
time(&tgm.tel_date);
tgm.tel_length = len;
if ((fwrite(&tgm, sizeof(tgm), 1, fptr) != 1) ||
(fwrite(msgbuf, tgm.tel_length, 1, fptr) != 1)) {
fclose(fptr);