mirror of
https://kernel.googlesource.com/pub/scm/network/tftp/tftp-hpa
synced 2025-04-28 10:59:53 +03:00
Add replacement library files
This commit is contained in:
parent
e6593dd693
commit
d0fec7a322
4 changed files with 87 additions and 0 deletions
23
lib/Makefile
Normal file
23
lib/Makefile
Normal file
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# Extra functions which may not be available everywhere
|
||||
#
|
||||
|
||||
include ../MCONFIG
|
||||
include ../MRULES
|
||||
|
||||
all: libxtra.a
|
||||
|
||||
install:
|
||||
|
||||
clean:
|
||||
-rm -f *.a *.o
|
||||
|
||||
spotless: clean
|
||||
-rm -f *~
|
||||
|
||||
libxtra.a: $(LIBOBJS)
|
||||
-rm -f libxtra.a
|
||||
$(AR) libxtra.a $(LIBOBJS)
|
||||
$(RANLIB) libxtra.a
|
||||
|
||||
|
21
lib/bsdsignal.c
Normal file
21
lib/bsdsignal.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* bsdsignal.c
|
||||
*
|
||||
* Use sigaction() to simulate BSD signal()
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void bsd_signal(int signum, void (*handler)(int))
|
||||
{
|
||||
struct sigaction action;
|
||||
|
||||
memset(&action, 0, sizeof action);
|
||||
action.sa_handler = handler;
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = SA_RESTART;
|
||||
|
||||
sigaction(hander, action, NULL);
|
||||
}
|
21
lib/xmalloc.c
Normal file
21
lib/xmalloc.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* xmalloc.c
|
||||
*
|
||||
* Simple error-checking version of malloc()
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void *xmalloc(size_t size)
|
||||
{
|
||||
void *p = malloc(size);
|
||||
|
||||
if ( !p ) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(128);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
22
lib/xstrdup.c
Normal file
22
lib/xstrdup.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* xstrdup.c
|
||||
*
|
||||
* Simple error-checking version of strdup()
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *xstrdup(const char *s)
|
||||
{
|
||||
char *p = strdup(s);
|
||||
|
||||
if ( !p ) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(128);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue