if (len != -1) {
path[len] = 0;
} else {
- errorMsg("%s: %s\n", proc, strerror(errno));
+ error_msg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
rc = Link(busybox, command);
if (rc) {
- errorMsg("%s: %s\n", command, strerror(errno));
+ error_msg("%s: %s\n", command, strerror(errno));
}
}
}
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
- fullRead(srcFd, magic, 6);
+ full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
- if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) {
+ if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
- if (fullRead(srcFd, arMagic, 8) != 8) {
- errorMsg("fatal error\n");
+ if (full_read(srcFd, arMagic, 8) != 8) {
+ error_msg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
- if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) {
+ if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH;
- fullRead(srcFd, tempName, entry->size);
+ full_read(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0';
/* read the second header for this entry */
if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName);
else {
- errorMsg("Invalid long filename\n");
+ error_msg("Invalid long filename\n");
return(FALSE);
}
}
usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
- fatalError("Cannot read %s\n", argv[optind]);
+ error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
- if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
- createPath(extractList->name, 0666);
+ if (is_directory(extractList->name, TRUE, NULL)==FALSE)
+ create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
}
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE)
- printf("%s %d/%d %8d %s ", modeString(extractList->mode),
+ printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
extractList->uid, extractList->gid,
- extractList->size, timeString(extractList->mtime));
+ extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name);
}
extractList=extractList->next;
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
- fullRead(srcFd, magic, 6);
+ full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
- if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) {
+ if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
- if (fullRead(srcFd, arMagic, 8) != 8) {
- errorMsg("fatal error\n");
+ if (full_read(srcFd, arMagic, 8) != 8) {
+ error_msg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
- if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) {
+ if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH;
- fullRead(srcFd, tempName, entry->size);
+ full_read(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0';
/* read the second header for this entry */
if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName);
else {
- errorMsg("Invalid long filename\n");
+ error_msg("Invalid long filename\n");
return(FALSE);
}
}
usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
- fatalError("Cannot read %s\n", argv[optind]);
+ error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
- if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
- createPath(extractList->name, 0666);
+ if (is_directory(extractList->name, TRUE, NULL)==FALSE)
+ create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
}
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE)
- printf("%s %d/%d %8d %s ", modeString(extractList->mode),
+ printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
extractList->uid, extractList->gid,
- extractList->size, timeString(extractList->mtime));
+ extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name);
}
extractList=extractList->next;
/* Diagnostic functions */
#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);}
+# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
method = (int) get_byte();
if (method != DEFLATED) {
- errorMsg("unknown method %d -- get newer version of gzip\n", method);
+ error_msg("unknown method %d -- get newer version of gzip\n", method);
exit_code = ERROR;
return -1;
}
int res = inflate();
if (res == 3) {
- errorMsg(memory_exhausted);
+ error_msg(memory_exhausted);
} else if (res != 0) {
- errorMsg("invalid compressed data--format violated\n");
+ error_msg("invalid compressed data--format violated\n");
}
} else {
- errorMsg("internal error, invalid method\n");
+ error_msg("internal error, invalid method\n");
}
/* Get the crc and original length */
/* Validate decompression */
if (orig_crc != updcrc(outbuf, 0)) {
- errorMsg("invalid compressed data--crc error\n");
+ error_msg("invalid compressed data--crc error\n");
}
if (orig_len != (ulg) bytes_out) {
- errorMsg("invalid compressed data--length error\n");
+ error_msg("invalid compressed data--length error\n");
}
/* Check if there are more entries in a pkzip file */
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
- fatalError( "data not read from terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
- fatalError( "data not written to terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (argc <= 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
exit(WARNING);
}
strcpy(ofname, ifname);
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg(memory_exhausted); \
+ if (array == NULL) error_msg(memory_exhausted); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
/* Diagnostic functions */
#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);}
+# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
(char *) window + start, length) != EQUAL) {
fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length);
- errorMsg("invalid match\n");
+ error_msg("invalid match\n");
}
if (verbose > 1) {
fprintf(stderr, "\\[%d,%d]", start - match, length);
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
- fatalError( "data not read from terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
- fatalError( "data not written to terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
#endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
- errorMsg("block vanished\n");
+ error_msg("block vanished\n");
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) {
- errorMsg("-l used on binary file\n");
+ error_msg("-l used on binary file\n");
}
}
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
- errorMsg(memory_exhausted);
+ error_msg(memory_exhausted);
oargv = *argvp;
*argvp = nargv;
/* Copy the program name first */
if (oargc-- < 0)
- errorMsg("argc<=0\n");
+ error_msg("argc<=0\n");
*(nargv++) = *(oargv++);
/* Then copy the environment args */
break;
case 'f':
if (*tarName != '-')
- fatalError( "Only one 'f' option allowed\n");
+ error_msg_and_die( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
- fatalError( "Option requires an argument: No file specified\n");
+ error_msg_and_die( "Option requires an argument: No file specified\n");
stopIt=TRUE;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv);
if (excludeList[excludeListSize] == NULL)
- fatalError( "Option requires an argument: No file specified\n");
+ error_msg_and_die( "Option requires an argument: No file specified\n");
/* Remove leading "/"s */
if (*excludeList[excludeListSize] =='/')
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
}
case 'X':
if (*excludeFileName != '-')
- fatalError("Only one 'X' option allowed\n");
+ error_msg_and_die("Only one 'X' option allowed\n");
excludeFileName = *(++argv);
if (excludeFileName == NULL)
- fatalError("Option requires an argument: No file specified\n");
+ error_msg_and_die("Option requires an argument: No file specified\n");
fileList = fopen (excludeFileName, "rt");
if (! fileList)
- fatalError("Exclude file: file not found\n");
+ error_msg_and_die("Exclude file: file not found\n");
while (!feof(fileList)) {
fscanf(fileList, "%s", file);
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
*/
if (createFlag == TRUE) {
#ifndef BB_FEATURE_TAR_CREATE
- fatalError( "This version of tar was not compiled with tar creation support.\n");
+ error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
#else
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
#endif
return EXIT_FAILURE;
flagError:
- fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n");
+ error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
}
static void
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
/* Create the path to the file, just in case it isn't there...
* This should not screw up path permissions or anything. */
- createPath(header->name, 0777);
+ create_path(header->name, 0777);
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
header->mode & ~S_IFMT)) < 0) {
- errorMsg(io_error, header->name, strerror(errno));
+ error_msg(io_error, header->name, strerror(errno));
return( FALSE);
}
}
readSize = size;
writeSize = size;
}
- if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) {
+ if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
/* Tarball seems to have a problem */
- errorMsg("Unexpected EOF in archive\n");
+ error_msg("Unexpected EOF in archive\n");
return( FALSE);
}
if ( readSize < writeSize )
/* Write out the file, if we are supposed to be doing that */
if (extractFlag==TRUE) {
- if ((actualWriteSz=fullWrite(outFd, buffer, writeSize)) != writeSize ) {
+ if ((actualWriteSz=full_write(outFd, buffer, writeSize)) != writeSize ) {
/* Output file seems to have a problem */
- errorMsg(io_error, header->name, strerror(errno));
+ error_msg(io_error, header->name, strerror(errno));
return( FALSE);
}
} else {
if (extractFlag==FALSE || tostdoutFlag==TRUE)
return( TRUE);
- if (createPath(header->name, header->mode) != TRUE) {
- errorMsg("%s: Cannot mkdir: %s\n",
+ if (create_path(header->name, header->mode) != TRUE) {
+ error_msg("%s: Cannot mkdir: %s\n",
header->name, strerror(errno));
return( FALSE);
}
/* make the final component, just in case it was
- * omitted by createPath() (which will skip the
+ * omitted by create_path() (which will skip the
* directory if it doesn't have a terminating '/') */
if (mkdir(header->name, header->mode) == 0) {
fixUpPermissions(header);
return( TRUE);
if (link(header->linkname, header->name) < 0) {
- errorMsg("%s: Cannot create hard link to '%s': %s\n",
+ error_msg("%s: Cannot create hard link to '%s': %s\n",
header->name, header->linkname, strerror(errno));
return( FALSE);
}
#ifdef S_ISLNK
if (symlink(header->linkname, header->name) < 0) {
- errorMsg("%s: Cannot create symlink to '%s': %s\n",
+ error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname, strerror(errno));
return( FALSE);
}
/* Do not change permissions or date on symlink,
* since it changes the pointed to file instead. duh. */
#else
- errorMsg("%s: Cannot create symlink to '%s': %s\n",
+ error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname,
"symlinks not supported");
#endif
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
- errorMsg("%s: Cannot mknod: %s\n",
+ error_msg("%s: Cannot mknod: %s\n",
header->name, strerror(errno));
return( FALSE);
}
} else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) {
- errorMsg("%s: Cannot mkfifo: %s\n",
+ error_msg("%s: Cannot mkfifo: %s\n",
header->name, strerror(errno));
return( FALSE);
}
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
- if ((size == 0) || !isOctal(*cp))
+ if ((size == 0) || !is_octal(*cp))
return -1;
- for(; (size > 0) && isOctal(*cp); size--) {
+ for(; (size > 0) && is_octal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
++*(header->name);
if (alreadyWarned == FALSE) {
- errorMsg("Removing leading '/' from member names\n");
+ error_msg("Removing leading '/' from member names\n");
alreadyWarned = TRUE;
}
}
else
tarFd = open(tarName, O_RDONLY);
if (tarFd < 0) {
- errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
+ error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
return ( FALSE);
}
umask(0);
/* Read the tar file, and iterate over it one file at a time */
- while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
+ while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
/* Try to read the header */
if ( readTarHeader(&rawHeader, &header) == FALSE ) {
goto endgame;
} else {
errorFlag=TRUE;
- errorMsg("Bad tar header, skipping\n");
+ error_msg("Bad tar header, skipping\n");
continue;
}
}
}
if ( skipNextHeaderFlag == TRUE ) {
skipNextHeaderFlag=FALSE;
- errorMsg(name_longer_than_foo, NAME_SIZE);
+ error_msg(name_longer_than_foo, NAME_SIZE);
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
continue;
char buf[35];
struct tm *tm = localtime (&(header.mtime));
- len=printf("%s ", modeString(header.mode));
+ len=printf("%s ", mode_string(header.mode));
memset(buf, 0, 8*sizeof(char));
my_getpwuid(buf, header.uid);
if (! *buf)
break;
#endif
default:
- errorMsg("Unknown file type '%c' in tar file\n", header.type);
+ error_msg("Unknown file type '%c' in tar file\n", header.type);
close( tarFd);
return( FALSE);
}
close(tarFd);
if (status > 0) {
/* Bummer - we read a partial header */
- errorMsg( "Error reading '%s': %s\n", tarName, strerror(errno));
+ error_msg( "Error reading '%s': %s\n", tarName, strerror(errno));
return ( FALSE);
}
else if (errorFlag==TRUE) {
- errorMsg( "Error exit delayed from previous errors\n");
+ error_msg( "Error exit delayed from previous errors\n");
return( FALSE);
} else
return( status);
close( tarFd);
if (extractList != NULL) {
for (; *extractList != NULL; extractList++) {
- errorMsg("%s: Not found in archive\n", *extractList);
+ error_msg("%s: Not found in archive\n", *extractList);
errorFlag = TRUE;
}
}
if ( *(header.name) == '\0' ) {
if (errorFlag==TRUE)
- errorMsg( "Error exit delayed from previous errors\n");
+ error_msg( "Error exit delayed from previous errors\n");
else
return( TRUE);
}
if (*fileName=='/') {
static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) {
- errorMsg("Removing leading '/' from member names\n");
+ error_msg("Removing leading '/' from member names\n");
alreadyWarned=TRUE;
}
strncpy(header.name, fileName+1, sizeof(header.name));
header.typeflag = SYMTYPE;
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
if ( link_size < 0) {
- errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
+ error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
return ( FALSE);
}
buffer[link_size] = '\0';
header.typeflag = REGTYPE;
putOctal(header.size, sizeof(header.size), statbuf->st_size);
} else {
- errorMsg("%s: Unknown file type\n", fileName);
+ error_msg("%s: Unknown file type\n", fileName);
return ( FALSE);
}
putOctal(header.chksum, 7, chksum);
/* Now write the header out to disk */
- if ((size=fullWrite(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
- errorMsg(io_error, fileName, strerror(errno));
+ if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
+ error_msg(io_error, fileName, strerror(errno));
return ( FALSE);
}
/* Pad the header up to the tar block size */
/* It is against the rules to archive a socket */
if (S_ISSOCK(statbuf->st_mode)) {
- errorMsg("%s: socket ignored\n", fileName);
+ error_msg("%s: socket ignored\n", fileName);
return( TRUE);
}
* the new tarball */
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
tbInfo->statBuf.st_ino == statbuf->st_ino) {
- errorMsg("%s: file is the archive; skipping\n", fileName);
+ error_msg("%s: file is the archive; skipping\n", fileName);
return( TRUE);
}
if (strlen(fileName) >= NAME_SIZE) {
- errorMsg(name_longer_than_foo, NAME_SIZE);
+ error_msg(name_longer_than_foo, NAME_SIZE);
return ( TRUE);
}
/* open the file we want to archive, and make sure all is well */
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
- errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno));
+ error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
return( FALSE);
}
/* write the file to the archive */
- while ( (size = fullRead(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
- if (fullWrite(tbInfo->tarFd, buffer, size) != size ) {
+ while ( (size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
+ if (full_write(tbInfo->tarFd, buffer, size) != size ) {
/* Output file seems to have a problem */
- errorMsg(io_error, fileName, strerror(errno));
+ error_msg(io_error, fileName, strerror(errno));
return( FALSE);
}
readSize+=size;
}
if (size == -1) {
- errorMsg(io_error, fileName, strerror(errno));
+ error_msg(io_error, fileName, strerror(errno));
return( FALSE);
}
/* Pad the file up to the tar block size */
/* Make sure there is at least one file to tar up. */
if (*argv == NULL)
- fatalError("Cowardly refusing to create an empty archive\n");
+ error_msg_and_die("Cowardly refusing to create an empty archive\n");
/* Open the tar file for writing. */
if (!strcmp(tarName, "-"))
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tbInfo.tarFd < 0) {
- errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
+ error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
freeHardLinkInfo(&tbInfo.hlInfoHead);
return ( FALSE);
}
/* Store the stat info for the tarball's file, so
* can avoid including the tarball into itself.... */
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
- fatalError(io_error, tarName, strerror(errno));
+ error_msg_and_die(io_error, tarName, strerror(errno));
/* Set the umask for this process so it doesn't
* screw up permission setting for us later. */
/* Read the directory/files and iterate over them one at a time */
while (*argv != NULL) {
- if (recursiveAction(*argv++, TRUE, FALSE, FALSE,
+ if (recursive_action(*argv++, TRUE, FALSE, FALSE,
writeFileToTarball, writeFileToTarball,
(void*) &tbInfo) == FALSE) {
errorFlag = TRUE;
/* Hang up the tools, close up shop, head home */
close(tarFd);
if (errorFlag == TRUE) {
- errorMsg("Error exit delayed from previous errors\n");
+ error_msg("Error exit delayed from previous errors\n");
freeHardLinkInfo(&tbInfo.hlInfoHead);
return(FALSE);
}
if (len != -1) {
path[len] = 0;
} else {
- errorMsg("%s: %s\n", proc, strerror(errno));
+ error_msg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
rc = Link(busybox, command);
if (rc) {
- errorMsg("%s: %s\n", command, strerror(errno));
+ error_msg("%s: %s\n", command, strerror(errno));
}
}
}
#define BUF_SIZE 8192
#define EXPAND_ALLOC 1024
-static inline int isDecimal(ch) { return ((ch >= '0') && (ch <= '9')); }
-static inline int isOctal(ch) { return ((ch >= '0') && (ch <= '7')); }
+static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
+static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */
#ifndef MIN
extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn));
-extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-extern void perrorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void fatalPerror(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-
-const char *modeString(int mode);
-const char *timeString(time_t timeVal);
-int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
+extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+
+const char *mode_string(int mode);
+const char *time_string(time_t timeVal);
+int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name);
typedef struct ino_dev_hash_bucket_struct {
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
-int copyFile(const char *srcName, const char *destName,
+int copy_file(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag);
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
char *buildName(const char *dirName, const char *fileName);
char *getChunk(int size);
char *chunkstrdup(const char *str);
void freeChunks(void);
-int fullWrite(int fd, const char *buf, int len);
-int fullRead(int fd, char *buf, int len);
-int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
+int full_write(int fd, const char *buf, int len);
+int full_read(int fd, char *buf, int len);
+int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData);
-extern int createPath (const char *name, int mode);
+extern int create_path (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode);
extern int get_kernel_revision(void);
extern int get_console_fd(char* tty_name);
-extern struct mntent *findMountPoint(const char *name, const char *table);
+extern struct mntent *find_mount_point(const char *name, const char *table);
extern void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name);
extern char *mtab_next(void **iter);
extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
-extern long getNum (const char *cp);
-extern pid_t* findPidByName( char* pidName);
+extern long atoi_w_units (const char *cp);
+extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name);
extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file);
case CHMOD_APP:
/* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
- fatalError( "unknown mode: %s\n", theMode);
+ error_msg_and_die( "unknown mode: %s\n", theMode);
}
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
}
if (argc == 0 || *argv == NULL) {
- errorMsg(too_few_args);
+ error_msg(too_few_args);
}
if (whichApp == CHMOD_APP) {
if (*argv == p)
uid = my_getpwnam(*argv);
if (uid == -1) {
- fatalError( "unknown user name: %s\n", *argv);
+ error_msg_and_die( "unknown user name: %s\n", *argv);
}
}
}
/* Ok, ready to do the deed now */
if (argc < 1) {
- fatalError(too_few_args);
+ error_msg_and_die(too_few_args);
}
while (argc-- > 1) {
- if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
+ if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE)
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
bad_group:
- fatalError( "unknown group name: %s\n", groupName);
+ error_msg_and_die( "unknown group name: %s\n", groupName);
}
/*
argv++;
if (chroot(*argv) || (chdir("/"))) {
- fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
+ error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
}
argc--;
return EXIT_SUCCESS;
#endif
}
- fatalError("cannot execute %s: %s\n", prog, strerror(errno));
+ error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
}
cmdedit_termw = w;
cmdedit_scroll = w / 3;
} else {
- errorMsg("\n*** Error: minimum screen width is 21\n");
+ error_msg("\n*** Error: minimum screen width is 21\n");
}
}
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
- errorMsg("0: illegal VT number\n");
+ error_msg("0: illegal VT number\n");
else if (num == 1)
- errorMsg("VT 1 cannot be deallocated\n");
+ error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
- fatalError("could not deallocate console %d\n", num);
+ error_msg_and_die("could not deallocate console %d\n", num);
}
}
printf("erik: C\n");
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
+ error_msg("Error opening /dev/tty0: %s\n", strerror(errno));
return EXIT_FAILURE;
}
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
- errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
+ error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,(void*)&ke.kb_value,2);
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
- errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
+ error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (screen_map_load(fd, stdin)) {
- errorMsg("Error loading acm: %s\n", strerror(errno));
+ error_msg("Error loading acm: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- errorMsg("16bit screen-map MUST be a regular file.\n"),
+ error_msg("16bit screen-map MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed reading binary 16bit screen-map"),
perror("Cannot read [new] map from file"), exit(1);
#if 0
else
- errorMsg("Input screen-map is binary.\n");
+ error_msg("Input screen-map is binary.\n");
#endif
}
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- errorMsg("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
perror("fseek failed assuming 8bit screen-map"), exit(1);
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- errorMsg("fseek() returned ESPIPE !\n"),
+ error_msg("fseek() returned ESPIPE !\n"),
exit(1);
else
perror("fseek for binary 8bit screen-map"), exit(1);
perror("Cannot read [old] map from file"), exit(1);
#if 0
else
- errorMsg("Input screen-map is binary.\n");
+ error_msg("Input screen-map is binary.\n");
#endif
}
else
return 0;
}
- errorMsg("Error parsing symbolic map\n");
+ error_msg("Error parsing symbolic map\n");
return(1);
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
- fatalPerror("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening /dev/tty0");
loadnewfont(fd);
return EXIT_SUCCESS;
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32)
- fatalError("Bad character size %d\n", unit);
+ error_msg_and_die("Bad character size %d\n", unit);
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */
- perrorMsg("PIO_FONTX ioctl error (trying PIO_FONT)");
+ perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
}
#endif
if (ioctl(fd, PIO_FONT, buf))
- fatalPerror("PIO_FONT ioctl error");
+ perror_msg_and_die("PIO_FONT ioctl error");
}
static void
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
- errorMsg("It seems this kernel is older than 1.1.92\n");
- fatalError("No Unicode mapping table loaded.\n");
+ error_msg("It seems this kernel is older than 1.1.92\n");
+ error_msg_and_die("No Unicode mapping table loaded.\n");
} else
#endif
- fatalPerror("PIO_UNIMAPCLR");
+ perror_msg_and_die("PIO_UNIMAPCLR");
}
ud.entry_ct = ct;
ud.entries = up;
/* change advice parameters */
}
#endif
- fatalPerror("PIO_UNIMAP");
+ perror_msg_and_die("PIO_UNIMAP");
}
}
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin))
- fatalPerror("Error reading input font");
+ perror_msg_and_die("Error reading input font");
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin))
- fatalPerror("Font too large");
+ perror_msg_and_die("Font too large");
/* test for psf first */
{
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE)
- fatalError("Unsupported psf file mode\n");
+ error_msg_and_die("Unsupported psf file mode\n");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256)
- fatalError("Only fontsize 256 supported\n");
+ error_msg_and_die("Only fontsize 256 supported\n");
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth))
- fatalError("Input file: bad length\n");
+ error_msg_and_die("Input file: bad length\n");
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
} else {
/* bare font */
if (inputlth & 0377)
- fatalError("Bad input file size\n");
+ error_msg_and_die("Bad input file size\n");
offset = 0;
unit = inputlth / 256;
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
- fatalPerror("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
- fatalError("This is not a valid binary keymap.\n");
+ error_msg_and_die("This is not a valid binary keymap.\n");
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
- fatalPerror("Error reading keymap flags");
+ perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz);
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
- fatalPerror("Error reading keymap");
+ perror_msg_and_die("Error reading keymap");
pos += readsz;
}
for (j = 0; j < NR_KEYS; j++) {
a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) {
- fatalError("error reading SCANCODE: '%s'\n", argv[1]);
+ error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
}
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (a.scancode > 255 || a.keycode > 127) {
- fatalError("SCANCODE or KEYCODE outside bounds\n");
+ error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
}
if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE");
- fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
+ error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
}
argc -= 2;
argv += 2;
argv++;
if (chroot(*argv) || (chdir("/"))) {
- fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
+ error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
}
argc--;
return EXIT_SUCCESS;
#endif
}
- fatalError("cannot execute %s: %s\n", prog, strerror(errno));
+ error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
}
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
- fatalError("invalid byte or field list\n");
+ error_msg_and_die("invalid byte or field list\n");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
- fatalError("invalid byte or field list\n");
+ error_msg_and_die("invalid byte or field list\n");
}
}
}
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
- fatalError("missing list of fields\n");
+ error_msg_and_die("missing list of fields\n");
}
endpos = startpos;
}
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
- fatalError("only one type of list may be specified");
+ error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
- fatalError("the delimiter must be a single character\n");
+ error_msg_and_die("the delimiter must be a single character\n");
}
delim = optarg[0];
break;
}
if (part == 0) {
- fatalError("you must specify a list of bytes, characters, or fields\n");
+ error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
}
if (supress_non_delimited_lines && part != 'f') {
- fatalError("suppressing non-delimited lines makes sense
+ error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
- fatalError("a delimiter may be specified only when operating on fields\n");
+ error_msg_and_die("a delimiter may be specified only when operating on fields\n");
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
- errorMsg("%s: %s\n", argv[i], strerror(errno));
+ error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
cut_file(file);
fclose(file);
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
- fatalError(invalid_date, t_string);
+ error_msg_and_die(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
- fatalError(invalid_date, t_string);
+ error_msg_and_die(invalid_date, t_string);
}
*tm_time = t;
return (tm_time);
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
break;
case 'd':
use_arg = 1;
}
#if 0
else {
- errorMsg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
+ error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage);
}
#endif
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
- fatalError(invalid_date, date_str);
+ error_msg_and_die(invalid_date, date_str);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
- perrorMsg("cannot set date");
+ perror_msg("cannot set date");
}
}
}
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
- count = getNum((strchr(*argv, '=')) + 1);
+ count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) {
- errorMsg("Bad count value %s\n", *argv);
+ error_msg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
- blockSize = getNum((strchr(*argv, '=')) + 1);
+ blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
- errorMsg("Bad block size value %s\n", *argv);
+ error_msg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
- skipBlocks = getNum((strchr(*argv, '=')) + 1);
+ skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
- errorMsg("Bad skip value %s\n", *argv);
+ error_msg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
- seekBlocks = getNum((strchr(*argv, '=')) + 1);
+ seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
- errorMsg("Bad seek value %s\n", *argv);
+ error_msg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
* here anyways... */
/* free(buf); */
- fatalPerror("%s", inFile);
+ perror_msg_and_die("%s", inFile);
}
if (outFile == NULL)
/* close(inFd);
free(buf); */
- fatalPerror("%s", outFile);
+ perror_msg_and_die("%s", outFile);
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
ibs=BUFSIZ;
while (totalSize > outTotal) {
- inCc = fullRead(inFd, buf, ibs);
+ inCc = full_read(inFd, buf, ibs);
inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs)
buf[inCc++]='\0';
- if ((outCc = fullWrite(outFd, buf, inCc)) < 1){
+ if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){
perror("Error during write");
}
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
- perrorMsg("%s", mountPoint);
+ perror_msg("%s", mountPoint);
return FALSE;
}
usage(df_usage);
}
while (argc > 1) {
- if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
- errorMsg("%s: can't find mount point.\n", argv[1]);
+ if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
+ error_msg("%s: can't find mount point.\n", argv[1]);
status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
- perrorMsg("%s", mtab_file);
+ perror_msg("%s", mtab_file);
return EXIT_FAILURE;
}
}
if (len + strlen(name) + 1 > BUFSIZ) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
du_depth--;
return 0;
}
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
- if (sum && isDirectory(argv[i], FALSE, NULL)) {
+ if (sum && is_directory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
return status;
}
-/* $Id: du.c,v 1.28 2000/12/06 15:56:31 kraai Exp $ */
+/* $Id: du.c,v 1.29 2000/12/07 19:56:48 markw Exp $ */
/*
Local Variables:
c-file-style: "linux"
VALUE *v;
if (argc == 1) {
- fatalError("too few arguments\n");
+ error_msg_and_die("too few arguments\n");
}
args = argv + 1;
v = eval ();
if (*args)
- fatalError ("syntax error\n");
+ error_msg_and_die ("syntax error\n");
if (v->type == integer)
printf ("%d\n", v->u.i);
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
- fatalError ("non-numeric argument\n"); \
+ error_msg_and_die ("non-numeric argument\n"); \
return l->u.i op r->u.i; \
}
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
- fatalError ( "non-numeric argument\n"); \
+ error_msg_and_die ( "non-numeric argument\n"); \
if (r->u.i == 0) \
- fatalError ( "division by zero\n"); \
+ error_msg_and_die ( "division by zero\n"); \
return l->u.i op r->u.i; \
}
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
- fatalError("%s\n", errmsg);
+ error_msg_and_die("%s\n", errmsg);
}
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
VALUE *v;
if (!*args)
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
if (nextarg ("(")) {
args++;
v = eval ();
if (!nextarg (")"))
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
args++;
return v;
}
if (nextarg (")"))
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
return str_value (*args++);
}
if (nextarg ("quote")) {
args++;
if (!*args)
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
return str_value (*args++);
}
else if (nextarg ("length")) {
}
head(len, fp);
if (errno) {
- errorMsg("%s: %s\n", argv[optind], strerror(errno));
+ error_msg("%s: %s\n", argv[optind], strerror(errno));
status = EXIT_FAILURE;
errno = 0;
}
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
if (gid == -1 || pwnam==-1 || grnam==-1) {
- fatalError("%s: No such user\n", user);
+ error_msg_and_die("%s: No such user\n", user);
}
if (no_group)
printf("%ld\n", pwnam);
strcpy(srcName, link_SrcName);
if (flag&LN_NODEREFERENCE)
- srcIsDir = isDirectory(srcName, TRUE, NULL);
+ srcIsDir = is_directory(srcName, TRUE, NULL);
else
- srcIsDir = isDirectory(srcName, FALSE, NULL);
+ srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/");
puts(user);
return EXIT_SUCCESS;
}
- fatalError("no login name\n");
+ error_msg_and_die("no login name\n");
}
#ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
- errorMsg("%s: %s\n", cur->fullname, strerror(errno));
+ error_msg("%s: %s\n", cur->fullname, strerror(errno));
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
} else
#endif
if (lstat(cur->fullname, &cur->dstat)) {
- errorMsg("%s: %s\n", cur->fullname, strerror(errno));
+ error_msg("%s: %s\n", cur->fullname, strerror(errno));
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
- errorMsg("%s: %s\n", path, strerror(errno));
+ error_msg("%s: %s\n", path, strerror(errno));
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}
column += 5;
break;
case LIST_MODEBITS:
- fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode));
+ fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
- errorMsg("%s: %s\n", filename, strerror(errno));
+ error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
- errorMsg("%s: %s\n", filename, strerror(errno));
+ error_msg("%s: %s\n", filename, strerror(errno));
if (fp != stdin)
fclose(fp);
}
if (fp != stdin && fclose(fp) == EOF) {
- errorMsg("%s: %s\n", filename, strerror(errno));
+ error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
- errorMsg("%s: %s\n", checkfile_name, strerror(errno));
+ error_msg("%s: %s\n", checkfile_name, strerror(errno));
return FALSE;
}
}
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
if (warn) {
- errorMsg("%s: %lu: improperly formatted MD5 checksum line\n",
+ error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
checkfile_name, (unsigned long) line_number);
}
} else {
free(line);
if (ferror(checkfile_stream)) {
- errorMsg("%s: read error\n", checkfile_name); /* */
+ error_msg("%s: read error\n", checkfile_name); /* */
return FALSE;
}
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
- errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
+ error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
return FALSE;
}
if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */
- errorMsg("%s: no properly formatted MD5 checksum lines found\n",
+ error_msg("%s: no properly formatted MD5 checksum lines found\n",
checkfile_name);
return FALSE;
} else {
- n_open_or_read_failures);
if (n_open_or_read_failures > 0) {
- errorMsg("WARNING: %d of %d listed files could not be read\n",
+ error_msg("WARNING: %d of %d listed files could not be read\n",
n_open_or_read_failures, n_properly_formated_lines);
return FALSE;
}
if (n_mismatched_checksums > 0) {
- errorMsg("WARNING: %d of %d computed checksums did NOT match\n",
+ error_msg("WARNING: %d of %d computed checksums did NOT match\n",
n_mismatched_checksums, n_computed_checkums);
return FALSE;
}
}
if (file_type_specified && do_check) {
- errorMsg("the -b and -t options are meaningless when verifying checksums\n");
+ error_msg("the -b and -t options are meaningless when verifying checksums\n");
return EXIT_FAILURE;
}
if (n_strings > 0 && do_check) {
- errorMsg("the -g and -c options are mutually exclusive\n");
+ error_msg("the -g and -c options are mutually exclusive\n");
return EXIT_FAILURE;
}
if (status_only && !do_check) {
- errorMsg("the -s option is meaningful only when verifying checksums\n");
+ error_msg("the -s option is meaningful only when verifying checksums\n");
return EXIT_FAILURE;
}
if (warn && !do_check) {
- errorMsg("the -w option is meaningful only when verifying checksums\n");
+ error_msg("the -w option is meaningful only when verifying checksums\n");
return EXIT_FAILURE;
}
size_t i;
if (optind < argc) {
- errorMsg("no files may be specified when using -g\n");
+ error_msg("no files may be specified when using -g\n");
return EXIT_FAILURE;
}
for (i = 0; i < n_strings; ++i) {
}
} else if (do_check) {
if (optind + 1 < argc) {
- errorMsg("only one argument may be specified when using -c\n");
+ error_msg("only one argument may be specified when using -c\n");
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
}
if (fclose (stdout) == EOF) {
- errorMsg("write error\n");
+ error_msg("write error\n");
return EXIT_FAILURE;
}
if (have_read_stdin && fclose (stdin) == EOF) {
- errorMsg("standard input\n");
+ error_msg("standard input\n");
return EXIT_FAILURE;
}
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
- errorMsg("Unknown mode: %s\n", *argv);
+ error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE;
}
/* Set the umask for this process so it doesn't
char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
return EXIT_FAILURE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
- errorMsg("%s: File exists\n", buf);
+ error_msg("%s: File exists\n", buf);
return EXIT_FAILURE;
}
if (parentFlag == TRUE) {
strcat(buf, "/");
- createPath(buf, mode);
+ create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
- fatalError("%s: %s\n", argv[0], strerror(errno));
+ error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
return EXIT_SUCCESS;
}
char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL)
- fatalError("%s\n", strerror(errno));
+ error_msg_and_die("%s\n", strerror(errno));
printf("%s\n", buf);
return EXIT_SUCCESS;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (unlink(fileName) < 0) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
&& errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */
} else {
- if (recursiveAction(srcName, recursiveFlag, FALSE,
+ if (recursive_action(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
status = EXIT_FAILURE;
}
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
- perrorMsg("%s", *argv);
+ perror_msg("%s", *argv);
status = EXIT_FAILURE;
}
}
break;
#endif
default:
- errorMsg("invalid option -- %c\n", opt);
+ error_msg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
return(0);
}
-/* $Id: sort.c,v 1.23 2000/09/28 17:49:59 beppu Exp $ */
+/* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */
usage(tail_usage);
break;
default:
- errorMsg("\nUnknown arg: %c.\n\n",optopt);
+ error_msg("\nUnknown arg: %c.\n\n",optopt);
usage(tail_usage);
}
}
else
fd[test] = open(files[test], O_RDONLY);
if (fd[test] == -1)
- fatalError("Unable to open file %s.\n", files[test]);
+ error_msg_and_die("Unable to open file %s.\n", files[test]);
tail_stream(fd[test]);
bs=BUFSIZ;
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--;
- errorMsg("%s: %s\n", argv[optind-1], strerror(errno));
+ error_msg("%s: %s\n", argv[optind-1], strerror(errno));
status = 1;
}
}
if (strcmp(applet_name, "[") == 0) {
if (strcmp(argv[--argc], "]"))
- fatalError("missing ]\n");
+ error_msg_and_die("missing ]\n");
argv[argc] = NULL;
}
/* Implement special cases from POSIX.2, section 4.62.4 */
char *msg;
{
if (op && *op)
- fatalError("%s: %s\n", op, msg);
+ error_msg_and_die("%s: %s\n", op, msg);
else
- fatalError("%s\n", msg);
+ error_msg_and_die("%s\n", msg);
}
static int
r = strtol(s, &p, 10);
if (errno != 0)
- fatalError("%s: out of range\n", s);
+ error_msg_and_die("%s: out of range\n", s);
while (isspace(*p))
p++;
if (*p)
- fatalError("%s: bad number\n", s);
+ error_msg_and_die("%s: bad number\n", s);
return (int) r;
}
if (create == FALSE && errno == ENOENT)
return EXIT_SUCCESS;
else {
- fatalError("%s", strerror(errno));
+ error_msg_and_die("%s", strerror(errno));
}
}
close(fd);
if (utime(*argv, NULL)) {
- fatalError("%s", strerror(errno));
+ error_msg_and_die("%s", strerror(errno));
}
argc--;
argv++;
input_length = complement(input, input_length);
if (argv[index] != NULL) {
if (*argv[index] == '\0')
- fatalError("STRING2 cannot be empty\n");
+ error_msg_and_die("STRING2 cannot be empty\n");
output_length = expand(argv[index], output);
map(input, input_length, output, output_length);
}
char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
- errorMsg("%s: Short file\n", inname);
+ error_msg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
if (fgets (buf, sizeof(buf), stdin) == NULL
|| strcmp (buf, "end\n")) {
- errorMsg("%s: No `end' line\n", inname);
+ error_msg("%s: No `end' line\n", inname);
return FALSE;
}
unsigned char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
- errorMsg("%s: Short file\n", inname);
+ error_msg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
if (memcmp (buf, "====", 4) == 0)
break;
if (last_data != 0) {
- errorMsg("%s: data following `=' padding character\n", inname);
+ error_msg("%s: data following `=' padding character\n", inname);
return FALSE;
}
while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=') {
- errorMsg("%s: illegal line\n", inname);
+ error_msg("%s: illegal line\n", inname);
return FALSE;
}
c2 = b64_tab[*p++];
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
- errorMsg("%s: illegal line\n", inname);
+ error_msg("%s: illegal line\n", inname);
return FALSE;
}
if (*p == '=') {
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
- errorMsg("%s: illegal line\n", inname);
+ error_msg("%s: illegal line\n", inname);
return FALSE;
}
putchar (c1 << 2 | c2 >> 4);
while (1) {
if (fgets (buf, sizeof (buf), stdin) == NULL) {
- errorMsg("%s: No `begin' line\n", inname);
+ error_msg("%s: No `begin' line\n", inname);
return FALSE;
}
while (*p != '/')
++p;
if (*p == '\0') {
- errorMsg("%s: Illegal ~user\n", inname);
+ error_msg("%s: Illegal ~user\n", inname);
return FALSE;
}
*p++ = '\0';
pw = getpwnam (buf + 1);
if (pw == NULL) {
- errorMsg("%s: No user `%s'\n", inname, buf + 1);
+ error_msg("%s: No user `%s'\n", inname, buf + 1);
return FALSE;
}
n = strlen (pw->pw_dir);
&& (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
- errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
+ error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
return FALSE;
}
if (decode (argv[optind], outname) != 0)
exit_status = FALSE;
} else {
- errorMsg("%s: %s\n", argv[optind], strerror(errno));
+ error_msg("%s: %s\n", argv[optind], strerror(errno));
exit_status = EXIT_FAILURE;
}
optind++;
}
if (ferror (stdin))
- errorMsg("Read error\n");
+ error_msg("Read error\n");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
- errorMsg("%s: %s\n", argv[optind], strerror(errno));
+ error_msg("%s: %s\n", argv[optind], strerror(errno));
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
- errorMsg("Write error\n");
+ error_msg("Write error\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
puts(user);
return EXIT_SUCCESS;
}
- fatalError("cannot find username for UID %u\n", (unsigned) uid);
+ error_msg_and_die("cannot find username for UID %u\n", (unsigned) uid);
}
static
void name_too_long__exit (void)
{
- fatalError(name_too_long);
+ error_msg_and_die(name_too_long);
}
static void
if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) {
- errorMsg(omitting_directory, baseSrcName);
+ error_msg(omitting_directory, baseSrcName);
return TRUE;
}
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
return FALSE;
}
strcat(destName, srcBasename);
if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) {
- errorMsg("rename(%s, %s): %s\n", fileName, destName,
+ error_msg("rename(%s, %s): %s\n", fileName, destName,
strerror(errno));
goto do_copyFile; /* Try anyway... */
}
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) {
- errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno));
+ error_msg("link(%s, %s): %s\n", name, destName, strerror(errno));
return FALSE;
}
return TRUE;
add_to_ino_dev_hashtable(statbuf, destName);
}
}
- return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag);
+ return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
}
static int
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
- errorMsg("rmdir(%s): %s\n", fileName, strerror(errno));
+ error_msg("rmdir(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
} else if (unlink(fileName) < 0) {
- errorMsg("unlink(%s): %s\n", fileName, strerror(errno));
+ error_msg("unlink(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
return status;
if (strlen(argv[argc - 1]) > BUFSIZ) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
goto exit_false;
}
strcpy(baseDestName, argv[argc - 1]);
if (baseDestLen == 0)
goto exit_false;
- destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
+ destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
if (argc - optind > 2 && destDirFlag == FALSE) {
- errorMsg(not_a_directory, baseDestName);
+ error_msg(not_a_directory, baseDestName);
goto exit_false;
}
if (srcLen == 0) continue; /* "" */
- srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf);
+ srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
if ((flags_memo = (recursiveFlag == TRUE &&
srcDirFlag == TRUE && destDirFlag == TRUE))) {
char *pushd, *d, *p;
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
- errorMsg("getcwd(): %s\n", strerror(errno));
+ error_msg("getcwd(): %s\n", strerror(errno));
continue;
}
if (chdir(baseDestName) < 0) {
- errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno));
+ error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno));
continue;
}
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
- errorMsg("getcwd(): %s\n", strerror(errno));
+ error_msg("getcwd(): %s\n", strerror(errno));
continue;
}
while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
- errorMsg("stat(%s): %s\n", d, strerror(errno));
+ error_msg("stat(%s): %s\n", d, strerror(errno));
state = -1;
continue;
}
if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) {
- errorMsg("Cannot %s `%s' into a subdirectory of itself, "
+ error_msg("Cannot %s `%s' into a subdirectory of itself, "
"`%s/%s'\n", applet_name, baseSrcName,
baseDestName, baseSrcName);
state = -1;
}
}
if (chdir(pushd) < 0) {
- errorMsg("chdir(%s): %s\n", pushd, strerror(errno));
+ error_msg("chdir(%s): %s\n", pushd, strerror(errno));
free(pushd);
free(d);
continue;
status = setjmp(catch);
if (status == 0) {
mv_Action_first_time = 1;
- if (recursiveAction(baseSrcName,
+ if (recursive_action(baseSrcName,
recursiveFlag, followLinks, FALSE,
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
if (dz_i == is_mv &&
- recursiveAction(baseSrcName,
+ recursive_action(baseSrcName,
recursiveFlag, followLinks, TRUE,
rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
}
/* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') {
- fatalError("invalid byte or field list\n");
+ error_msg_and_die("invalid byte or field list\n");
}
if (*ptr == '-') {
nminus++;
if (nminus > 1) {
- fatalError("invalid byte or field list\n");
+ error_msg_and_die("invalid byte or field list\n");
}
}
}
if (nminus == 0) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
- fatalError("missing list of fields\n");
+ error_msg_and_die("missing list of fields\n");
}
endpos = startpos;
}
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
- fatalError("only one type of list may be specified");
+ error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
decompose_list(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
- fatalError("the delimiter must be a single character\n");
+ error_msg_and_die("the delimiter must be a single character\n");
}
delim = optarg[0];
break;
}
if (part == 0) {
- fatalError("you must specify a list of bytes, characters, or fields\n");
+ error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
}
if (supress_non_delimited_lines && part != 'f') {
- fatalError("suppressing non-delimited lines makes sense
+ error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
- fatalError("a delimiter may be specified only when operating on fields\n");
+ error_msg_and_die("a delimiter may be specified only when operating on fields\n");
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
- errorMsg("%s: %s\n", argv[i], strerror(errno));
+ error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
cut_file(file);
fclose(file);
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
- fatalError(invalid_date, t_string);
+ error_msg_and_die(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
- fatalError(invalid_date, t_string);
+ error_msg_and_die(invalid_date, t_string);
}
*tm_time = t;
return (tm_time);
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
break;
case 'd':
use_arg = 1;
}
#if 0
else {
- errorMsg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
+ error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage);
}
#endif
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
- fatalError(invalid_date, date_str);
+ error_msg_and_die(invalid_date, date_str);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
- perrorMsg("cannot set date");
+ perror_msg("cannot set date");
}
}
}
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
- fatalError("stack overflow\n");
+ error_msg_and_die("stack overflow\n");
stack[pointer++] = a;
}
static double pop()
{
if (pointer == 0)
- fatalError("stack underflow\n");
+ error_msg_and_die("stack underflow\n");
return stack[--pointer];
}
}
o++;
}
- fatalError("%s: syntax error.\n", argument);
+ error_msg_and_die("%s: syntax error.\n", argument);
}
/* return pointer to next token in buffer and set *buffer to one char
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
- count = getNum((strchr(*argv, '=')) + 1);
+ count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) {
- errorMsg("Bad count value %s\n", *argv);
+ error_msg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
- blockSize = getNum((strchr(*argv, '=')) + 1);
+ blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
- errorMsg("Bad block size value %s\n", *argv);
+ error_msg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
- skipBlocks = getNum((strchr(*argv, '=')) + 1);
+ skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
- errorMsg("Bad skip value %s\n", *argv);
+ error_msg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
- seekBlocks = getNum((strchr(*argv, '=')) + 1);
+ seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
- errorMsg("Bad seek value %s\n", *argv);
+ error_msg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
* here anyways... */
/* free(buf); */
- fatalPerror("%s", inFile);
+ perror_msg_and_die("%s", inFile);
}
if (outFile == NULL)
/* close(inFd);
free(buf); */
- fatalPerror("%s", outFile);
+ perror_msg_and_die("%s", outFile);
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
ibs=BUFSIZ;
while (totalSize > outTotal) {
- inCc = fullRead(inFd, buf, ibs);
+ inCc = full_read(inFd, buf, ibs);
inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs)
buf[inCc++]='\0';
- if ((outCc = fullWrite(outFd, buf, inCc)) < 1){
+ if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){
perror("Error during write");
}
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
- errorMsg("0: illegal VT number\n");
+ error_msg("0: illegal VT number\n");
else if (num == 1)
- errorMsg("VT 1 cannot be deallocated\n");
+ error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
- fatalError("could not deallocate console %d\n", num);
+ error_msg_and_die("could not deallocate console %d\n", num);
}
}
printf("erik: C\n");
long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) {
- perrorMsg("%s", mountPoint);
+ perror_msg("%s", mountPoint);
return FALSE;
}
usage(df_usage);
}
while (argc > 1) {
- if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
- errorMsg("%s: can't find mount point.\n", argv[1]);
+ if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
+ error_msg("%s: can't find mount point.\n", argv[1]);
status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE;
mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) {
- perrorMsg("%s", mtab_file);
+ perror_msg("%s", mtab_file);
return EXIT_FAILURE;
}
}
if (len + strlen(name) + 1 > BUFSIZ) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
du_depth--;
return 0;
}
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
- if (sum && isDirectory(argv[i], FALSE, NULL)) {
+ if (sum && is_directory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
return status;
}
-/* $Id: du.c,v 1.28 2000/12/06 15:56:31 kraai Exp $ */
+/* $Id: du.c,v 1.29 2000/12/07 19:56:48 markw Exp $ */
/*
Local Variables:
c-file-style: "linux"
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
+ error_msg("Error opening /dev/tty0: %s\n", strerror(errno));
return EXIT_FAILURE;
}
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
- errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
+ error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,(void*)&ke.kb_value,2);
} else {
file = open(argv[1], O_RDONLY);
if (file < 0) {
- fatalError(io_error, argv[1], strerror(errno));
+ error_msg_and_die(io_error, argv[1], strerror(errno));
}
}
else if (my_str[idx] == '/') {
idx = index_of_next_unescaped_slash(my_str, ++idx);
if (idx == -1)
- fatalError("unterminated match expression\n");
+ error_msg_and_die("unterminated match expression\n");
my_str[idx] = '\0';
*regex = (regex_t *)xmalloc(sizeof(regex_t));
xregcomp(*regex, my_str+1, 0);
idx++; /* so it points to the next character after the last '/' */
}
else {
- errorMsg("get_address: no address found in string\n"
+ error_msg("get_address: no address found in string\n"
"\t(you probably didn't check the string you passed me)\n");
idx = -1;
}
/* verify that the 's' is followed by a 'slash' */
if (substr[++idx] != '/')
- fatalError("bad format in substitution expression\n");
+ error_msg_and_die("bad format in substitution expression\n");
/* save the match string */
oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx);
if (idx == -1)
- fatalError("bad format in substitution expression\n");
+ error_msg_and_die("bad format in substitution expression\n");
match = strdup_substr(substr, oldidx, idx);
/* determine the number of back references in the match string */
oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx);
if (idx == -1)
- fatalError("bad format in substitution expression\n");
+ error_msg_and_die("bad format in substitution expression\n");
sed_cmd->replace = strdup_substr(substr, oldidx, idx);
/* process the flags */
if (strchr("; \t\v\n\r", substr[idx]))
goto out;
/* else */
- fatalError("bad option in substitution expression\n");
+ error_msg_and_die("bad option in substitution expression\n");
}
}
*/
if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r'))
- fatalError("bad format in edit expression\n");
+ error_msg_and_die("bad format in edit expression\n");
/* store the edit line text */
/* make editline big enough to accomodate the extra '\n' we will tack on
/* last part (mandatory) will be a command */
if (cmdstr[idx] == '\0')
- fatalError("missing command\n");
+ error_msg_and_die("missing command\n");
if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */
- fatalError("invalid command\n");
+ error_msg_and_die("invalid command\n");
sed_cmd->cmd = cmdstr[idx];
/* special-case handling for (s)ubstitution */
/* special-case handling for (a)ppend, (i)nsert, and (c)hange */
else if (strchr("aic", cmdstr[idx])) {
if (sed_cmd->end_line || sed_cmd->end_match)
- fatalError("only a beginning address can be specified for edit commands\n");
+ error_msg_and_die("only a beginning address can be specified for edit commands\n");
idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]);
}
/* if it was a single-letter command (such as 'p' or 'd') we need to
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
- errorMsg("%s: %s\n", argv[i], strerror(errno));
+ error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
process_file(file);
fclose(file);
VALUE *v;
if (argc == 1) {
- fatalError("too few arguments\n");
+ error_msg_and_die("too few arguments\n");
}
args = argv + 1;
v = eval ();
if (*args)
- fatalError ("syntax error\n");
+ error_msg_and_die ("syntax error\n");
if (v->type == integer)
printf ("%d\n", v->u.i);
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
- fatalError ("non-numeric argument\n"); \
+ error_msg_and_die ("non-numeric argument\n"); \
return l->u.i op r->u.i; \
}
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
- fatalError ( "non-numeric argument\n"); \
+ error_msg_and_die ( "non-numeric argument\n"); \
if (r->u.i == 0) \
- fatalError ( "division by zero\n"); \
+ error_msg_and_die ( "division by zero\n"); \
return l->u.i op r->u.i; \
}
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
- fatalError("%s\n", errmsg);
+ error_msg_and_die("%s\n", errmsg);
}
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
VALUE *v;
if (!*args)
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
if (nextarg ("(")) {
args++;
v = eval ();
if (!nextarg (")"))
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
args++;
return v;
}
if (nextarg (")"))
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
return str_value (*args++);
}
if (nextarg ("quote")) {
args++;
if (!*args)
- fatalError ( "syntax error\n");
+ error_msg_and_die ( "syntax error\n");
return str_value (*args++);
}
else if (nextarg ("length")) {
}
}
#else
- errorMsg( "mode reading not compiled in\n");
+ error_msg( "mode reading not compiled in\n");
#endif
return 0;
}
PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
- errorMsg("Unknown video mode `%s'\n", mode);
+ error_msg("Unknown video mode `%s'\n", mode);
return EXIT_FAILURE;
}
}
break;
}
- if (recursiveAction(directory, TRUE, FALSE, FALSE,
+ if (recursive_action(directory, TRUE, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
break;
}
- if (recursiveAction(directory, TRUE, FALSE, FALSE,
+ if (recursive_action(directory, TRUE, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
file = fopen(cur_file, "r");
if (file == NULL) {
if (!suppress_err_msgs)
- errorMsg("%s: %s\n", cur_file, strerror(errno));
+ error_msg("%s: %s\n", cur_file, strerror(errno));
}
else {
grep_file(file);
}
if ((f = open(argv[1], O_RDWR)) == -1) {
- fatalError( "cannot open %s: %s\n", argv[1], strerror(errno));
+ error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno));
}
if (ioctl(f, BLKFLSBUF) < 0) {
- fatalError( "failed ioctl on %s: %s\n", argv[1], strerror(errno));
+ error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno));
}
/* Don't bother closing. Exit does
* that, so we can save a few bytes */
static void die(const char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s\n", str);
leave(8);
}
* <misiek@misiek.eu.org>)
* Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
* Removed --version/-V and --help/-h in
- * Removed prase_error(), using errorMsg() from Busybox instead
+ * Removed prase_error(), using error_msg() from Busybox instead
* Replaced our_malloc with xmalloc and our_realloc with xrealloc
*
*/
arg_opt=required_argument;
}
if (strlen(tokptr) == 0)
- errorMsg("empty long option after -l or --long argument\n");
+ error_msg("empty long option after -l or --long argument\n");
}
add_longopt(tokptr,arg_opt);
}
else if (!strcmp(new_shell,"csh"))
shell=TCSH;
else
- errorMsg("unknown shell after -s or --shell argument\n");
+ error_msg("unknown shell after -s or --shell argument\n");
}
printf(" --\n");
exit(0);
} else
- fatalError("missing optstring argument\n");
+ error_msg_and_die("missing optstring argument\n");
}
if (argv[1][0] != '-' || compatible) {
if (!optstr) {
if (optind >= argc)
- fatalError("missing optstring argument\n");
+ error_msg_and_die("missing optstring argument\n");
else {
optstr=xmalloc(strlen(argv[optind])+1);
strcpy(optstr,argv[optind]);
file = fopen(cur_file, "r");
if (file == NULL) {
if (!suppress_err_msgs)
- errorMsg("%s: %s\n", cur_file, strerror(errno));
+ error_msg("%s: %s\n", cur_file, strerror(errno));
}
else {
grep_file(file);
/* Diagnostic functions */
#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);}
+# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
method = (int) get_byte();
if (method != DEFLATED) {
- errorMsg("unknown method %d -- get newer version of gzip\n", method);
+ error_msg("unknown method %d -- get newer version of gzip\n", method);
exit_code = ERROR;
return -1;
}
int res = inflate();
if (res == 3) {
- errorMsg(memory_exhausted);
+ error_msg(memory_exhausted);
} else if (res != 0) {
- errorMsg("invalid compressed data--format violated\n");
+ error_msg("invalid compressed data--format violated\n");
}
} else {
- errorMsg("internal error, invalid method\n");
+ error_msg("internal error, invalid method\n");
}
/* Get the crc and original length */
/* Validate decompression */
if (orig_crc != updcrc(outbuf, 0)) {
- errorMsg("invalid compressed data--crc error\n");
+ error_msg("invalid compressed data--crc error\n");
}
if (orig_len != (ulg) bytes_out) {
- errorMsg("invalid compressed data--length error\n");
+ error_msg("invalid compressed data--length error\n");
}
/* Check if there are more entries in a pkzip file */
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
- fatalError( "data not read from terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
- fatalError( "data not written to terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (argc <= 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
exit(WARNING);
}
strcpy(ofname, ifname);
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg(memory_exhausted); \
+ if (array == NULL) error_msg(memory_exhausted); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
/* Diagnostic functions */
#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);}
+# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
(char *) window + start, length) != EQUAL) {
fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length);
- errorMsg("invalid match\n");
+ error_msg("invalid match\n");
}
if (verbose > 1) {
fprintf(stderr, "\\[%d,%d]", start - match, length);
}
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
- fatalError( "data not read from terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
- fatalError( "data not written to terminal. Use -f to force it.\n");
+ error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
#endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
- errorMsg("block vanished\n");
+ error_msg("block vanished\n");
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) {
- errorMsg("-l used on binary file\n");
+ error_msg("-l used on binary file\n");
}
}
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
- errorMsg(memory_exhausted);
+ error_msg(memory_exhausted);
oargv = *argvp;
*argvp = nargv;
/* Copy the program name first */
if (oargc-- < 0)
- errorMsg("argc<=0\n");
+ error_msg("argc<=0\n");
*(nargv++) = *(oargv++);
/* Then copy the environment args */
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(findPidByName("init")), SIGUSR1));
+ return(kill(*(find_pid_by_name("init")), SIGUSR1));
#else
return(kill(1, SIGUSR1));
#endif
}
head(len, fp);
if (errno) {
- errorMsg("%s: %s\n", argv[optind], strerror(errno));
+ error_msg("%s: %s\n", argv[optind], strerror(errno));
status = EXIT_FAILURE;
errno = 0;
}
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.15 2000/10/12 22:30:31 andersen Exp $
+ * $Id: hostname.c,v 1.16 2000/12/07 19:56:48 markw Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- errorMsg("you must be root to change the hostname\n");
+ error_msg("you must be root to change the hostname\n");
else
perror("sethostname");
exit(1);
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
if (gid == -1 || pwnam==-1 || grnam==-1) {
- fatalError("%s: No such user\n", user);
+ error_msg_and_die("%s: No such user\n", user);
}
if (no_group)
printf("%ld\n", pwnam);
#define BUF_SIZE 8192
#define EXPAND_ALLOC 1024
-static inline int isDecimal(ch) { return ((ch >= '0') && (ch <= '9')); }
-static inline int isOctal(ch) { return ((ch >= '0') && (ch <= '7')); }
+static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
+static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */
#ifndef MIN
extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn));
-extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-extern void perrorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
-extern void fatalPerror(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
-
-const char *modeString(int mode);
-const char *timeString(time_t timeVal);
-int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
+extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+
+const char *mode_string(int mode);
+const char *time_string(time_t timeVal);
+int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name);
typedef struct ino_dev_hash_bucket_struct {
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void);
-int copyFile(const char *srcName, const char *destName,
+int copy_file(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag);
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
char *buildName(const char *dirName, const char *fileName);
char *getChunk(int size);
char *chunkstrdup(const char *str);
void freeChunks(void);
-int fullWrite(int fd, const char *buf, int len);
-int fullRead(int fd, char *buf, int len);
-int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
+int full_write(int fd, const char *buf, int len);
+int full_read(int fd, char *buf, int len);
+int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData);
-extern int createPath (const char *name, int mode);
+extern int create_path (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode);
extern int get_kernel_revision(void);
extern int get_console_fd(char* tty_name);
-extern struct mntent *findMountPoint(const char *name, const char *table);
+extern struct mntent *find_mount_point(const char *name, const char *table);
extern void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name);
extern char *mtab_next(void **iter);
extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
-extern long getNum (const char *cp);
-extern pid_t* findPidByName( char* pidName);
+extern long atoi_w_units (const char *cp);
+extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name);
extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file);
unsigned int result, u, s=10;
if (sysinfo(&info) != 0) {
- perrorMsg("Error checking free memory: ");
+ perror_msg("Error checking free memory: ");
return -1;
}
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(findPidByName("init")), SIGUSR1));
+ return(kill(*(find_pid_by_name("init")), SIGUSR1));
#else
return(kill(1, SIGUSR1));
#endif
unsigned int result, u, s=10;
if (sysinfo(&info) != 0) {
- perrorMsg("Error checking free memory: ");
+ perror_msg("Error checking free memory: ");
return -1;
}
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(findPidByName("init")), SIGUSR2));
+ return(kill(*(find_pid_by_name("init")), SIGUSR2));
#else
return(kill(1, SIGUSR2));
#endif
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(findPidByName("init")), SIGINT));
+ return(kill(*(find_pid_by_name("init")), SIGINT));
#else
return(kill(1, SIGINT));
#endif
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.30 2000/12/06 18:18:26 andersen Exp $"
+#ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.30 2000/12/06 18:18:26 andersen Exp $"
+#ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw Exp $"
/* The relocatable object is manipulated using elfin types. */
/* Don't report an error if the symbol is coming from
the kernel or some external module. */
if (secidx <= SHN_HIRESERVE)
- errorMsg("%s multiply defined\n", name);
+ error_msg("%s multiply defined\n", name);
return sym;
}
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- errorMsg("symbol for parameter %s not found\n", p);
+ error_msg("symbol for parameter %s not found\n", p);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- errorMsg("improperly terminated string argument for %s\n", p);
+ error_msg("improperly terminated string argument for %s\n", p);
return 0;
} else if (*q == '\\')
switch (*++q) {
nks = get_kernel_syms(NULL);
if (nks < 0) {
- errorMsg("get_kernel_syms: %s: %s\n", m_name, strerror(errno));
+ error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno));
return 0;
}
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
: 0), &routines, symtab);
if (ret)
- errorMsg("init_module: %s: %s\n", m_name, strerror(errno));
+ error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image);
free(symtab);
p = get_modinfo_value(f, key);
key += 5;
if (p == NULL) {
- errorMsg("invalid parameter %s\n", key);
+ error_msg("invalid parameter %s\n", key);
return 0;
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- errorMsg("symbol for parameter %s not found\n", key);
+ error_msg("symbol for parameter %s not found\n", key);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- errorMsg("improperly terminated string argument for %s\n",
+ error_msg("improperly terminated string argument for %s\n",
key);
return 0;
} else if (*q == '\\')
/* Get the size of each member */
/* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) {
- errorMsg("parameter type 'c' for %s must be followed by"
+ error_msg("parameter type 'c' for %s must be followed by"
" the maximum size\n", key);
return 0;
}
/* Check length */
if (strlen(str) >= charssize) {
- errorMsg("string too long for %s (max %ld)\n", key,
+ error_msg("string too long for %s (max %ld)\n", key,
charssize - 1);
return 0;
}
break;
default:
- errorMsg("unknown parameter type '%c' for %s\n", *p, key);
+ error_msg("unknown parameter type '%c' for %s\n", *p, key);
return 0;
}
}
case ',':
if (++n > max) {
- errorMsg("too many values for %s (max %d)\n", key, max);
+ error_msg("too many values for %s (max %d)\n", key, max);
return 0;
}
++q;
break;
default:
- errorMsg("invalid argument syntax for %s\n", key);
+ error_msg("invalid argument syntax for %s\n", key);
return 0;
}
}
end_of_arg:
if (n < min) {
- errorMsg("too few values for %s (min %d)\n", key, min);
+ error_msg("too few values for %s (min %d)\n", key, min);
return 0;
}
module_names = xrealloc(module_names, bufsize = ret);
goto retry_modules_load;
}
- errorMsg("QM_MODULES: %s\n", strerror(errno));
+ error_msg("QM_MODULES: %s\n", strerror(errno));
return 0;
}
/* The module was removed out from underneath us. */
continue;
}
- errorMsg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno));
+ error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno));
return 0;
}
/* The module was removed out from underneath us. */
continue;
default:
- errorMsg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno));
+ error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno));
return 0;
}
}
syms = xrealloc(syms, bufsize = ret);
goto retry_kern_sym_load;
}
- errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
+ error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
return 0;
}
nksyms = nsyms = ret;
ret = new_sys_init_module(m_name, (struct new_module *) image);
if (ret)
- errorMsg("init_module: %s: %s\n", m_name, strerror(errno));
+ error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image);
sym->secidx = SHN_ABS;
sym->value = 0;
} else {
- errorMsg("unresolved symbol %s\n", sym->name);
+ error_msg("unresolved symbol %s\n", sym->name);
ret = 0;
}
}
errmsg = "Unhandled relocation";
bad_reloc:
if (extsym) {
- errorMsg("%s of type %ld for %s\n", errmsg,
+ error_msg("%s of type %ld for %s\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name);
} else {
- errorMsg("%s of type %ld\n", errmsg,
+ error_msg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info));
}
ret = 0;
fseek(fp, 0, SEEK_SET);
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
- errorMsg("error reading ELF header: %s\n", strerror(errno));
+ error_msg("error reading ELF header: %s\n", strerror(errno));
return NULL;
}
|| f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) {
- errorMsg("not an ELF file\n");
+ error_msg("not an ELF file\n");
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
- errorMsg("ELF file not for this architecture\n");
+ error_msg("ELF file not for this architecture\n");
return NULL;
}
if (f->header.e_type != ET_REL) {
- errorMsg("ELF file not a relocatable object\n");
+ error_msg("ELF file not a relocatable object\n");
return NULL;
}
/* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
- errorMsg("section header size mismatch: %lu != %lu\n",
+ error_msg("section header size mismatch: %lu != %lu\n",
(unsigned long) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr)));
return NULL;
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
fseek(fp, f->header.e_shoff, SEEK_SET);
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
- errorMsg("error reading ELF section headers: %s\n", strerror(errno));
+ error_msg("error reading ELF section headers: %s\n", strerror(errno));
return NULL;
}
sec->contents = xmalloc(sec->header.sh_size);
fseek(fp, sec->header.sh_offset, SEEK_SET);
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
- errorMsg("error reading ELF section data: %s\n", strerror(errno));
+ error_msg("error reading ELF section data: %s\n", strerror(errno));
return NULL;
}
} else {
#if SHT_RELM == SHT_REL
case SHT_RELA:
- errorMsg("RELA relocations not supported on this architecture\n");
+ error_msg("RELA relocations not supported on this architecture\n");
return NULL;
#else
case SHT_REL:
- errorMsg("REL relocations not supported on this architecture\n");
+ error_msg("REL relocations not supported on this architecture\n");
return NULL;
#endif
break;
}
- errorMsg("can't handle sections of type %ld\n",
+ error_msg("can't handle sections of type %ld\n",
(long) sec->header.sh_type);
return NULL;
}
ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
- errorMsg("symbol size mismatch: %lu != %lu\n",
+ error_msg("symbol size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym)));
return NULL;
case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
- errorMsg("relocation entry size mismatch: %lu != %lu\n",
+ error_msg("relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM)));
return NULL;
/* Get a filedesc for the module */
if ((fp = fopen(*argv, "r")) == NULL) {
/* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */
- if (recursiveAction(_PATH_MODULES, TRUE, FALSE, FALSE,
+ if (recursive_action(_PATH_MODULES, TRUE, FALSE, FALSE,
findNamedModule, 0, m_fullName) == FALSE)
{
if (m_filename[0] == '\0'
|| ((fp = fopen(m_filename, "r")) == NULL))
{
- errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
+ error_msg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
return EXIT_FAILURE;
}
} else
- fatalError("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
+ error_msg_and_die("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
} else
memcpy(m_filename, *argv, strlen(*argv));
} else {
m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) {
- errorMsg("couldn't find the kernel version the module was "
+ error_msg("couldn't find the kernel version the module was "
"compiled for\n");
goto out;
}
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
- errorMsg("Warning: kernel-module version mismatch\n"
+ error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion);
} else {
- errorMsg("kernel-module version mismatch\n"
+ error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion);
goto out;
k_crcs = new_is_kernel_checksummed();
#else
- errorMsg("Not configured to support new kernels\n");
+ error_msg("Not configured to support new kernels\n");
goto out;
#endif
} else {
goto out;
k_crcs = old_is_kernel_checksummed();
#else
- errorMsg("Not configured to support old kernels\n");
+ error_msg("Not configured to support old kernels\n");
goto out;
#endif
}
case 0:
break;
case EEXIST:
- errorMsg("A module named %s already exists\n", m_name);
+ error_msg("A module named %s already exists\n", m_name);
goto out;
case ENOMEM:
- errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n",
+ error_msg("Can't allocate kernel memory for module; needed %lu bytes\n",
m_size);
goto out;
default:
- errorMsg("create_module: %s: %s\n", m_name, strerror(errno));
+ error_msg("create_module: %s: %s\n", m_name, strerror(errno));
goto out;
}
int pid;
if (!isdigit(**argv))
- fatalError( "Bad PID: %s\n", strerror(errno));
+ error_msg_and_die( "Bad PID: %s\n", strerror(errno));
pid = strtol(*argv, NULL, 0);
if (kill(pid, sig) != 0)
- fatalError( "Could not kill pid '%d': %s\n", pid, strerror(errno));
+ error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno));
argv++;
}
}
while (--argc >= 0) {
pid_t* pidList;
- pidList = findPidByName( *argv);
+ pidList = find_pid_by_name( *argv);
if (!pidList) {
all_found = FALSE;
- errorMsg( "%s: no process killed\n", *argv);
+ error_msg( "%s: no process killed\n", *argv);
}
for(; pidList && *pidList!=0; pidList++) {
if (*pidList==myPid)
continue;
if (kill(*pidList, sig) != 0)
- fatalError( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
+ error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
}
/* Note that we don't bother to free the memory
- * allocated in findPidByName(). It will be freed
+ * allocated in find_pid_by_name(). It will be freed
* upon exit, so we can save a byte or two */
argv++;
}
end:
- fatalError( "bad signal name: %s\n", *argv);
+ error_msg_and_die( "bad signal name: %s\n", *argv);
}
{
cmd->progs[0].argv++;
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
- fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
+ error_msg_and_die("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
strerror(errno));
}
return EXIT_SUCCESS;
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
- errorMsg("%s: exactly one argument is expected\n",
+ error_msg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return EXIT_FAILURE;
}
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
- errorMsg("%s: bad argument '%s'\n",
+ error_msg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return EXIT_FAILURE;
for (job = jobList->head; job; job = job->next) {
}
if (!job) {
- errorMsg("%s: unknown job %d\n",
+ error_msg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
return EXIT_FAILURE;
}
char* charptr1=cmd->text+5; /* skip over the leading 'then ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `then'\n");
+ error_msg("unexpected token `then'\n");
return EXIT_FAILURE;
}
/* If the if result was FALSE, skip the 'then' stuff */
char* charptr1=cmd->text+5; /* skip over the leading 'else ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `else'\n");
+ error_msg("unexpected token `else'\n");
return EXIT_FAILURE;
}
/* If the if result was TRUE, skip the 'else' stuff */
static int builtin_fi(struct job *cmd, struct jobSet *junk)
{
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `fi'\n");
+ error_msg("unexpected token `fi'\n");
return EXIT_FAILURE;
}
/* Clear out the if and then context bits */
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
- errorMsg("error opening %s: %s\n", redir->filename,
+ error_msg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
if (strpbrk(prog->argv[argc_l - 1],"*[]?")!= NULL){
rc = glob(prog->argv[argc_l - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
- errorMsg("out of space during glob operation\n");
+ error_msg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
if (*src == '\\') {
src++;
if (!*src) {
- errorMsg("character expected after \\\n");
+ error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
chptr++;
if (!*chptr) {
- errorMsg("file name expected after %c\n", *src);
+ error_msg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
if (*prog->argv[argc_l])
argc_l++;
if (!argc_l) {
- errorMsg("empty command in pipe\n");
+ error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
src++;
if (!*src) {
- errorMsg("empty command in pipe\n");
+ error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
* command line, making extra room as needed */
--src;
charptr1 = xmalloc(BUFSIZ);
- while ( (size=fullRead(pipefd[0], charptr1, BUFSIZ-1)) >0) {
+ while ( (size=full_read(pipefd[0], charptr1, BUFSIZ-1)) >0) {
int newSize=src - *commandPtr + size + 1 + strlen(charptr2);
if (newSize > BUFSIZ) {
*commandPtr=xrealloc(*commandPtr, src - *commandPtr +
case '\\':
src++;
if (!*src) {
- errorMsg("character expected after \\\n");
+ error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
#endif
execvp(newJob->progs[i].argv[0], newJob->progs[i].argv);
- fatalError("%s: %s\n", newJob->progs[i].argv[0],
+ error_msg_and_die("%s: %s\n", newJob->progs[i].argv[0],
strerror(errno));
}
if (outPipe[1]!=-1) {
case 'c':
input = NULL;
if (local_pending_command != 0)
- fatalError("multiple -c arguments\n");
+ error_msg_and_die("multiple -c arguments\n");
local_pending_command = xstrdup(argv[optind]);
optind++;
argv = argv+optind;
strcpy(srcName, link_SrcName);
if (flag&LN_NODEREFERENCE)
- srcIsDir = isDirectory(srcName, TRUE, NULL);
+ srcIsDir = is_directory(srcName, TRUE, NULL);
else
- srcIsDir = isDirectory(srcName, FALSE, NULL);
+ srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/");
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
- errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
+ error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (screen_map_load(fd, stdin)) {
- errorMsg("Error loading acm: %s\n", strerror(errno));
+ error_msg("Error loading acm: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- errorMsg("16bit screen-map MUST be a regular file.\n"),
+ error_msg("16bit screen-map MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed reading binary 16bit screen-map"),
perror("Cannot read [new] map from file"), exit(1);
#if 0
else
- errorMsg("Input screen-map is binary.\n");
+ error_msg("Input screen-map is binary.\n");
#endif
}
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- errorMsg("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
perror("fseek failed assuming 8bit screen-map"), exit(1);
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- errorMsg("fseek() returned ESPIPE !\n"),
+ error_msg("fseek() returned ESPIPE !\n"),
exit(1);
else
perror("fseek for binary 8bit screen-map"), exit(1);
perror("Cannot read [old] map from file"), exit(1);
#if 0
else
- errorMsg("Input screen-map is binary.\n");
+ error_msg("Input screen-map is binary.\n");
#endif
}
else
return 0;
}
- errorMsg("Error parsing symbolic map\n");
+ error_msg("Error parsing symbolic map\n");
return(1);
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
- fatalPerror("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening /dev/tty0");
loadnewfont(fd);
return EXIT_SUCCESS;
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32)
- fatalError("Bad character size %d\n", unit);
+ error_msg_and_die("Bad character size %d\n", unit);
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */
- perrorMsg("PIO_FONTX ioctl error (trying PIO_FONT)");
+ perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
}
#endif
if (ioctl(fd, PIO_FONT, buf))
- fatalPerror("PIO_FONT ioctl error");
+ perror_msg_and_die("PIO_FONT ioctl error");
}
static void
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
- errorMsg("It seems this kernel is older than 1.1.92\n");
- fatalError("No Unicode mapping table loaded.\n");
+ error_msg("It seems this kernel is older than 1.1.92\n");
+ error_msg_and_die("No Unicode mapping table loaded.\n");
} else
#endif
- fatalPerror("PIO_UNIMAPCLR");
+ perror_msg_and_die("PIO_UNIMAPCLR");
}
ud.entry_ct = ct;
ud.entries = up;
/* change advice parameters */
}
#endif
- fatalPerror("PIO_UNIMAP");
+ perror_msg_and_die("PIO_UNIMAP");
}
}
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin))
- fatalPerror("Error reading input font");
+ perror_msg_and_die("Error reading input font");
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin))
- fatalPerror("Font too large");
+ perror_msg_and_die("Font too large");
/* test for psf first */
{
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE)
- fatalError("Unsupported psf file mode\n");
+ error_msg_and_die("Unsupported psf file mode\n");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256)
- fatalError("Only fontsize 256 supported\n");
+ error_msg_and_die("Only fontsize 256 supported\n");
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth))
- fatalError("Input file: bad length\n");
+ error_msg_and_die("Input file: bad length\n");
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
} else {
/* bare font */
if (inputlth & 0377)
- fatalError("Bad input file size\n");
+ error_msg_and_die("Bad input file size\n");
offset = 0;
unit = inputlth / 256;
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
- fatalPerror("Error opening /dev/tty0");
+ perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
- fatalError("This is not a valid binary keymap.\n");
+ error_msg_and_die("This is not a valid binary keymap.\n");
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
- fatalPerror("Error reading keymap flags");
+ perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz);
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
- fatalPerror("Error reading keymap");
+ perror_msg_and_die("Error reading keymap");
pos += readsz;
}
for (j = 0; j < NR_KEYS; j++) {
*s = '\0';
fac = decode(save, facilitynames);
if (fac < 0)
- fatalError("unknown facility name: %s\n", save);
+ error_msg_and_die("unknown facility name: %s\n", save);
*s++ = '.';
} else {
s = save;
}
lev = decode(s, prioritynames);
if (lev < 0)
- fatalError("unknown priority name: %s\n", save);
+ error_msg_and_die("unknown priority name: %s\n", save);
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
}
if (argc >= 1)
message = *argv;
else
- fatalError("No message\n");
+ error_msg_and_die("No message\n");
}
openlog(name, option, (pri | LOG_FACMASK));
puts(user);
return EXIT_SUCCESS;
}
- fatalError("no login name\n");
+ error_msg_and_die("no login name\n");
}
#ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
- errorMsg("%s: %s\n", cur->fullname, strerror(errno));
+ error_msg("%s: %s\n", cur->fullname, strerror(errno));
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
} else
#endif
if (lstat(cur->fullname, &cur->dstat)) {
- errorMsg("%s: %s\n", cur->fullname, strerror(errno));
+ error_msg("%s: %s\n", cur->fullname, strerror(errno));
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
- errorMsg("%s: %s\n", path, strerror(errno));
+ error_msg("%s: %s\n", path, strerror(errno));
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}
column += 5;
break;
case LIST_MODEBITS:
- fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode));
+ fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
module_names = xmalloc(bufsize = 256);
deps = xmalloc(bufsize);
if (query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) {
- fatalError("QM_MODULES: %s\n", strerror(errno));
+ error_msg_and_die("QM_MODULES: %s\n", strerror(errno));
}
printf("Module Size Used by\n");
continue;
}
/* else choke */
- fatalError("module %s: QM_INFO: %s\n", mn, strerror(errno));
+ error_msg_and_die("module %s: QM_INFO: %s\n", mn, strerror(errno));
}
while (query_module(mn, QM_REFS, deps, bufsize, &count)) {
if (errno == ENOENT) {
continue;
}
if (errno != ENOSPC) {
- fatalError("module %s: QM_REFS: %s", mn, strerror(errno));
+ error_msg_and_die("module %s: QM_REFS: %s", mn, strerror(errno));
}
deps = xrealloc(deps, bufsize = count);
}
close(fd);
return 0;
}
- fatalError("/proc/modules: %s\n", strerror(errno));
+ error_msg_and_die("/proc/modules: %s\n", strerror(errno));
return 1;
}
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
- errorMsg("%s: %s\n", filename, strerror(errno));
+ error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
- errorMsg("%s: %s\n", filename, strerror(errno));
+ error_msg("%s: %s\n", filename, strerror(errno));
if (fp != stdin)
fclose(fp);
}
if (fp != stdin && fclose(fp) == EOF) {
- errorMsg("%s: %s\n", filename, strerror(errno));
+ error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
- errorMsg("%s: %s\n", checkfile_name, strerror(errno));
+ error_msg("%s: %s\n", checkfile_name, strerror(errno));
return FALSE;
}
}
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
if (warn) {
- errorMsg("%s: %lu: improperly formatted MD5 checksum line\n",
+ error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
checkfile_name, (unsigned long) line_number);
}
} else {
free(line);
if (ferror(checkfile_stream)) {
- errorMsg("%s: read error\n", checkfile_name); /* */
+ error_msg("%s: read error\n", checkfile_name); /* */
return FALSE;
}
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
- errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
+ error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
return FALSE;
}
if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */
- errorMsg("%s: no properly formatted MD5 checksum lines found\n",
+ error_msg("%s: no properly formatted MD5 checksum lines found\n",
checkfile_name);
return FALSE;
} else {
- n_open_or_read_failures);
if (n_open_or_read_failures > 0) {
- errorMsg("WARNING: %d of %d listed files could not be read\n",
+ error_msg("WARNING: %d of %d listed files could not be read\n",
n_open_or_read_failures, n_properly_formated_lines);
return FALSE;
}
if (n_mismatched_checksums > 0) {
- errorMsg("WARNING: %d of %d computed checksums did NOT match\n",
+ error_msg("WARNING: %d of %d computed checksums did NOT match\n",
n_mismatched_checksums, n_computed_checkums);
return FALSE;
}
}
if (file_type_specified && do_check) {
- errorMsg("the -b and -t options are meaningless when verifying checksums\n");
+ error_msg("the -b and -t options are meaningless when verifying checksums\n");
return EXIT_FAILURE;
}
if (n_strings > 0 && do_check) {
- errorMsg("the -g and -c options are mutually exclusive\n");
+ error_msg("the -g and -c options are mutually exclusive\n");
return EXIT_FAILURE;
}
if (status_only && !do_check) {
- errorMsg("the -s option is meaningful only when verifying checksums\n");
+ error_msg("the -s option is meaningful only when verifying checksums\n");
return EXIT_FAILURE;
}
if (warn && !do_check) {
- errorMsg("the -w option is meaningful only when verifying checksums\n");
+ error_msg("the -w option is meaningful only when verifying checksums\n");
return EXIT_FAILURE;
}
size_t i;
if (optind < argc) {
- errorMsg("no files may be specified when using -g\n");
+ error_msg("no files may be specified when using -g\n");
return EXIT_FAILURE;
}
for (i = 0; i < n_strings; ++i) {
}
} else if (do_check) {
if (optind + 1 < argc) {
- errorMsg("only one argument may be specified when using -c\n");
+ error_msg("only one argument may be specified when using -c\n");
}
err = md5_check ((optind == argc) ? "-" : argv[optind]);
}
if (fclose (stdout) == EOF) {
- errorMsg("write error\n");
+ error_msg("write error\n");
return EXIT_FAILURE;
}
if (have_read_stdin && fclose (stdin) == EOF) {
- errorMsg("standard input\n");
+ error_msg("standard input\n");
return EXIT_FAILURE;
}
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
- fatalError("stack overflow\n");
+ error_msg_and_die("stack overflow\n");
stack[pointer++] = a;
}
static double pop()
{
if (pointer == 0)
- fatalError("stack underflow\n");
+ error_msg_and_die("stack underflow\n");
return stack[--pointer];
}
}
o++;
}
- fatalError("%s: syntax error.\n", argument);
+ error_msg_and_die("%s: syntax error.\n", argument);
}
/* return pointer to next token in buffer and set *buffer to one char
} else {
file = open(argv[1], O_RDONLY);
if (file < 0) {
- fatalError(io_error, argv[1], strerror(errno));
+ error_msg_and_die(io_error, argv[1], strerror(errno));
}
}
}
if (code->name == 0) {
- errorMsg("unrecognized opcode %s.\n", argv[1]);
+ error_msg("unrecognized opcode %s.\n", argv[1]);
return EXIT_FAILURE;
}
buf = xrealloc(buf, bufsize);
size = readlink(argv[1], buf, bufsize);
if (size == -1)
- fatalError("%s: %s\n", argv[1], strerror(errno));
+ error_msg_and_die("%s: %s\n", argv[1], strerror(errno));
}
buf[size] = '\0';
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
- errorMsg("Unknown mode: %s\n", *argv);
+ error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE;
}
/* Set the umask for this process so it doesn't
char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
return EXIT_FAILURE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
- errorMsg("%s: File exists\n", buf);
+ error_msg("%s: File exists\n", buf);
return EXIT_FAILURE;
}
if (parentFlag == TRUE) {
strcat(buf, "/");
- createPath(buf, mode);
+ create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);
*/
static volatile void die(char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s\n", str);
exit(8);
}
#ifdef BB_FEATURE_MINIX2
version2 = 1;
#else
- errorMsg("%s: not compiled with minix v2 support\n",
+ error_msg("%s: not compiled with minix v2 support\n",
device_name);
exit(-1);
#endif
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
- fatalError("%s: %s\n", argv[0], strerror(errno));
+ error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
return EXIT_SUCCESS;
}
#ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE)
- errorMsg("Assuming pages of size %d\n", pagesize);
+ error_msg("Assuming pages of size %d\n", pagesize);
#endif
signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, pagesize);
void die(const char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s\n", str);
exit(EXIT_FAILURE);
}
}
}
if (!device_name) {
- errorMsg("error: Nowhere to set up swap on?\n");
+ error_msg("error: Nowhere to set up swap on?\n");
usage(mkswap_usage);
}
sz = get_size(device_name);
if (!PAGES) {
PAGES = sz;
} else if (PAGES > sz && !force) {
- errorMsg("error: size %ld is larger than device size %d\n",
+ error_msg("error: size %ld is larger than device size %d\n",
PAGES * (pagesize / 1024), sz * (pagesize / 1024));
return EXIT_FAILURE;
}
version = 1;
}
if (version != 0 && version != 1) {
- errorMsg("error: unknown version %d\n", version);
+ error_msg("error: unknown version %d\n", version);
usage(mkswap_usage);
}
if (PAGES < 10) {
- errorMsg("error: swap area needs to be at least %ldkB\n",
+ error_msg("error: swap area needs to be at least %ldkB\n",
(long) (10 * pagesize / 1024));
usage(mkswap_usage);
}
#endif
if (PAGES > maxpages) {
PAGES = maxpages;
- errorMsg("warning: truncating swap area to %ldkB\n",
+ error_msg("warning: truncating swap area to %ldkB\n",
PAGES * pagesize / 1024);
}
for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--;
if (!sum) {
- errorMsg("Device '%s' contains a valid Sun disklabel.\n"
+ error_msg("Device '%s' contains a valid Sun disklabel.\n"
"This probably means creating v0 swap would destroy your partition table\n"
"No swap created. If you really want to create swap v0 on that device, use\n"
"the -f option to force it.\n", device_name);
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.30 2000/12/06 18:18:26 andersen Exp $"
+#ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.30 2000/12/06 18:18:26 andersen Exp $"
+#ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw Exp $"
/* The relocatable object is manipulated using elfin types. */
/* Don't report an error if the symbol is coming from
the kernel or some external module. */
if (secidx <= SHN_HIRESERVE)
- errorMsg("%s multiply defined\n", name);
+ error_msg("%s multiply defined\n", name);
return sym;
}
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- errorMsg("symbol for parameter %s not found\n", p);
+ error_msg("symbol for parameter %s not found\n", p);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- errorMsg("improperly terminated string argument for %s\n", p);
+ error_msg("improperly terminated string argument for %s\n", p);
return 0;
} else if (*q == '\\')
switch (*++q) {
nks = get_kernel_syms(NULL);
if (nks < 0) {
- errorMsg("get_kernel_syms: %s: %s\n", m_name, strerror(errno));
+ error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno));
return 0;
}
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
: 0), &routines, symtab);
if (ret)
- errorMsg("init_module: %s: %s\n", m_name, strerror(errno));
+ error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image);
free(symtab);
p = get_modinfo_value(f, key);
key += 5;
if (p == NULL) {
- errorMsg("invalid parameter %s\n", key);
+ error_msg("invalid parameter %s\n", key);
return 0;
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- errorMsg("symbol for parameter %s not found\n", key);
+ error_msg("symbol for parameter %s not found\n", key);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- errorMsg("improperly terminated string argument for %s\n",
+ error_msg("improperly terminated string argument for %s\n",
key);
return 0;
} else if (*q == '\\')
/* Get the size of each member */
/* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) {
- errorMsg("parameter type 'c' for %s must be followed by"
+ error_msg("parameter type 'c' for %s must be followed by"
" the maximum size\n", key);
return 0;
}
/* Check length */
if (strlen(str) >= charssize) {
- errorMsg("string too long for %s (max %ld)\n", key,
+ error_msg("string too long for %s (max %ld)\n", key,
charssize - 1);
return 0;
}
break;
default:
- errorMsg("unknown parameter type '%c' for %s\n", *p, key);
+ error_msg("unknown parameter type '%c' for %s\n", *p, key);
return 0;
}
}
case ',':
if (++n > max) {
- errorMsg("too many values for %s (max %d)\n", key, max);
+ error_msg("too many values for %s (max %d)\n", key, max);
return 0;
}
++q;
break;
default:
- errorMsg("invalid argument syntax for %s\n", key);
+ error_msg("invalid argument syntax for %s\n", key);
return 0;
}
}
end_of_arg:
if (n < min) {
- errorMsg("too few values for %s (min %d)\n", key, min);
+ error_msg("too few values for %s (min %d)\n", key, min);
return 0;
}
module_names = xrealloc(module_names, bufsize = ret);
goto retry_modules_load;
}
- errorMsg("QM_MODULES: %s\n", strerror(errno));
+ error_msg("QM_MODULES: %s\n", strerror(errno));
return 0;
}
/* The module was removed out from underneath us. */
continue;
}
- errorMsg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno));
+ error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno));
return 0;
}
/* The module was removed out from underneath us. */
continue;
default:
- errorMsg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno));
+ error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno));
return 0;
}
}
syms = xrealloc(syms, bufsize = ret);
goto retry_kern_sym_load;
}
- errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
+ error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
return 0;
}
nksyms = nsyms = ret;
ret = new_sys_init_module(m_name, (struct new_module *) image);
if (ret)
- errorMsg("init_module: %s: %s\n", m_name, strerror(errno));
+ error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image);
sym->secidx = SHN_ABS;
sym->value = 0;
} else {
- errorMsg("unresolved symbol %s\n", sym->name);
+ error_msg("unresolved symbol %s\n", sym->name);
ret = 0;
}
}
errmsg = "Unhandled relocation";
bad_reloc:
if (extsym) {
- errorMsg("%s of type %ld for %s\n", errmsg,
+ error_msg("%s of type %ld for %s\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name);
} else {
- errorMsg("%s of type %ld\n", errmsg,
+ error_msg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info));
}
ret = 0;
fseek(fp, 0, SEEK_SET);
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
- errorMsg("error reading ELF header: %s\n", strerror(errno));
+ error_msg("error reading ELF header: %s\n", strerror(errno));
return NULL;
}
|| f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) {
- errorMsg("not an ELF file\n");
+ error_msg("not an ELF file\n");
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
- errorMsg("ELF file not for this architecture\n");
+ error_msg("ELF file not for this architecture\n");
return NULL;
}
if (f->header.e_type != ET_REL) {
- errorMsg("ELF file not a relocatable object\n");
+ error_msg("ELF file not a relocatable object\n");
return NULL;
}
/* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
- errorMsg("section header size mismatch: %lu != %lu\n",
+ error_msg("section header size mismatch: %lu != %lu\n",
(unsigned long) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr)));
return NULL;
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
fseek(fp, f->header.e_shoff, SEEK_SET);
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
- errorMsg("error reading ELF section headers: %s\n", strerror(errno));
+ error_msg("error reading ELF section headers: %s\n", strerror(errno));
return NULL;
}
sec->contents = xmalloc(sec->header.sh_size);
fseek(fp, sec->header.sh_offset, SEEK_SET);
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
- errorMsg("error reading ELF section data: %s\n", strerror(errno));
+ error_msg("error reading ELF section data: %s\n", strerror(errno));
return NULL;
}
} else {
#if SHT_RELM == SHT_REL
case SHT_RELA:
- errorMsg("RELA relocations not supported on this architecture\n");
+ error_msg("RELA relocations not supported on this architecture\n");
return NULL;
#else
case SHT_REL:
- errorMsg("REL relocations not supported on this architecture\n");
+ error_msg("REL relocations not supported on this architecture\n");
return NULL;
#endif
break;
}
- errorMsg("can't handle sections of type %ld\n",
+ error_msg("can't handle sections of type %ld\n",
(long) sec->header.sh_type);
return NULL;
}
ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
- errorMsg("symbol size mismatch: %lu != %lu\n",
+ error_msg("symbol size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym)));
return NULL;
case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
- errorMsg("relocation entry size mismatch: %lu != %lu\n",
+ error_msg("relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM)));
return NULL;
/* Get a filedesc for the module */
if ((fp = fopen(*argv, "r")) == NULL) {
/* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */
- if (recursiveAction(_PATH_MODULES, TRUE, FALSE, FALSE,
+ if (recursive_action(_PATH_MODULES, TRUE, FALSE, FALSE,
findNamedModule, 0, m_fullName) == FALSE)
{
if (m_filename[0] == '\0'
|| ((fp = fopen(m_filename, "r")) == NULL))
{
- errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
+ error_msg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
return EXIT_FAILURE;
}
} else
- fatalError("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
+ error_msg_and_die("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
} else
memcpy(m_filename, *argv, strlen(*argv));
} else {
m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) {
- errorMsg("couldn't find the kernel version the module was "
+ error_msg("couldn't find the kernel version the module was "
"compiled for\n");
goto out;
}
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
- errorMsg("Warning: kernel-module version mismatch\n"
+ error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion);
} else {
- errorMsg("kernel-module version mismatch\n"
+ error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion);
goto out;
k_crcs = new_is_kernel_checksummed();
#else
- errorMsg("Not configured to support new kernels\n");
+ error_msg("Not configured to support new kernels\n");
goto out;
#endif
} else {
goto out;
k_crcs = old_is_kernel_checksummed();
#else
- errorMsg("Not configured to support old kernels\n");
+ error_msg("Not configured to support old kernels\n");
goto out;
#endif
}
case 0:
break;
case EEXIST:
- errorMsg("A module named %s already exists\n", m_name);
+ error_msg("A module named %s already exists\n", m_name);
goto out;
case ENOMEM:
- errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n",
+ error_msg("Can't allocate kernel memory for module; needed %lu bytes\n",
m_size);
goto out;
default:
- errorMsg("create_module: %s: %s\n", m_name, strerror(errno));
+ error_msg("create_module: %s: %s\n", m_name, strerror(errno));
goto out;
}
module_names = xmalloc(bufsize = 256);
deps = xmalloc(bufsize);
if (query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) {
- fatalError("QM_MODULES: %s\n", strerror(errno));
+ error_msg_and_die("QM_MODULES: %s\n", strerror(errno));
}
printf("Module Size Used by\n");
continue;
}
/* else choke */
- fatalError("module %s: QM_INFO: %s\n", mn, strerror(errno));
+ error_msg_and_die("module %s: QM_INFO: %s\n", mn, strerror(errno));
}
while (query_module(mn, QM_REFS, deps, bufsize, &count)) {
if (errno == ENOENT) {
continue;
}
if (errno != ENOSPC) {
- fatalError("module %s: QM_REFS: %s", mn, strerror(errno));
+ error_msg_and_die("module %s: QM_REFS: %s", mn, strerror(errno));
}
deps = xrealloc(deps, bufsize = count);
}
close(fd);
return 0;
}
- fatalError("/proc/modules: %s\n", strerror(errno));
+ error_msg_and_die("/proc/modules: %s\n", strerror(errno));
return 1;
}
specialfile = find_unused_loop_device();
if (specialfile == NULL) {
- errorMsg("Could not find a spare loop device\n");
+ error_msg("Could not find a spare loop device\n");
return (FALSE);
}
if (set_loop(specialfile, lofile, 0, &loro)) {
- errorMsg("Could not setup loop device\n");
+ error_msg("Could not setup loop device\n");
return (FALSE);
}
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */
- errorMsg("WARNING: loop device is read-only\n");
+ error_msg("WARNING: loop device is read-only\n");
flags &= ~MS_RDONLY;
}
}
#endif
status = mount(specialfile, dir, filesystemtype, flags, string_flags);
if (errno == EROFS) {
- errorMsg("%s is write-protected, mounting read-only\n", specialfile);
+ error_msg("%s is write-protected, mounting read-only\n", specialfile);
status = mount(specialfile, dir, filesystemtype, flags |= MS_RDONLY, string_flags);
}
}
#endif
if (errno == EPERM) {
- fatalError("permission denied. Are you root?\n");
+ error_msg_and_die("permission denied. Are you root?\n");
}
return (FALSE);
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError("open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno));
/* How many filesystems? We need to know to allocate enough space */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
if (numfilesystems<0)
- fatalError("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno));
fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype));
/* Grab the list of available filesystems */
status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
if (status<0)
- fatalError("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno));
/* Walk the list trying to mount filesystems
* that do not claim to be nodev filesystems */
if (status == FALSE) {
if (whineOnErrors == TRUE) {
- errorMsg("Mounting %s on %s failed: %s\n",
+ error_msg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno));
}
return (FALSE);
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError("open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno));
/* How many mounted filesystems? We need to know to
* allocate enough space for later... */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
if (numfilesystems<0)
- fatalError( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno));
mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
/* Grab the list of mounted filesystems */
if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
- fatalError( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno));
for( i = 0 ; i < numfilesystems ; i++) {
fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
fstabmount = TRUE;
if (f == NULL)
- fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno));
+ error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) {
if (all == FALSE && directory == NULL && (
rc = nfsmount (device, directory, &flags,
&extra_opts, &string_flags, 1);
if ( rc != 0) {
- fatalError("nfsmount failed: %s\n", strerror(errno));
+ error_msg_and_die("nfsmount failed: %s\n", strerror(errno));
rc = EXIT_FAILURE;
}
}
}
if (code->name == 0) {
- errorMsg("unrecognized opcode %s.\n", argv[1]);
+ error_msg("unrecognized opcode %s.\n", argv[1]);
return EXIT_FAILURE;
}
#ifdef BB_FEATURE_USE_PROCFS
if (filesystemType == 0) {
- struct mntent *p = findMountPoint(blockDevice, "/proc/mounts");
+ struct mntent *p = find_mount_point(blockDevice, "/proc/mounts");
if (p && p->mnt_type)
filesystemType = p->mnt_type;
hostinfo = (struct hostent *) gethostbyname(*argv);
if (!hostinfo) {
- fatalError("cannot resolve %s\n", *argv);
+ error_msg_and_die("cannot resolve %s\n", *argv);
}
address.sin_family = AF_INET;
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.15 2000/10/12 22:30:31 andersen Exp $
+ * $Id: hostname.c,v 1.16 2000/12/07 19:56:48 markw Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- errorMsg("you must be root to change the hostname\n");
+ error_msg("you must be root to change the hostname\n");
else
perror("sethostname");
exit(1);
hostinfo = (struct hostent *) gethostbyname(*argv);
if (!hostinfo) {
- fatalError("cannot resolve %s\n", *argv);
+ error_msg_and_die("cannot resolve %s\n", *argv);
}
address.sin_family = AF_INET;
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.27 2000/12/01 02:55:13 kraai Exp $
+ * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- errorMsg("unknown host %s\n", host);
+ error_msg("unknown host %s\n", host);
exit(1);
}
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
if (c < 0 || c != sizeof(packet)) {
if (c < 0)
perror("ping: sendto");
- errorMsg("write incomplete\n");
+ error_msg("write incomplete\n");
exit(1);
}
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
if (i < 0)
- fatalError("sendto: %s\n", strerror(errno));
+ error_msg_and_die("sendto: %s\n", strerror(errno));
else if ((size_t)i != sizeof(packet))
- fatalError("ping wrote %d chars; %d expected\n", i,
+ error_msg_and_die("ping wrote %d chars; %d expected\n", i,
(int)sizeof(packet));
signal(SIGALRM, sendping);
printf("\n");
} else
if (icmppkt->icmp_type != ICMP_ECHO)
- errorMsg("Warning: Got ICMP %d (%s)\n",
+ error_msg("Warning: Got ICMP %d (%s)\n",
icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
}
if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM) {
- errorMsg("permission denied. (are you root?)\n");
+ error_msg("permission denied. (are you root?)\n");
} else {
perror("ping: creating a raw socket");
}
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- errorMsg("unknown host %s\n", host);
+ error_msg("unknown host %s\n", host);
exit(1);
}
if (h->h_addrtype != AF_INET) {
- errorMsg("unknown address type; only AF_INET is currently supported.\n");
+ error_msg("unknown address type; only AF_INET is currently supported.\n");
exit(1);
}
if ((unsigned)(port - 1 ) > 65534)
{
- fatalError("%s: bad port number\n", p);
+ error_msg_and_die("%s: bad port number\n", p);
}
return port;
}
struct hostent * he;
if ((he = gethostbyname(host)) == NULL)
{
- fatalError("%s: Unknown host\n", host);
+ error_msg_and_die("%s: Unknown host\n", host);
}
memcpy(&addr, he->h_addr, sizeof addr);
if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
{
- fatalError("Unable to connect to remote host: %s\n", strerror(errno));
+ error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno));
}
return s;
}
if (do_continue && !fname_out)
- fatalError("cannot specify continue (-c) without a filename (-O)\n");
+ error_msg_and_die("cannot specify continue (-c) without a filename (-O)\n");
/*
* Parse url into components.
*/
if (fname_out != (char *)1) {
if ( (output=fopen(fname_out, (do_continue ? "a" : "w")))
== NULL)
- fatalPerror("fopen(%s)", fname_out);
+ perror_msg_and_die("fopen(%s)", fname_out);
} else {
output = stdout;
}
if (do_continue) {
struct stat sbuf;
if (fstat(fileno(output), &sbuf) < 0)
- fatalError("fstat()");
+ error_msg_and_die("fstat()");
if (sbuf.st_size > 0)
beg_range = sbuf.st_size;
else
* Retrieve HTTP response line and check for "200" status code.
*/
if (fgets(buf, sizeof(buf), sfp) == NULL)
- fatalError("no response from server\n");
+ error_msg_and_die("no response from server\n");
for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
;
for ( ; isspace(*s) ; ++s)
case 200:
if (!do_continue)
break;
- fatalError("server does not support ranges\n");
+ error_msg_and_die("server does not support ranges\n");
case 206:
if (do_continue)
break;
/*FALLTHRU*/
default:
- fatalError("server returned error: %s", buf);
+ error_msg_and_die("server returned error: %s", buf);
}
/*
continue;
}
if (strcmp(buf, "transfer-encoding") == 0) {
- fatalError("server wants to do %s transfer encoding\n", s);
+ error_msg_and_die("server wants to do %s transfer encoding\n", s);
continue;
}
}
filesize -= n;
}
if (n == 0 && ferror(sfp))
- fatalPerror("network read error");
+ perror_msg_and_die("network read error");
exit(0);
}
*uri_port = 80;
if (strncmp(url, "http://", 7) != 0)
- fatalError("not an http url: %s\n", url);
+ error_msg_and_die("not an http url: %s\n", url);
/* pull the host portion to the front of the buffer */
for (s = url, h = url+7 ; *h != '/' && *h != 0; ++h) {
memzero(&sin, sizeof(sin));
sin.sin_family = AF_INET;
if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
- fatalError("cannot resolve %s\n", host);
+ error_msg_and_die("cannot resolve %s\n", host);
memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length);
sin.sin_port = htons(port);
* Get the server onto a stdio stream.
*/
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- fatalPerror("socket()");
+ perror_msg_and_die("socket()");
if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
- fatalPerror("connect(%s)", host);
+ perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL)
- fatalPerror("fdopen()");
+ perror_msg_and_die("fdopen()");
return fp;
}
/* verify we are at the end of the header name */
if (*s != ':')
- fatalError("bad header line: %s\n", buf);
+ error_msg_and_die("bad header line: %s\n", buf);
/* locate the start of the header value */
for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.9 2000/12/07 03:55:35 tausq Exp $
+ * $Id: wget.c,v 1.10 2000/12/07 19:56:48 markw Exp $
*/
msock = fsock = -1;
mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) {
- errorMsg("excessively long host:dir argument\n");
+ error_msg("excessively long host:dir argument\n");
goto fail;
}
strcpy(hostdir, spec);
until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) {
*s = '\0';
- errorMsg("warning: multiple hostnames not supported\n");
+ error_msg("warning: multiple hostnames not supported\n");
}
} else {
- errorMsg("directory to mount not in host:dir format\n");
+ error_msg("directory to mount not in host:dir format\n");
goto fail;
}
#endif
{
if ((hp = gethostbyname(hostname)) == NULL) {
- errorMsg("can't get address for %s\n", hostname);
+ error_msg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- errorMsg("got bad hp->h_length\n");
+ error_msg("got bad hp->h_length\n");
hp->h_length = sizeof(struct in_addr);
}
memcpy(&server_addr.sin_addr,
if (!old_opts)
old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
- errorMsg("excessively long option argument\n");
+ error_msg("excessively long option argument\n");
goto fail;
}
sprintf(new_opts, "%s%saddr=%s",
data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif
if (nfsvers > MAX_NFSPROT) {
- errorMsg("NFSv%d not supported!\n", nfsvers);
+ error_msg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (mountvers > MAX_NFSPROT) {
- errorMsg("NFSv%d not supported!\n", nfsvers);
+ error_msg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (nfsvers && !mountvers)
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else {
if ((hp = gethostbyname(mounthost)) == NULL) {
- errorMsg("can't get address for %s\n", hostname);
+ error_msg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- errorMsg("got bad hp->h_length?\n");
+ error_msg("got bad hp->h_length?\n");
hp->h_length = sizeof(struct in_addr);
}
mount_server_addr.sin_family = AF_INET;
if (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) {
- errorMsg("%s:%s failed, reason given by server: %s\n",
+ error_msg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv2.fhs_status));
goto fail;
#if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) {
- errorMsg("%s:%s failed, reason given by server: %s\n",
+ error_msg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv3.fhs_status));
goto fail;
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.27 2000/12/01 02:55:13 kraai Exp $
+ * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- errorMsg("unknown host %s\n", host);
+ error_msg("unknown host %s\n", host);
exit(1);
}
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
if (c < 0 || c != sizeof(packet)) {
if (c < 0)
perror("ping: sendto");
- errorMsg("write incomplete\n");
+ error_msg("write incomplete\n");
exit(1);
}
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
if (i < 0)
- fatalError("sendto: %s\n", strerror(errno));
+ error_msg_and_die("sendto: %s\n", strerror(errno));
else if ((size_t)i != sizeof(packet))
- fatalError("ping wrote %d chars; %d expected\n", i,
+ error_msg_and_die("ping wrote %d chars; %d expected\n", i,
(int)sizeof(packet));
signal(SIGALRM, sendping);
printf("\n");
} else
if (icmppkt->icmp_type != ICMP_ECHO)
- errorMsg("Warning: Got ICMP %d (%s)\n",
+ error_msg("Warning: Got ICMP %d (%s)\n",
icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
}
if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM) {
- errorMsg("permission denied. (are you root?)\n");
+ error_msg("permission denied. (are you root?)\n");
} else {
perror("ping: creating a raw socket");
}
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- errorMsg("unknown host %s\n", host);
+ error_msg("unknown host %s\n", host);
exit(1);
}
if (h->h_addrtype != AF_INET) {
- errorMsg("unknown address type; only AF_INET is currently supported.\n");
+ error_msg("unknown address type; only AF_INET is currently supported.\n");
exit(1);
}
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(findPidByName("init")), SIGUSR2));
+ return(kill(*(find_pid_by_name("init")), SIGUSR2));
#else
return(kill(1, SIGUSR2));
#endif
int pid;
if (!isdigit(**argv))
- fatalError( "Bad PID: %s\n", strerror(errno));
+ error_msg_and_die( "Bad PID: %s\n", strerror(errno));
pid = strtol(*argv, NULL, 0);
if (kill(pid, sig) != 0)
- fatalError( "Could not kill pid '%d': %s\n", pid, strerror(errno));
+ error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno));
argv++;
}
}
while (--argc >= 0) {
pid_t* pidList;
- pidList = findPidByName( *argv);
+ pidList = find_pid_by_name( *argv);
if (!pidList) {
all_found = FALSE;
- errorMsg( "%s: no process killed\n", *argv);
+ error_msg( "%s: no process killed\n", *argv);
}
for(; pidList && *pidList!=0; pidList++) {
if (*pidList==myPid)
continue;
if (kill(*pidList, sig) != 0)
- fatalError( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
+ error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
}
/* Note that we don't bother to free the memory
- * allocated in findPidByName(). It will be freed
+ * allocated in find_pid_by_name(). It will be freed
* upon exit, so we can save a byte or two */
argv++;
}
end:
- fatalError( "bad signal name: %s\n", *argv);
+ error_msg_and_die( "bad signal name: %s\n", *argv);
}
if (tmp)
sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid);
else
- errorMsg("Internal error!\n");
+ error_msg("Internal error!\n");
/* For busybox, ignoring effective, saved, etc */
tmp = strstr(S, "Uid:");
if (tmp)
sscanf(tmp, "Uid:\t%d", &P->ruid);
else
- errorMsg("Internal error!\n");
+ error_msg("Internal error!\n");
tmp = strstr(S, "Gid:");
if (tmp)
sscanf(tmp, "Gid:\t%d", &P->rgid);
else
- errorMsg("Internal error!\n");
+ error_msg("Internal error!\n");
}
dir = opendir("/proc");
if (!dir)
- fatalError("Can't open /proc\n");
+ error_msg_and_die("Can't open /proc\n");
#ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError( "open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno));
/* Find out how many processes there are */
if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
- fatalError( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
/* Allocate some memory -- grab a few extras just in case
* some new processes start up while we wait. The kernel will
/* Now grab the pid list */
if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
- fatalError("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
#ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
info.pid = pid_array[i];
if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
- fatalError("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
/* Make some adjustments as needed */
my_getpwuid(uidName, info.euid);
/* close device */
if (close (fd) != 0)
- fatalError("close failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno));
exit (0);
}
if (setpriority(PRIO_PROCESS, ps, prio) == 0) {
printf("%d: old priority %d, new priority %d\n", ps, oldp, prio );
} else {
- perrorMsg("%d: setpriority", ps);
+ perror_msg("%d: setpriority", ps);
status = EXIT_FAILURE;
}
}
if (tmp)
sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid);
else
- errorMsg("Internal error!\n");
+ error_msg("Internal error!\n");
/* For busybox, ignoring effective, saved, etc */
tmp = strstr(S, "Uid:");
if (tmp)
sscanf(tmp, "Uid:\t%d", &P->ruid);
else
- errorMsg("Internal error!\n");
+ error_msg("Internal error!\n");
tmp = strstr(S, "Gid:");
if (tmp)
sscanf(tmp, "Gid:\t%d", &P->rgid);
else
- errorMsg("Internal error!\n");
+ error_msg("Internal error!\n");
}
dir = opendir("/proc");
if (!dir)
- fatalError("Can't open /proc\n");
+ error_msg_and_die("Can't open /proc\n");
#ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError( "open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno));
/* Find out how many processes there are */
if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
- fatalError( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
/* Allocate some memory -- grab a few extras just in case
* some new processes start up while we wait. The kernel will
/* Now grab the pid list */
if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
- fatalError("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
#ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
info.pid = pid_array[i];
if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
- fatalError("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
/* Make some adjustments as needed */
my_getpwuid(uidName, info.euid);
/* close device */
if (close (fd) != 0)
- fatalError("close failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno));
exit (0);
}
char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL)
- fatalError("%s\n", strerror(errno));
+ error_msg_and_die("%s\n", strerror(errno));
printf("%s\n", buf);
return EXIT_SUCCESS;
int fd;
if (!(h = gethostbyname(host))) { /* get the IP addr */
- errorMsg("%s: %s\n", host, strerror(errno));
+ error_msg("%s: %s\n", host, strerror(errno));
return(-1);
}
if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
- errorMsg("%s: %s\n", "time", strerror(errno));
+ error_msg("%s: %s\n", "time", strerror(errno));
return(-1);
}
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */
- errorMsg("%s: %s\n", "socket", strerror(errno));
+ error_msg("%s: %s\n", "socket", strerror(errno));
return(-1);
}
sin.sin_family = AF_INET;
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */
- errorMsg("%s: %s\n", host, strerror(errno));
+ error_msg("%s: %s\n", host, strerror(errno));
close(fd);
return(-1);
}
if (read(fd, (void *)&nett, 4) != 4) { /* read time from server */
close(fd);
- errorMsg("%s did not send the complete time\n", host);
+ error_msg("%s did not send the complete time\n", host);
}
close(fd);
}
if (setdate) {
if (stime(&time) < 0)
- fatalError("Could not set time of day: %s\n", strerror(errno));
+ error_msg_and_die("Could not set time of day: %s\n", strerror(errno));
}
if (printdate) {
fprintf(stdout, "%s", ctime(&time));
buf = xrealloc(buf, bufsize);
size = readlink(argv[1], buf, bufsize);
if (size == -1)
- fatalError("%s: %s\n", argv[1], strerror(errno));
+ error_msg_and_die("%s: %s\n", argv[1], strerror(errno));
}
buf[size] = '\0';
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(findPidByName("init")), SIGINT));
+ return(kill(*(find_pid_by_name("init")), SIGINT));
#else
return(kill(1, SIGINT));
#endif
if (setpriority(PRIO_PROCESS, ps, prio) == 0) {
printf("%d: old priority %d, new priority %d\n", ps, oldp, prio );
} else {
- perrorMsg("%d: setpriority", ps);
+ perror_msg("%d: setpriority", ps);
status = EXIT_FAILURE;
}
}
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (unlink(fileName) < 0) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return (FALSE);
}
return (TRUE);
&& errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */
} else {
- if (recursiveAction(srcName, recursiveFlag, FALSE,
+ if (recursive_action(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
status = EXIT_FAILURE;
}
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
- perrorMsg("%s", *argv);
+ perror_msg("%s", *argv);
status = EXIT_FAILURE;
}
}
else if (my_str[idx] == '/') {
idx = index_of_next_unescaped_slash(my_str, ++idx);
if (idx == -1)
- fatalError("unterminated match expression\n");
+ error_msg_and_die("unterminated match expression\n");
my_str[idx] = '\0';
*regex = (regex_t *)xmalloc(sizeof(regex_t));
xregcomp(*regex, my_str+1, 0);
idx++; /* so it points to the next character after the last '/' */
}
else {
- errorMsg("get_address: no address found in string\n"
+ error_msg("get_address: no address found in string\n"
"\t(you probably didn't check the string you passed me)\n");
idx = -1;
}
/* verify that the 's' is followed by a 'slash' */
if (substr[++idx] != '/')
- fatalError("bad format in substitution expression\n");
+ error_msg_and_die("bad format in substitution expression\n");
/* save the match string */
oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx);
if (idx == -1)
- fatalError("bad format in substitution expression\n");
+ error_msg_and_die("bad format in substitution expression\n");
match = strdup_substr(substr, oldidx, idx);
/* determine the number of back references in the match string */
oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx);
if (idx == -1)
- fatalError("bad format in substitution expression\n");
+ error_msg_and_die("bad format in substitution expression\n");
sed_cmd->replace = strdup_substr(substr, oldidx, idx);
/* process the flags */
if (strchr("; \t\v\n\r", substr[idx]))
goto out;
/* else */
- fatalError("bad option in substitution expression\n");
+ error_msg_and_die("bad option in substitution expression\n");
}
}
*/
if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r'))
- fatalError("bad format in edit expression\n");
+ error_msg_and_die("bad format in edit expression\n");
/* store the edit line text */
/* make editline big enough to accomodate the extra '\n' we will tack on
/* last part (mandatory) will be a command */
if (cmdstr[idx] == '\0')
- fatalError("missing command\n");
+ error_msg_and_die("missing command\n");
if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */
- fatalError("invalid command\n");
+ error_msg_and_die("invalid command\n");
sed_cmd->cmd = cmdstr[idx];
/* special-case handling for (s)ubstitution */
/* special-case handling for (a)ppend, (i)nsert, and (c)hange */
else if (strchr("aic", cmdstr[idx])) {
if (sed_cmd->end_line || sed_cmd->end_match)
- fatalError("only a beginning address can be specified for edit commands\n");
+ error_msg_and_die("only a beginning address can be specified for edit commands\n");
idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]);
}
/* if it was a single-letter command (such as 'p' or 'd') we need to
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
- errorMsg("%s: %s\n", argv[i], strerror(errno));
+ error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
process_file(file);
fclose(file);
a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) {
- fatalError("error reading SCANCODE: '%s'\n", argv[1]);
+ error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
}
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (a.scancode > 255 || a.keycode > 127) {
- fatalError("SCANCODE or KEYCODE outside bounds\n");
+ error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
}
if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE");
- fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
+ error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
}
argc -= 2;
argv += 2;
{
cmd->progs[0].argv++;
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
- fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
+ error_msg_and_die("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
strerror(errno));
}
return EXIT_SUCCESS;
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
- errorMsg("%s: exactly one argument is expected\n",
+ error_msg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return EXIT_FAILURE;
}
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
- errorMsg("%s: bad argument '%s'\n",
+ error_msg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return EXIT_FAILURE;
for (job = jobList->head; job; job = job->next) {
}
if (!job) {
- errorMsg("%s: unknown job %d\n",
+ error_msg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
return EXIT_FAILURE;
}
char* charptr1=cmd->text+5; /* skip over the leading 'then ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `then'\n");
+ error_msg("unexpected token `then'\n");
return EXIT_FAILURE;
}
/* If the if result was FALSE, skip the 'then' stuff */
char* charptr1=cmd->text+5; /* skip over the leading 'else ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `else'\n");
+ error_msg("unexpected token `else'\n");
return EXIT_FAILURE;
}
/* If the if result was TRUE, skip the 'else' stuff */
static int builtin_fi(struct job *cmd, struct jobSet *junk)
{
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `fi'\n");
+ error_msg("unexpected token `fi'\n");
return EXIT_FAILURE;
}
/* Clear out the if and then context bits */
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
- errorMsg("error opening %s: %s\n", redir->filename,
+ error_msg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
if (strpbrk(prog->argv[argc_l - 1],"*[]?")!= NULL){
rc = glob(prog->argv[argc_l - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
- errorMsg("out of space during glob operation\n");
+ error_msg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
if (*src == '\\') {
src++;
if (!*src) {
- errorMsg("character expected after \\\n");
+ error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
chptr++;
if (!*chptr) {
- errorMsg("file name expected after %c\n", *src);
+ error_msg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
if (*prog->argv[argc_l])
argc_l++;
if (!argc_l) {
- errorMsg("empty command in pipe\n");
+ error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
src++;
if (!*src) {
- errorMsg("empty command in pipe\n");
+ error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
* command line, making extra room as needed */
--src;
charptr1 = xmalloc(BUFSIZ);
- while ( (size=fullRead(pipefd[0], charptr1, BUFSIZ-1)) >0) {
+ while ( (size=full_read(pipefd[0], charptr1, BUFSIZ-1)) >0) {
int newSize=src - *commandPtr + size + 1 + strlen(charptr2);
if (newSize > BUFSIZ) {
*commandPtr=xrealloc(*commandPtr, src - *commandPtr +
case '\\':
src++;
if (!*src) {
- errorMsg("character expected after \\\n");
+ error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
#endif
execvp(newJob->progs[i].argv[0], newJob->progs[i].argv);
- fatalError("%s: %s\n", newJob->progs[i].argv[0],
+ error_msg_and_die("%s: %s\n", newJob->progs[i].argv[0],
strerror(errno));
}
if (outPipe[1]!=-1) {
case 'c':
input = NULL;
if (local_pending_command != 0)
- fatalError("multiple -c arguments\n");
+ error_msg_and_die("multiple -c arguments\n");
local_pending_command = xstrdup(argv[optind]);
optind++;
argv = argv+optind;
cmdedit_termw = w;
cmdedit_scroll = w / 3;
} else {
- errorMsg("\n*** Error: minimum screen width is 21\n");
+ error_msg("\n*** Error: minimum screen width is 21\n");
}
}
{
cmd->progs[0].argv++;
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
- fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
+ error_msg_and_die("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
strerror(errno));
}
return EXIT_SUCCESS;
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
- errorMsg("%s: exactly one argument is expected\n",
+ error_msg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return EXIT_FAILURE;
}
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
- errorMsg("%s: bad argument '%s'\n",
+ error_msg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return EXIT_FAILURE;
for (job = jobList->head; job; job = job->next) {
}
if (!job) {
- errorMsg("%s: unknown job %d\n",
+ error_msg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
return EXIT_FAILURE;
}
char* charptr1=cmd->text+5; /* skip over the leading 'then ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `then'\n");
+ error_msg("unexpected token `then'\n");
return EXIT_FAILURE;
}
/* If the if result was FALSE, skip the 'then' stuff */
char* charptr1=cmd->text+5; /* skip over the leading 'else ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `else'\n");
+ error_msg("unexpected token `else'\n");
return EXIT_FAILURE;
}
/* If the if result was TRUE, skip the 'else' stuff */
static int builtin_fi(struct job *cmd, struct jobSet *junk)
{
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
- errorMsg("unexpected token `fi'\n");
+ error_msg("unexpected token `fi'\n");
return EXIT_FAILURE;
}
/* Clear out the if and then context bits */
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
- errorMsg("error opening %s: %s\n", redir->filename,
+ error_msg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
if (strpbrk(prog->argv[argc_l - 1],"*[]?")!= NULL){
rc = glob(prog->argv[argc_l - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
- errorMsg("out of space during glob operation\n");
+ error_msg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
if (*src == '\\') {
src++;
if (!*src) {
- errorMsg("character expected after \\\n");
+ error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
chptr++;
if (!*chptr) {
- errorMsg("file name expected after %c\n", *src);
+ error_msg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
if (*prog->argv[argc_l])
argc_l++;
if (!argc_l) {
- errorMsg("empty command in pipe\n");
+ error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
src++;
if (!*src) {
- errorMsg("empty command in pipe\n");
+ error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
* command line, making extra room as needed */
--src;
charptr1 = xmalloc(BUFSIZ);
- while ( (size=fullRead(pipefd[0], charptr1, BUFSIZ-1)) >0) {
+ while ( (size=full_read(pipefd[0], charptr1, BUFSIZ-1)) >0) {
int newSize=src - *commandPtr + size + 1 + strlen(charptr2);
if (newSize > BUFSIZ) {
*commandPtr=xrealloc(*commandPtr, src - *commandPtr +
case '\\':
src++;
if (!*src) {
- errorMsg("character expected after \\\n");
+ error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
#endif
execvp(newJob->progs[i].argv[0], newJob->progs[i].argv);
- fatalError("%s: %s\n", newJob->progs[i].argv[0],
+ error_msg_and_die("%s: %s\n", newJob->progs[i].argv[0],
strerror(errno));
}
if (outPipe[1]!=-1) {
case 'c':
input = NULL;
if (local_pending_command != 0)
- fatalError("multiple -c arguments\n");
+ error_msg_and_die("multiple -c arguments\n");
local_pending_command = xstrdup(argv[optind]);
optind++;
argv = argv+optind;
break;
#endif
default:
- errorMsg("invalid option -- %c\n", opt);
+ error_msg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
return(0);
}
-/* $Id: sort.c,v 1.23 2000/09/28 17:49:59 beppu Exp $ */
+/* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */
struct stat statBuf;
if (stat("/etc/fstab", &statBuf) < 0)
- fatalError("/etc/fstab file missing\n");
+ error_msg_and_die("/etc/fstab file missing\n");
}
do_em_all();
break;
*s = '\0';
fac = decode(save, facilitynames);
if (fac < 0)
- fatalError("unknown facility name: %s\n", save);
+ error_msg_and_die("unknown facility name: %s\n", save);
*s++ = '.';
} else {
s = save;
}
lev = decode(s, prioritynames);
if (lev < 0)
- fatalError("unknown priority name: %s\n", save);
+ error_msg_and_die("unknown priority name: %s\n", save);
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
}
if (argc >= 1)
message = *argv;
else
- fatalError("No message\n");
+ error_msg_and_die("No message\n");
}
openlog(name, option, (pri | LOG_FACMASK));
v->iov_len = strlen(msg);
if ( -1 == writev(remotefd,iov, IOV_COUNT)){
- fatalError("syslogd: cannot write to remote file handle on"
+ error_msg_and_die("syslogd: cannot write to remote file handle on"
"%s:%d\n",RemoteHost,RemotePort);
}
}
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
if (remotefd < 0) {
- fatalError("syslogd: cannot create socket\n");
+ error_msg_and_die("syslogd: cannot create socket\n");
}
hostinfo = (struct hostent *) gethostbyname(RemoteHost);
if (!hostinfo) {
- fatalError("syslogd: cannot resolve remote host name [%s]\n", RemoteHost);
+ error_msg_and_die("syslogd: cannot resolve remote host name [%s]\n", RemoteHost);
}
remoteaddr.sin_family = AF_INET;
for future operations
*/
if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){
- fatalError("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort);
+ error_msg_and_die("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort);
}
}
/* Create the syslog file so realpath() can work. */
close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
if (realpath (_PATH_LOG, lfile) == NULL)
- fatalError ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno));
unlink (lfile);
sunx.sun_family = AF_UNIX;
strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
- fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno));
addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
- fatalError ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno));
if (chmod (lfile, 0666) < 0)
- fatalError ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno));
FD_ZERO (&fds);
FD_SET (sock_fd, &fds);
if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
if (errno == EINTR) continue; /* alarm may have happened. */
- fatalError ("select error: %s\n", strerror (errno));
+ error_msg_and_die ("select error: %s\n", strerror (errno));
}
for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
pid_t pid;
if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
- fatalError ("accept error: %s\n", strerror (errno));
+ error_msg_and_die ("accept error: %s\n", strerror (errno));
}
pid = fork();
v->iov_len = strlen(msg);
if ( -1 == writev(remotefd,iov, IOV_COUNT)){
- fatalError("syslogd: cannot write to remote file handle on"
+ error_msg_and_die("syslogd: cannot write to remote file handle on"
"%s:%d\n",RemoteHost,RemotePort);
}
}
remotefd = socket(AF_INET, SOCK_DGRAM, 0);
if (remotefd < 0) {
- fatalError("syslogd: cannot create socket\n");
+ error_msg_and_die("syslogd: cannot create socket\n");
}
hostinfo = (struct hostent *) gethostbyname(RemoteHost);
if (!hostinfo) {
- fatalError("syslogd: cannot resolve remote host name [%s]\n", RemoteHost);
+ error_msg_and_die("syslogd: cannot resolve remote host name [%s]\n", RemoteHost);
}
remoteaddr.sin_family = AF_INET;
for future operations
*/
if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){
- fatalError("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort);
+ error_msg_and_die("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort);
}
}
/* Create the syslog file so realpath() can work. */
close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
if (realpath (_PATH_LOG, lfile) == NULL)
- fatalError ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno));
unlink (lfile);
sunx.sun_family = AF_UNIX;
strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
- fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno));
addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
- fatalError ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno));
if (chmod (lfile, 0666) < 0)
- fatalError ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno));
+ error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno));
FD_ZERO (&fds);
FD_SET (sock_fd, &fds);
if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
if (errno == EINTR) continue; /* alarm may have happened. */
- fatalError ("select error: %s\n", strerror (errno));
+ error_msg_and_die ("select error: %s\n", strerror (errno));
}
for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
pid_t pid;
if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
- fatalError ("accept error: %s\n", strerror (errno));
+ error_msg_and_die ("accept error: %s\n", strerror (errno));
}
pid = fork();
usage(tail_usage);
break;
default:
- errorMsg("\nUnknown arg: %c.\n\n",optopt);
+ error_msg("\nUnknown arg: %c.\n\n",optopt);
usage(tail_usage);
}
}
else
fd[test] = open(files[test], O_RDONLY);
if (fd[test] == -1)
- fatalError("Unable to open file %s.\n", files[test]);
+ error_msg_and_die("Unable to open file %s.\n", files[test]);
tail_stream(fd[test]);
bs=BUFSIZ;
break;
case 'f':
if (*tarName != '-')
- fatalError( "Only one 'f' option allowed\n");
+ error_msg_and_die( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
- fatalError( "Option requires an argument: No file specified\n");
+ error_msg_and_die( "Option requires an argument: No file specified\n");
stopIt=TRUE;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv);
if (excludeList[excludeListSize] == NULL)
- fatalError( "Option requires an argument: No file specified\n");
+ error_msg_and_die( "Option requires an argument: No file specified\n");
/* Remove leading "/"s */
if (*excludeList[excludeListSize] =='/')
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
}
case 'X':
if (*excludeFileName != '-')
- fatalError("Only one 'X' option allowed\n");
+ error_msg_and_die("Only one 'X' option allowed\n");
excludeFileName = *(++argv);
if (excludeFileName == NULL)
- fatalError("Option requires an argument: No file specified\n");
+ error_msg_and_die("Option requires an argument: No file specified\n");
fileList = fopen (excludeFileName, "rt");
if (! fileList)
- fatalError("Exclude file: file not found\n");
+ error_msg_and_die("Exclude file: file not found\n");
while (!feof(fileList)) {
fscanf(fileList, "%s", file);
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
*/
if (createFlag == TRUE) {
#ifndef BB_FEATURE_TAR_CREATE
- fatalError( "This version of tar was not compiled with tar creation support.\n");
+ error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
#else
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
#endif
return EXIT_FAILURE;
flagError:
- fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n");
+ error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
}
static void
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
/* Create the path to the file, just in case it isn't there...
* This should not screw up path permissions or anything. */
- createPath(header->name, 0777);
+ create_path(header->name, 0777);
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
header->mode & ~S_IFMT)) < 0) {
- errorMsg(io_error, header->name, strerror(errno));
+ error_msg(io_error, header->name, strerror(errno));
return( FALSE);
}
}
readSize = size;
writeSize = size;
}
- if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) {
+ if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
/* Tarball seems to have a problem */
- errorMsg("Unexpected EOF in archive\n");
+ error_msg("Unexpected EOF in archive\n");
return( FALSE);
}
if ( readSize < writeSize )
/* Write out the file, if we are supposed to be doing that */
if (extractFlag==TRUE) {
- if ((actualWriteSz=fullWrite(outFd, buffer, writeSize)) != writeSize ) {
+ if ((actualWriteSz=full_write(outFd, buffer, writeSize)) != writeSize ) {
/* Output file seems to have a problem */
- errorMsg(io_error, header->name, strerror(errno));
+ error_msg(io_error, header->name, strerror(errno));
return( FALSE);
}
} else {
if (extractFlag==FALSE || tostdoutFlag==TRUE)
return( TRUE);
- if (createPath(header->name, header->mode) != TRUE) {
- errorMsg("%s: Cannot mkdir: %s\n",
+ if (create_path(header->name, header->mode) != TRUE) {
+ error_msg("%s: Cannot mkdir: %s\n",
header->name, strerror(errno));
return( FALSE);
}
/* make the final component, just in case it was
- * omitted by createPath() (which will skip the
+ * omitted by create_path() (which will skip the
* directory if it doesn't have a terminating '/') */
if (mkdir(header->name, header->mode) == 0) {
fixUpPermissions(header);
return( TRUE);
if (link(header->linkname, header->name) < 0) {
- errorMsg("%s: Cannot create hard link to '%s': %s\n",
+ error_msg("%s: Cannot create hard link to '%s': %s\n",
header->name, header->linkname, strerror(errno));
return( FALSE);
}
#ifdef S_ISLNK
if (symlink(header->linkname, header->name) < 0) {
- errorMsg("%s: Cannot create symlink to '%s': %s\n",
+ error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname, strerror(errno));
return( FALSE);
}
/* Do not change permissions or date on symlink,
* since it changes the pointed to file instead. duh. */
#else
- errorMsg("%s: Cannot create symlink to '%s': %s\n",
+ error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname,
"symlinks not supported");
#endif
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
- errorMsg("%s: Cannot mknod: %s\n",
+ error_msg("%s: Cannot mknod: %s\n",
header->name, strerror(errno));
return( FALSE);
}
} else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) {
- errorMsg("%s: Cannot mkfifo: %s\n",
+ error_msg("%s: Cannot mkfifo: %s\n",
header->name, strerror(errno));
return( FALSE);
}
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
- if ((size == 0) || !isOctal(*cp))
+ if ((size == 0) || !is_octal(*cp))
return -1;
- for(; (size > 0) && isOctal(*cp); size--) {
+ for(; (size > 0) && is_octal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
++*(header->name);
if (alreadyWarned == FALSE) {
- errorMsg("Removing leading '/' from member names\n");
+ error_msg("Removing leading '/' from member names\n");
alreadyWarned = TRUE;
}
}
else
tarFd = open(tarName, O_RDONLY);
if (tarFd < 0) {
- errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
+ error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
return ( FALSE);
}
umask(0);
/* Read the tar file, and iterate over it one file at a time */
- while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
+ while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
/* Try to read the header */
if ( readTarHeader(&rawHeader, &header) == FALSE ) {
goto endgame;
} else {
errorFlag=TRUE;
- errorMsg("Bad tar header, skipping\n");
+ error_msg("Bad tar header, skipping\n");
continue;
}
}
}
if ( skipNextHeaderFlag == TRUE ) {
skipNextHeaderFlag=FALSE;
- errorMsg(name_longer_than_foo, NAME_SIZE);
+ error_msg(name_longer_than_foo, NAME_SIZE);
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
continue;
char buf[35];
struct tm *tm = localtime (&(header.mtime));
- len=printf("%s ", modeString(header.mode));
+ len=printf("%s ", mode_string(header.mode));
memset(buf, 0, 8*sizeof(char));
my_getpwuid(buf, header.uid);
if (! *buf)
break;
#endif
default:
- errorMsg("Unknown file type '%c' in tar file\n", header.type);
+ error_msg("Unknown file type '%c' in tar file\n", header.type);
close( tarFd);
return( FALSE);
}
close(tarFd);
if (status > 0) {
/* Bummer - we read a partial header */
- errorMsg( "Error reading '%s': %s\n", tarName, strerror(errno));
+ error_msg( "Error reading '%s': %s\n", tarName, strerror(errno));
return ( FALSE);
}
else if (errorFlag==TRUE) {
- errorMsg( "Error exit delayed from previous errors\n");
+ error_msg( "Error exit delayed from previous errors\n");
return( FALSE);
} else
return( status);
close( tarFd);
if (extractList != NULL) {
for (; *extractList != NULL; extractList++) {
- errorMsg("%s: Not found in archive\n", *extractList);
+ error_msg("%s: Not found in archive\n", *extractList);
errorFlag = TRUE;
}
}
if ( *(header.name) == '\0' ) {
if (errorFlag==TRUE)
- errorMsg( "Error exit delayed from previous errors\n");
+ error_msg( "Error exit delayed from previous errors\n");
else
return( TRUE);
}
if (*fileName=='/') {
static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) {
- errorMsg("Removing leading '/' from member names\n");
+ error_msg("Removing leading '/' from member names\n");
alreadyWarned=TRUE;
}
strncpy(header.name, fileName+1, sizeof(header.name));
header.typeflag = SYMTYPE;
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
if ( link_size < 0) {
- errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
+ error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
return ( FALSE);
}
buffer[link_size] = '\0';
header.typeflag = REGTYPE;
putOctal(header.size, sizeof(header.size), statbuf->st_size);
} else {
- errorMsg("%s: Unknown file type\n", fileName);
+ error_msg("%s: Unknown file type\n", fileName);
return ( FALSE);
}
putOctal(header.chksum, 7, chksum);
/* Now write the header out to disk */
- if ((size=fullWrite(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
- errorMsg(io_error, fileName, strerror(errno));
+ if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
+ error_msg(io_error, fileName, strerror(errno));
return ( FALSE);
}
/* Pad the header up to the tar block size */
/* It is against the rules to archive a socket */
if (S_ISSOCK(statbuf->st_mode)) {
- errorMsg("%s: socket ignored\n", fileName);
+ error_msg("%s: socket ignored\n", fileName);
return( TRUE);
}
* the new tarball */
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
tbInfo->statBuf.st_ino == statbuf->st_ino) {
- errorMsg("%s: file is the archive; skipping\n", fileName);
+ error_msg("%s: file is the archive; skipping\n", fileName);
return( TRUE);
}
if (strlen(fileName) >= NAME_SIZE) {
- errorMsg(name_longer_than_foo, NAME_SIZE);
+ error_msg(name_longer_than_foo, NAME_SIZE);
return ( TRUE);
}
/* open the file we want to archive, and make sure all is well */
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
- errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno));
+ error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
return( FALSE);
}
/* write the file to the archive */
- while ( (size = fullRead(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
- if (fullWrite(tbInfo->tarFd, buffer, size) != size ) {
+ while ( (size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
+ if (full_write(tbInfo->tarFd, buffer, size) != size ) {
/* Output file seems to have a problem */
- errorMsg(io_error, fileName, strerror(errno));
+ error_msg(io_error, fileName, strerror(errno));
return( FALSE);
}
readSize+=size;
}
if (size == -1) {
- errorMsg(io_error, fileName, strerror(errno));
+ error_msg(io_error, fileName, strerror(errno));
return( FALSE);
}
/* Pad the file up to the tar block size */
/* Make sure there is at least one file to tar up. */
if (*argv == NULL)
- fatalError("Cowardly refusing to create an empty archive\n");
+ error_msg_and_die("Cowardly refusing to create an empty archive\n");
/* Open the tar file for writing. */
if (!strcmp(tarName, "-"))
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tbInfo.tarFd < 0) {
- errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
+ error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
freeHardLinkInfo(&tbInfo.hlInfoHead);
return ( FALSE);
}
/* Store the stat info for the tarball's file, so
* can avoid including the tarball into itself.... */
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
- fatalError(io_error, tarName, strerror(errno));
+ error_msg_and_die(io_error, tarName, strerror(errno));
/* Set the umask for this process so it doesn't
* screw up permission setting for us later. */
/* Read the directory/files and iterate over them one at a time */
while (*argv != NULL) {
- if (recursiveAction(*argv++, TRUE, FALSE, FALSE,
+ if (recursive_action(*argv++, TRUE, FALSE, FALSE,
writeFileToTarball, writeFileToTarball,
(void*) &tbInfo) == FALSE) {
errorFlag = TRUE;
/* Hang up the tools, close up shop, head home */
close(tarFd);
if (errorFlag == TRUE) {
- errorMsg("Error exit delayed from previous errors\n");
+ error_msg("Error exit delayed from previous errors\n");
freeHardLinkInfo(&tbInfo.hlInfoHead);
return(FALSE);
}
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--;
- errorMsg("%s: %s\n", argv[optind-1], strerror(errno));
+ error_msg("%s: %s\n", argv[optind-1], strerror(errno));
status = 1;
}
}
if ((unsigned)(port - 1 ) > 65534)
{
- fatalError("%s: bad port number\n", p);
+ error_msg_and_die("%s: bad port number\n", p);
}
return port;
}
struct hostent * he;
if ((he = gethostbyname(host)) == NULL)
{
- fatalError("%s: Unknown host\n", host);
+ error_msg_and_die("%s: Unknown host\n", host);
}
memcpy(&addr, he->h_addr, sizeof addr);
if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
{
- fatalError("Unable to connect to remote host: %s\n", strerror(errno));
+ error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno));
}
return s;
}
if (strcmp(applet_name, "[") == 0) {
if (strcmp(argv[--argc], "]"))
- fatalError("missing ]\n");
+ error_msg_and_die("missing ]\n");
argv[argc] = NULL;
}
/* Implement special cases from POSIX.2, section 4.62.4 */
char *msg;
{
if (op && *op)
- fatalError("%s: %s\n", op, msg);
+ error_msg_and_die("%s: %s\n", op, msg);
else
- fatalError("%s\n", msg);
+ error_msg_and_die("%s\n", msg);
}
static int
r = strtol(s, &p, 10);
if (errno != 0)
- fatalError("%s: out of range\n", s);
+ error_msg_and_die("%s: out of range\n", s);
while (isspace(*p))
p++;
if (*p)
- fatalError("%s: bad number\n", s);
+ error_msg_and_die("%s: bad number\n", s);
return (int) r;
}
if (create == FALSE && errno == ENOENT)
return EXIT_SUCCESS;
else {
- fatalError("%s", strerror(errno));
+ error_msg_and_die("%s", strerror(errno));
}
}
close(fd);
if (utime(*argv, NULL)) {
- fatalError("%s", strerror(errno));
+ error_msg_and_die("%s", strerror(errno));
}
argc--;
argv++;
input_length = complement(input, input_length);
if (argv[index] != NULL) {
if (*argv[index] == '\0')
- fatalError("STRING2 cannot be empty\n");
+ error_msg_and_die("STRING2 cannot be empty\n");
output_length = expand(argv[index], output);
map(input, input_length, output, output_length);
}
return;
if ((fp = setmntent(mtab_file, "r")) == NULL) {
- errorMsg("Cannot open %s\n", mtab_file);
+ error_msg("Cannot open %s\n", mtab_file);
return;
}
while ((e = getmntent(fp))) {
if (status != 0 && doForce == TRUE) {
status = umount2(blockDevice, MNT_FORCE);
if (status != 0) {
- fatalError("forced umount of %s failed!\n", blockDevice);
+ error_msg_and_die("forced umount of %s failed!\n", blockDevice);
}
}
#endif
status = mount(blockDevice, name, NULL,
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (status == 0) {
- errorMsg("%s busy - remounted read-only\n", blockDevice);
+ error_msg("%s busy - remounted read-only\n", blockDevice);
} else {
- errorMsg("Cannot remount %s read-only\n", blockDevice);
+ error_msg("Cannot remount %s read-only\n", blockDevice);
}
}
if (status == 0) {
}
}
#else
- errorMsg( "mode reading not compiled in\n");
+ error_msg( "mode reading not compiled in\n");
#endif
return 0;
}
PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
- errorMsg("Unknown video mode `%s'\n", mode);
+ error_msg("Unknown video mode `%s'\n", mode);
return EXIT_FAILURE;
}
}
}
if ((f = open(argv[1], O_RDWR)) == -1) {
- fatalError( "cannot open %s: %s\n", argv[1], strerror(errno));
+ error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno));
}
if (ioctl(f, BLKFLSBUF) < 0) {
- fatalError( "failed ioctl on %s: %s\n", argv[1], strerror(errno));
+ error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno));
}
/* Don't bother closing. Exit does
* that, so we can save a few bytes */
static void die(const char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s\n", str);
leave(8);
}
* <misiek@misiek.eu.org>)
* Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
* Removed --version/-V and --help/-h in
- * Removed prase_error(), using errorMsg() from Busybox instead
+ * Removed prase_error(), using error_msg() from Busybox instead
* Replaced our_malloc with xmalloc and our_realloc with xrealloc
*
*/
arg_opt=required_argument;
}
if (strlen(tokptr) == 0)
- errorMsg("empty long option after -l or --long argument\n");
+ error_msg("empty long option after -l or --long argument\n");
}
add_longopt(tokptr,arg_opt);
}
else if (!strcmp(new_shell,"csh"))
shell=TCSH;
else
- errorMsg("unknown shell after -s or --shell argument\n");
+ error_msg("unknown shell after -s or --shell argument\n");
}
printf(" --\n");
exit(0);
} else
- fatalError("missing optstring argument\n");
+ error_msg_and_die("missing optstring argument\n");
}
if (argv[1][0] != '-' || compatible) {
if (!optstr) {
if (optind >= argc)
- fatalError("missing optstring argument\n");
+ error_msg_and_die("missing optstring argument\n");
else {
optstr=xmalloc(strlen(argv[optind])+1);
strcpy(optstr,argv[optind]);
*/
static volatile void die(char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s\n", str);
exit(8);
}
#ifdef BB_FEATURE_MINIX2
version2 = 1;
#else
- errorMsg("%s: not compiled with minix v2 support\n",
+ error_msg("%s: not compiled with minix v2 support\n",
device_name);
exit(-1);
#endif
#ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE)
- errorMsg("Assuming pages of size %d\n", pagesize);
+ error_msg("Assuming pages of size %d\n", pagesize);
#endif
signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, pagesize);
void die(const char *str)
{
- errorMsg("%s\n", str);
+ error_msg("%s\n", str);
exit(EXIT_FAILURE);
}
}
}
if (!device_name) {
- errorMsg("error: Nowhere to set up swap on?\n");
+ error_msg("error: Nowhere to set up swap on?\n");
usage(mkswap_usage);
}
sz = get_size(device_name);
if (!PAGES) {
PAGES = sz;
} else if (PAGES > sz && !force) {
- errorMsg("error: size %ld is larger than device size %d\n",
+ error_msg("error: size %ld is larger than device size %d\n",
PAGES * (pagesize / 1024), sz * (pagesize / 1024));
return EXIT_FAILURE;
}
version = 1;
}
if (version != 0 && version != 1) {
- errorMsg("error: unknown version %d\n", version);
+ error_msg("error: unknown version %d\n", version);
usage(mkswap_usage);
}
if (PAGES < 10) {
- errorMsg("error: swap area needs to be at least %ldkB\n",
+ error_msg("error: swap area needs to be at least %ldkB\n",
(long) (10 * pagesize / 1024));
usage(mkswap_usage);
}
#endif
if (PAGES > maxpages) {
PAGES = maxpages;
- errorMsg("warning: truncating swap area to %ldkB\n",
+ error_msg("warning: truncating swap area to %ldkB\n",
PAGES * pagesize / 1024);
}
for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--;
if (!sum) {
- errorMsg("Device '%s' contains a valid Sun disklabel.\n"
+ error_msg("Device '%s' contains a valid Sun disklabel.\n"
"This probably means creating v0 swap would destroy your partition table\n"
"No swap created. If you really want to create swap v0 on that device, use\n"
"the -f option to force it.\n", device_name);
specialfile = find_unused_loop_device();
if (specialfile == NULL) {
- errorMsg("Could not find a spare loop device\n");
+ error_msg("Could not find a spare loop device\n");
return (FALSE);
}
if (set_loop(specialfile, lofile, 0, &loro)) {
- errorMsg("Could not setup loop device\n");
+ error_msg("Could not setup loop device\n");
return (FALSE);
}
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */
- errorMsg("WARNING: loop device is read-only\n");
+ error_msg("WARNING: loop device is read-only\n");
flags &= ~MS_RDONLY;
}
}
#endif
status = mount(specialfile, dir, filesystemtype, flags, string_flags);
if (errno == EROFS) {
- errorMsg("%s is write-protected, mounting read-only\n", specialfile);
+ error_msg("%s is write-protected, mounting read-only\n", specialfile);
status = mount(specialfile, dir, filesystemtype, flags |= MS_RDONLY, string_flags);
}
}
#endif
if (errno == EPERM) {
- fatalError("permission denied. Are you root?\n");
+ error_msg_and_die("permission denied. Are you root?\n");
}
return (FALSE);
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError("open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno));
/* How many filesystems? We need to know to allocate enough space */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
if (numfilesystems<0)
- fatalError("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno));
fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype));
/* Grab the list of available filesystems */
status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
if (status<0)
- fatalError("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno));
+ error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno));
/* Walk the list trying to mount filesystems
* that do not claim to be nodev filesystems */
if (status == FALSE) {
if (whineOnErrors == TRUE) {
- errorMsg("Mounting %s on %s failed: %s\n",
+ error_msg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno));
}
return (FALSE);
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError("open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno));
/* How many mounted filesystems? We need to know to
* allocate enough space for later... */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
if (numfilesystems<0)
- fatalError( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno));
mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
/* Grab the list of mounted filesystems */
if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
- fatalError( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno));
for( i = 0 ; i < numfilesystems ; i++) {
fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
fstabmount = TRUE;
if (f == NULL)
- fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno));
+ error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) {
if (all == FALSE && directory == NULL && (
rc = nfsmount (device, directory, &flags,
&extra_opts, &string_flags, 1);
if ( rc != 0) {
- fatalError("nfsmount failed: %s\n", strerror(errno));
+ error_msg_and_die("nfsmount failed: %s\n", strerror(errno));
rc = EXIT_FAILURE;
}
}
msock = fsock = -1;
mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) {
- errorMsg("excessively long host:dir argument\n");
+ error_msg("excessively long host:dir argument\n");
goto fail;
}
strcpy(hostdir, spec);
until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) {
*s = '\0';
- errorMsg("warning: multiple hostnames not supported\n");
+ error_msg("warning: multiple hostnames not supported\n");
}
} else {
- errorMsg("directory to mount not in host:dir format\n");
+ error_msg("directory to mount not in host:dir format\n");
goto fail;
}
#endif
{
if ((hp = gethostbyname(hostname)) == NULL) {
- errorMsg("can't get address for %s\n", hostname);
+ error_msg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- errorMsg("got bad hp->h_length\n");
+ error_msg("got bad hp->h_length\n");
hp->h_length = sizeof(struct in_addr);
}
memcpy(&server_addr.sin_addr,
if (!old_opts)
old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
- errorMsg("excessively long option argument\n");
+ error_msg("excessively long option argument\n");
goto fail;
}
sprintf(new_opts, "%s%saddr=%s",
data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif
if (nfsvers > MAX_NFSPROT) {
- errorMsg("NFSv%d not supported!\n", nfsvers);
+ error_msg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (mountvers > MAX_NFSPROT) {
- errorMsg("NFSv%d not supported!\n", nfsvers);
+ error_msg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (nfsvers && !mountvers)
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else {
if ((hp = gethostbyname(mounthost)) == NULL) {
- errorMsg("can't get address for %s\n", hostname);
+ error_msg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- errorMsg("got bad hp->h_length?\n");
+ error_msg("got bad hp->h_length?\n");
hp->h_length = sizeof(struct in_addr);
}
mount_server_addr.sin_family = AF_INET;
if (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) {
- errorMsg("%s:%s failed, reason given by server: %s\n",
+ error_msg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv2.fhs_status));
goto fail;
#if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) {
- errorMsg("%s:%s failed, reason given by server: %s\n",
+ error_msg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv3.fhs_status));
goto fail;
int fd;
if (!(h = gethostbyname(host))) { /* get the IP addr */
- errorMsg("%s: %s\n", host, strerror(errno));
+ error_msg("%s: %s\n", host, strerror(errno));
return(-1);
}
if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
- errorMsg("%s: %s\n", "time", strerror(errno));
+ error_msg("%s: %s\n", "time", strerror(errno));
return(-1);
}
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */
- errorMsg("%s: %s\n", "socket", strerror(errno));
+ error_msg("%s: %s\n", "socket", strerror(errno));
return(-1);
}
sin.sin_family = AF_INET;
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */
- errorMsg("%s: %s\n", host, strerror(errno));
+ error_msg("%s: %s\n", host, strerror(errno));
close(fd);
return(-1);
}
if (read(fd, (void *)&nett, 4) != 4) { /* read time from server */
close(fd);
- errorMsg("%s did not send the complete time\n", host);
+ error_msg("%s did not send the complete time\n", host);
}
close(fd);
}
if (setdate) {
if (stime(&time) < 0)
- fatalError("Could not set time of day: %s\n", strerror(errno));
+ error_msg_and_die("Could not set time of day: %s\n", strerror(errno));
}
if (printdate) {
fprintf(stdout, "%s", ctime(&time));
struct stat statBuf;
if (stat("/etc/fstab", &statBuf) < 0)
- fatalError("/etc/fstab file missing\n");
+ error_msg_and_die("/etc/fstab file missing\n");
}
do_em_all();
break;
return;
if ((fp = setmntent(mtab_file, "r")) == NULL) {
- errorMsg("Cannot open %s\n", mtab_file);
+ error_msg("Cannot open %s\n", mtab_file);
return;
}
while ((e = getmntent(fp))) {
if (status != 0 && doForce == TRUE) {
status = umount2(blockDevice, MNT_FORCE);
if (status != 0) {
- fatalError("forced umount of %s failed!\n", blockDevice);
+ error_msg_and_die("forced umount of %s failed!\n", blockDevice);
}
}
#endif
status = mount(blockDevice, name, NULL,
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (status == 0) {
- errorMsg("%s busy - remounted read-only\n", blockDevice);
+ error_msg("%s busy - remounted read-only\n", blockDevice);
} else {
- errorMsg("Cannot remount %s read-only\n", blockDevice);
+ error_msg("Cannot remount %s read-only\n", blockDevice);
}
}
if (status == 0) {
|| defined (BB_LS) \
|| defined (BB_RM) \
|| defined (BB_TAR)
-/* same conditions as recursiveAction */
+/* same conditions as recursive_action */
#define bb_need_name_too_long
#endif
#define bb_need_memory_exhausted
exit(EXIT_FAILURE);
}
-static void verrorMsg(const char *s, va_list p)
+static void verror_msg(const char *s, va_list p)
{
fflush(stdout);
fprintf(stderr, "%s: ", applet_name);
fflush(stderr);
}
-extern void errorMsg(const char *s, ...)
+extern void error_msg(const char *s, ...)
{
va_list p;
va_start(p, s);
- verrorMsg(s, p);
+ verror_msg(s, p);
va_end(p);
}
-extern void fatalError(const char *s, ...)
+extern void error_msg_and_die(const char *s, ...)
{
va_list p;
va_start(p, s);
- verrorMsg(s, p);
+ verror_msg(s, p);
va_end(p);
exit(EXIT_FAILURE);
}
-static void vperrorMsg(const char *s, va_list p)
+static void vperror_msg(const char *s, va_list p)
{
fflush(stdout);
fprintf(stderr, "%s: ", applet_name);
fflush(stderr);
}
-extern void perrorMsg(const char *s, ...)
+extern void perror_msg(const char *s, ...)
{
va_list p;
va_start(p, s);
- vperrorMsg(s, p);
+ vperror_msg(s, p);
va_end(p);
}
-extern void fatalPerror(const char *s, ...)
+extern void perror_msg_and_die(const char *s, ...)
{
va_list p;
va_start(p, s);
- vperrorMsg(s, p);
+ vperror_msg(s, p);
va_end(p);
exit(EXIT_FAILURE);
}
* Return TRUE if a fileName is a directory.
* Nonexistant files return FALSE.
*/
-int isDirectory(const char *fileName, const int followLinks, struct stat *statBuf)
+int is_directory(const char *fileName, const int followLinks, struct stat *statBuf)
{
int status;
int didMalloc = 0;
size = BUFSIZ;
else
size = chunksize;
- if (fullWrite(dstfd, buffer, fullRead(srcfd, buffer, size)) < size)
+ if (full_write(dstfd, buffer, full_read(srcfd, buffer, size)) < size)
return(FALSE);
chunksize -= size;
}
* -Erik Andersen
*/
int
-copyFile(const char *srcName, const char *destName,
+copy_file(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag)
{
int rfd;
if ((srcStatBuf.st_dev == dstStatBuf.st_dev) &&
(srcStatBuf.st_ino == dstStatBuf.st_ino)) {
- errorMsg("Copying file \"%s\" to itself\n", srcName);
+ error_msg("Copying file \"%s\" to itself\n", srcName);
return FALSE;
}
* Return the standard ls-like mode string from a file mode.
* This is static and so is overwritten on each call.
*/
-const char *modeString(int mode)
+const char *mode_string(int mode)
{
static char buf[12];
* Return the standard ls-like time string from a time_t
* This is static and so is overwritten on each call.
*/
-const char *timeString(time_t timeVal)
+const char *time_string(time_t timeVal)
{
time_t now;
char *str;
* This does multiple writes as necessary.
* Returns the amount written, or -1 on an error.
*/
-int fullWrite(int fd, const char *buf, int len)
+int full_write(int fd, const char *buf, int len)
{
int cc;
int total;
* Returns the amount read, or -1 on an error.
* A short read is returned on an end of file.
*/
-int fullRead(int fd, char *buf, int len)
+int full_read(int fd, char *buf, int len)
{
int cc;
int total;
* and so isn't sufficiently portable to take over since glibc2.1
* is so stinking huge.
*/
-int recursiveAction(const char *fileName,
+int recursive_action(const char *fileName,
int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName,
struct stat * statbuf,
"status=%d followLinks=%d TRUE=%d\n",
status, followLinks, TRUE);
#endif
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return FALSE;
}
dir = opendir(fileName);
if (!dir) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return FALSE;
}
if (dirAction != NULL && depthFirst == FALSE) {
status = dirAction(fileName, &statbuf, userData);
if (status == FALSE) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return FALSE;
}
}
continue;
}
if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) {
- errorMsg(name_too_long);
+ error_msg(name_too_long);
return FALSE;
}
memset(nextFile, 0, sizeof(nextFile));
sprintf(nextFile, "%s/%s", fileName, next->d_name);
status =
- recursiveAction(nextFile, TRUE, followLinks, depthFirst,
+ recursive_action(nextFile, TRUE, followLinks, depthFirst,
fileAction, dirAction, userData);
if (status == FALSE) {
closedir(dir);
}
status = closedir(dir);
if (status < 0) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return FALSE;
}
if (dirAction != NULL && depthFirst == TRUE) {
status = dirAction(fileName, &statbuf, userData);
if (status == FALSE) {
- perrorMsg("%s", fileName);
+ perror_msg("%s", fileName);
return FALSE;
}
}
* while all previous ones get default protections. Errors are not reported
* here, as failures to restore files can be reported later.
*/
-extern int createPath(const char *name, int mode)
+extern int create_path(const char *name, int mode)
{
char *cp;
char *cpOld;
if (is_a_console(fd))
return fd;
- errorMsg("Couldnt get a file descriptor referring to the console\n");
+ error_msg("Couldnt get a file descriptor referring to the console\n");
return -1; /* total failure */
}
* Given any other file (or directory), find the mount table entry for its
* filesystem.
*/
-extern struct mntent *findMountPoint(const char *name, const char *table)
+extern struct mntent *find_mount_point(const char *name, const char *table)
{
struct stat s;
dev_t mountDevice;
* Read a number with a possible multiplier.
* Returns -1 if the number format is illegal.
*/
-extern long getNum(const char *cp)
+extern long atoi_w_units(const char *cp)
{
long value;
- if (!isDecimal(*cp))
+ if (!is_decimal(*cp))
return -1;
value = 0;
- while (isDecimal(*cp))
+ while (is_decimal(*cp))
value = value * 10 + *cp++ - '0';
switch (*cp++) {
#endif
#if defined BB_FEATURE_USE_DEVPS_PATCH
-/* findPidByName()
+/* find_pid_by_name()
*
* This finds the pid of the specified process,
* by using the /dev/ps device driver.
*
* Returns a list of all matching PIDs
*/
-extern pid_t* findPidByName( char* pidName)
+extern pid_t* find_pid_by_name( char* pidName)
{
int fd, i, j;
char device[] = "/dev/ps";
/* open device */
fd = open(device, O_RDONLY);
if (fd < 0)
- fatalError( "open failed for `%s': %s\n", device, strerror (errno));
+ error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno));
/* Find out how many processes there are */
if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
- fatalError( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
/* Allocate some memory -- grab a few extras just in case
* some new processes start up while we wait. The kernel will
/* Now grab the pid list */
if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
- fatalError( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno));
/* Now search for a match */
for (i=1, j=0; i<pid_array[0] ; i++) {
info.pid = pid_array[i];
if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
- fatalError( "\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
+ error_msg_and_die( "\nDEVPS_GET_PID_INFO: %s\n", strerror (errno));
/* Make sure we only match on the process name */
p=info.command_line+1;
/* close device */
if (close (fd) != 0)
- fatalError( "close failed for `%s': %s\n",device, strerror (errno));
+ error_msg_and_die( "close failed for `%s': %s\n",device, strerror (errno));
return pidList;
}
#error Sorry, I depend on the /proc filesystem right now.
#endif
-/* findPidByName()
+/* find_pid_by_name()
*
* This finds the pid of the specified process.
* Currently, it's implemented by rummaging through
*
* Returns a list of all matching PIDs
*/
-extern pid_t* findPidByName( char* pidName)
+extern pid_t* find_pid_by_name( char* pidName)
{
DIR *dir;
struct dirent *next;
dir = opendir("/proc");
if (!dir)
- fatalError( "Cannot open /proc: %s\n", strerror (errno));
+ error_msg_and_die( "Cannot open /proc: %s\n", strerror (errno));
while ((next = readdir(dir)) != NULL) {
FILE *status;
void *ptr = malloc(size);
if (!ptr)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
return ptr;
}
{
void *ptr = realloc(old, size);
if (!ptr)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
return ptr;
}
{
void *ptr = calloc(nmemb, size);
if (!ptr)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
return ptr;
}
#endif
t = strdup (s);
if (t == NULL)
- fatalError(memory_exhausted);
+ error_msg_and_die(memory_exhausted);
return t;
}
char *t;
if (s == NULL)
- fatalError("xstrndup bug");
+ error_msg_and_die("xstrndup bug");
t = xmalloc(n+1);
strncpy(t,s,n);
char fileName[BUFSIZ];
if (stat("/", &rootStat) != 0) {
- errorMsg("could not stat '/'\n");
+ error_msg("could not stat '/'\n");
return( FALSE);
}
dir = opendir("/dev");
if (!dir) {
- errorMsg("could not open '/dev'\n");
+ error_msg("could not open '/dev'\n");
return( FALSE);
}
int errmsgsz = regerror(ret, preg, NULL, 0);
char *errmsg = xmalloc(errmsgsz);
regerror(ret, preg, errmsg, errmsgsz);
- fatalError("xregcomp: %s\n", errmsg);
+ error_msg_and_die("xregcomp: %s\n", errmsg);
}
}
#endif
{
FILE *fp;
if ((fp = fopen(path, mode)) == NULL) {
- errorMsg("%s: %s\n", path, strerror(errno));
+ error_msg("%s: %s\n", path, strerror(errno));
errno = 0;
}
return fp;
{
FILE *fp;
if ((fp = fopen(path, mode)) == NULL)
- fatalError("%s: %s\n", path, strerror(errno));
+ error_msg_and_die("%s: %s\n", path, strerror(errno));
return fp;
}
#endif
char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
- errorMsg("%s: Short file\n", inname);
+ error_msg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
if (fgets (buf, sizeof(buf), stdin) == NULL
|| strcmp (buf, "end\n")) {
- errorMsg("%s: No `end' line\n", inname);
+ error_msg("%s: No `end' line\n", inname);
return FALSE;
}
unsigned char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) {
- errorMsg("%s: Short file\n", inname);
+ error_msg("%s: Short file\n", inname);
return FALSE;
}
p = buf;
if (memcmp (buf, "====", 4) == 0)
break;
if (last_data != 0) {
- errorMsg("%s: data following `=' padding character\n", inname);
+ error_msg("%s: data following `=' padding character\n", inname);
return FALSE;
}
while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=') {
- errorMsg("%s: illegal line\n", inname);
+ error_msg("%s: illegal line\n", inname);
return FALSE;
}
c2 = b64_tab[*p++];
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
- errorMsg("%s: illegal line\n", inname);
+ error_msg("%s: illegal line\n", inname);
return FALSE;
}
if (*p == '=') {
while (b64_tab[*p] == '\177')
if (*p++ == '\n') {
- errorMsg("%s: illegal line\n", inname);
+ error_msg("%s: illegal line\n", inname);
return FALSE;
}
putchar (c1 << 2 | c2 >> 4);
while (1) {
if (fgets (buf, sizeof (buf), stdin) == NULL) {
- errorMsg("%s: No `begin' line\n", inname);
+ error_msg("%s: No `begin' line\n", inname);
return FALSE;
}
while (*p != '/')
++p;
if (*p == '\0') {
- errorMsg("%s: Illegal ~user\n", inname);
+ error_msg("%s: Illegal ~user\n", inname);
return FALSE;
}
*p++ = '\0';
pw = getpwnam (buf + 1);
if (pw == NULL) {
- errorMsg("%s: No user `%s'\n", inname, buf + 1);
+ error_msg("%s: No user `%s'\n", inname, buf + 1);
return FALSE;
}
n = strlen (pw->pw_dir);
&& (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
- errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
+ error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
return FALSE;
}
if (decode (argv[optind], outname) != 0)
exit_status = FALSE;
} else {
- errorMsg("%s: %s\n", argv[optind], strerror(errno));
+ error_msg("%s: %s\n", argv[optind], strerror(errno));
exit_status = EXIT_FAILURE;
}
optind++;
}
if (ferror (stdin))
- errorMsg("Read error\n");
+ error_msg("Read error\n");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
- errorMsg("%s: %s\n", argv[optind], strerror(errno));
+ error_msg("%s: %s\n", argv[optind], strerror(errno));
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
- errorMsg("Write error\n");
+ error_msg("Write error\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
if (do_continue && !fname_out)
- fatalError("cannot specify continue (-c) without a filename (-O)\n");
+ error_msg_and_die("cannot specify continue (-c) without a filename (-O)\n");
/*
* Parse url into components.
*/
if (fname_out != (char *)1) {
if ( (output=fopen(fname_out, (do_continue ? "a" : "w")))
== NULL)
- fatalPerror("fopen(%s)", fname_out);
+ perror_msg_and_die("fopen(%s)", fname_out);
} else {
output = stdout;
}
if (do_continue) {
struct stat sbuf;
if (fstat(fileno(output), &sbuf) < 0)
- fatalError("fstat()");
+ error_msg_and_die("fstat()");
if (sbuf.st_size > 0)
beg_range = sbuf.st_size;
else
* Retrieve HTTP response line and check for "200" status code.
*/
if (fgets(buf, sizeof(buf), sfp) == NULL)
- fatalError("no response from server\n");
+ error_msg_and_die("no response from server\n");
for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
;
for ( ; isspace(*s) ; ++s)
case 200:
if (!do_continue)
break;
- fatalError("server does not support ranges\n");
+ error_msg_and_die("server does not support ranges\n");
case 206:
if (do_continue)
break;
/*FALLTHRU*/
default:
- fatalError("server returned error: %s", buf);
+ error_msg_and_die("server returned error: %s", buf);
}
/*
continue;
}
if (strcmp(buf, "transfer-encoding") == 0) {
- fatalError("server wants to do %s transfer encoding\n", s);
+ error_msg_and_die("server wants to do %s transfer encoding\n", s);
continue;
}
}
filesize -= n;
}
if (n == 0 && ferror(sfp))
- fatalPerror("network read error");
+ perror_msg_and_die("network read error");
exit(0);
}
*uri_port = 80;
if (strncmp(url, "http://", 7) != 0)
- fatalError("not an http url: %s\n", url);
+ error_msg_and_die("not an http url: %s\n", url);
/* pull the host portion to the front of the buffer */
for (s = url, h = url+7 ; *h != '/' && *h != 0; ++h) {
memzero(&sin, sizeof(sin));
sin.sin_family = AF_INET;
if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
- fatalError("cannot resolve %s\n", host);
+ error_msg_and_die("cannot resolve %s\n", host);
memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length);
sin.sin_port = htons(port);
* Get the server onto a stdio stream.
*/
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- fatalPerror("socket()");
+ perror_msg_and_die("socket()");
if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
- fatalPerror("connect(%s)", host);
+ perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL)
- fatalPerror("fdopen()");
+ perror_msg_and_die("fdopen()");
return fp;
}
/* verify we are at the end of the header name */
if (*s != ':')
- fatalError("bad header line: %s\n", buf);
+ error_msg_and_die("bad header line: %s\n", buf);
/* locate the start of the header value */
for (*s++ = '\0' ; *s == ' ' || *s == '\t' ; ++s)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.9 2000/12/07 03:55:35 tausq Exp $
+ * $Id: wget.c,v 1.10 2000/12/07 19:56:48 markw Exp $
*/
puts(user);
return EXIT_SUCCESS;
}
- fatalError("cannot find username for UID %u\n", (unsigned) uid);
+ error_msg_and_die("cannot find username for UID %u\n", (unsigned) uid);
}