libbb: shrink print_login_issue (by Vladimir Dronnikov)
function old new delta print_login_issue 469 435 -34
This commit is contained in:
parent
52ec4b98d5
commit
ad6d6ffcdc
@ -20,7 +20,7 @@ static const char fmtstr_t[] ALIGN1 = "%H:%M:%S";
|
|||||||
|
|
||||||
void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
|
void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
|
||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fp;
|
||||||
int c;
|
int c;
|
||||||
char buf[256+1];
|
char buf[256+1];
|
||||||
const char *outbuf;
|
const char *outbuf;
|
||||||
@ -32,10 +32,10 @@ void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
|
|||||||
|
|
||||||
puts("\r"); /* start a new line */
|
puts("\r"); /* start a new line */
|
||||||
|
|
||||||
fd = fopen(issue_file, "r");
|
fp = fopen(issue_file, "r");
|
||||||
if (!fd)
|
if (!fp)
|
||||||
return;
|
return;
|
||||||
while ((c = fgetc(fd)) != EOF) {
|
while ((c = fgetc(fp)) != EOF) {
|
||||||
outbuf = buf;
|
outbuf = buf;
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
buf[1] = '\0';
|
buf[1] = '\0';
|
||||||
@ -44,7 +44,7 @@ void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
|
|||||||
buf[2] = '\0';
|
buf[2] = '\0';
|
||||||
}
|
}
|
||||||
if (c == '\\' || c == '%') {
|
if (c == '\\' || c == '%') {
|
||||||
c = fgetc(fd);
|
c = fgetc(fp);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 's':
|
case 's':
|
||||||
outbuf = uts.sysname;
|
outbuf = uts.sysname;
|
||||||
@ -64,8 +64,7 @@ void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
|
|||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'o':
|
case 'o':
|
||||||
c = getdomainname(buf, sizeof(buf) - 1);
|
outbuf = uts.domainname;
|
||||||
buf[c >= 0 ? c : 0] = '\0';
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
|
strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
|
||||||
@ -82,7 +81,7 @@ void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
|
|||||||
}
|
}
|
||||||
fputs(outbuf, stdout);
|
fputs(outbuf, stdout);
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fp);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user