#include <config.h>
-#include <errno.h>
-#include <stdio.h>
#include "com.h"
#include "empio.h"
#include "empthread.h"
int
show_motd(void)
{
- FILE *motd_fp;
- struct telstr tgm;
- char buf[MAXTELSIZE + 1]; /* UTF-8 */
-
- if ((motd_fp = fopen(motdfil, "rb")) == NULL) {
- if (errno == ENOENT)
- return RET_OK;
- else {
- pr ("Could not open motd.\n");
- logerror("Could not open motd (%s).\n", motdfil);
- return RET_FAIL;
- }
- }
- if (fread(&tgm, sizeof(tgm), 1, motd_fp) != 1) {
- logerror("bad header on login message (motdfil)");
- fclose(motd_fp);
- return RET_FAIL;
- }
- if (tgm.tel_length >= (long)sizeof(buf)) {
- logerror("text length (%ld) is too long for login message (motdfil)", tgm.tel_length);
- fclose(motd_fp);
- return RET_FAIL;
- }
- if (fread(buf, tgm.tel_length, 1, motd_fp) != 1) {
- logerror("bad length %ld on login message", tgm.tel_length);
- fclose(motd_fp);
- return RET_FAIL;
- }
- buf[tgm.tel_length] = 0;
- uprnf(buf);
- fclose(motd_fp);
+ show_first_tel(motdfil);
return RET_OK;
}