[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] More on bb_xfopen vs bb_wfopen
From:       Tito <farmatito () tiscali ! it>
Date:       2003-09-29 13:09:12
[Download RAW message or body]

Hi  to all,

FILE *bb_xfopen(const char *path, const char *mode)
{
	FILE *fp;
	if ((fp = fopen(path, mode)) == NULL)
		bb_perror_msg_and_die("%s", path);
	return fp;
}

FILE *bb_wfopen(const char *path, const char *mode)
{
	FILE *fp;
	if ((fp = fopen(path, mode)) == NULL) {
		bb_perror_msg("%s", path);
		errno = 0;
	}
	return fp;
}

seems to me the major diff is in the bb_error_msg_and_die call.
Maybe they could be unified as:

FILE *bb_xwfopen(int die, const char *path, const char *mode)
{
	FILE *fp;
	if ((fp = fopen(path, mode)) == NULL)
	{
		bb_perror_msg("%s", path);
		errno = 0;
		if(die==1)
			exit(EXIT_FAILURE)	
	}
	return fp;
}


BTW: the same patch could be applied to most of the bb_x* functions
(think about  how to write a port scanner with  xconnect etc.)
as they would be useful also in situations when you want the 
program to issue a warning but no to die.


........I know this would make necessary a major rewrote of all bb applets. :-P
........was just an idea.

Ciao
Tito


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic