projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update contact info.
[oweals/busybox.git]
/
loadacm.c
diff --git
a/loadacm.c
b/loadacm.c
index 072562f6bef28090f597ce52e40bd03ff4f1436b..040062cf8ce69140343d67302a4f285a9ee92b8e 100644
(file)
--- a/
loadacm.c
+++ b/
loadacm.c
@@
-7,6
+7,7
@@
* Peter Novodvorsky <petya@logic.ru>
*/
* Peter Novodvorsky <petya@logic.ru>
*/
+#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
@@
-17,7
+18,6
@@
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
@@
-33,20
+33,22
@@
int loadacm_main(int argc, char **argv)
{
int fd;
{
int fd;
+ if (argc>=2 && *argv[1]=='-') {
+ usage(loadacm_usage);
+ }
+
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
- return 1;
+ perror_msg_and_die("Error opening /dev/tty1");
}
if (screen_map_load(fd, stdin)) {
}
if (screen_map_load(fd, stdin)) {
- fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
- return 1;
+ perror_msg_and_die("Error loading acm");
}
write(fd, "\033(K", 3);
}
write(fd, "\033(K", 3);
- return
0
;
+ return
EXIT_SUCCESS
;
}
int screen_map_load(int fd, FILE * fp)
}
int screen_map_load(int fd, FILE * fp)
@@
-57,8
+59,8
@@
int screen_map_load(int fd, FILE * fp)
int parse_failed = 0;
int is_unicode;
int parse_failed = 0;
int is_unicode;
- if (fstat(f
p->_fileno
, &stbuf))
- perror
("Cannot stat map file"), exit(1
);
+ if (fstat(f
ileno(fp)
, &stbuf))
+ perror
_msg_and_die("Cannot stat map file"
);
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
@@
-68,19
+70,16
@@
int screen_map_load(int fd, FILE * fp)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- fprintf(stderr,
- "16bit screen-map MUST be a regular file.\n"),
- exit(1);
+ error_msg_and_die("16bit screen-map MUST be a regular file.\n");
else
else
- perror("fseek failed reading binary 16bit screen-map"),
- exit(1);
+ perror_msg_and_die("fseek failed reading binary 16bit screen-map");
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
- perror
("Cannot read [new] map from file"), exit(1
);
+ perror
_msg_and_die("Cannot read [new] map from file"
);
#if 0
else
#if 0
else
-
fprintf(stderr,
"Input screen-map is binary.\n");
+
error_msg(
"Input screen-map is binary.\n");
#endif
}
#endif
}
@@
-88,7
+87,7
@@
int screen_map_load(int fd, FILE * fp)
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
- perror
("PIO_UNISCRNMAP ioctl"), exit(1
);
+ perror
_msg_and_die("PIO_UNISCRNMAP ioctl"
);
else
return 0;
}
else
return 0;
}
@@
-97,11
+96,10
@@
int screen_map_load(int fd, FILE * fp)
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- fprintf(stderr,
- "Assuming 8bit screen-map - MUST be a regular file.\n"),
+ error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
exit(1);
else
- perror
("fseek failed assuming 8bit screen-map"), exit(1
);
+ perror
_msg_and_die("fseek failed assuming 8bit screen-map"
);
}
/* ... and try an old 8-bit screen-map */
}
/* ... and try an old 8-bit screen-map */
@@
-111,28
+109,26
@@
int screen_map_load(int fd, FILE * fp)
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- fprintf(stderr, "fseek() returned ESPIPE !\n"),
- exit(1);
+ error_msg_and_die("fseek() returned ESPIPE !\n");
else
else
- perror
("fseek for binary 8bit screen-map"), exit(1
);
+ perror
_msg_and_die("fseek for binary 8bit screen-map"
);
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
- perror
("Cannot read [old] map from file"), exit(1
);
+ perror
_msg_and_die("Cannot read [old] map from file"
);
#if 0
else
#if 0
else
-
fprintf(stderr,
"Input screen-map is binary.\n");
+
error_msg(
"Input screen-map is binary.\n");
#endif
}
if (ioctl(fd, PIO_SCRNMAP, buf))
#endif
}
if (ioctl(fd, PIO_SCRNMAP, buf))
- perror
("PIO_SCRNMAP ioctl"), exit(1
);
+ perror
_msg_and_die("PIO_SCRNMAP ioctl"
);
else
return 0;
else
return 0;
- } else {
- fprintf(stderr, "Error parsing symbolic map\n");
- exit(1);
}
}
+ error_msg("Error parsing symbolic map\n");
+ return(1);
}
}
@@
-175,10
+171,8
@@
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
- else {
- perror("uni_screen_map_read_ascii() can't read line");
- exit(2);
- }
+ else
+ perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
}
/* get "charset-relative charcode", stripping leading spaces */
}
/* get "charset-relative charcode", stripping leading spaces */
@@
-318,32
+312,25
@@
void saveoldmap(int fd, char *omfil)
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
- perror("GIO_UNISCRNMAP ioctl error");
+ perror
_msg
("GIO_UNISCRNMAP ioctl error");
#endif
#endif
- if (ioctl(fd, GIO_SCRNMAP, buf)) {
- perror("GIO_SCRNMAP ioctl error");
- exit(1);
- } else
+ if (ioctl(fd, GIO_SCRNMAP, buf))
+ perror_msg_and_die("GIO_SCRNMAP ioctl error");
+ else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#endif
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#endif
- if ((fp = fopen(omfil, "w")) == NULL) {
- perror(omfil);
- exit(1);
- }
+ fp = xfopen(omfil, "w");
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
- if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
- perror("Error writing map to file");
- exit(1);
- }
+ if (fwrite(buf, E_TABSZ, 1, fp) != 1)
+ perror_msg_and_die("Error writing map to file");
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
- perror("Error writing map to file");
- exit(1);
+ perror_msg_and_die("Error writing map to file");
}
#endif
}
#endif
@@
-353,8
+340,8
@@
void saveoldmap(int fd, char *omfil)
unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
unicode utf8_to_ucs2(char *buf)
{
int utf_count = 0;
- long utf_char;
- unicode tc;
+ long utf_char
= 0
;
+ unicode tc
= 0
;
unsigned char c;
do {
unsigned char c;
do {