diff options
author | ewt <devnull@localhost> | 1998-03-04 16:51:38 +0000 |
---|---|---|
committer | ewt <devnull@localhost> | 1998-03-04 16:51:38 +0000 |
commit | 1d7baffb338d8571d9ba15f1ebac67325bb8e94a (patch) | |
tree | 66e4ae6ae19b1c83df9feebf3a244f73d8138d72 /misc | |
parent | d29004dc6918935f3a6916e59f373874a5f6ab85 (diff) | |
download | librpm-tizen-1d7baffb338d8571d9ba15f1ebac67325bb8e94a.tar.gz librpm-tizen-1d7baffb338d8571d9ba15f1ebac67325bb8e94a.tar.bz2 librpm-tizen-1d7baffb338d8571d9ba15f1ebac67325bb8e94a.zip |
1) make use of new delpendency scheme
2) made " #if" look like "# if" for portability
3) added strdup.c
CVS patchset: 2021
CVS date: 1998/03/04 16:51:38
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Makefile.in | 11 | ||||
-rw-r--r-- | misc/getmntent.c | 6 | ||||
-rw-r--r-- | misc/miscfn.h | 28 | ||||
-rw-r--r-- | misc/strdup.c | 44 |
4 files changed, 73 insertions, 16 deletions
diff --git a/misc/Makefile.in b/misc/Makefile.in index 35ac3bb3a..d7365bb29 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -1,4 +1,5 @@ srcdir = @srcdir@ +top_srcdir = @top_srcdir@ VPATH = $(srcdir) include ../Makefile.inc @@ -8,11 +9,7 @@ LIBMISC = libmisc.a # ----------------------------------------------------------------------- -ifeq (.depend,$(wildcard .depend)) TARGET=everything -else -TARGET=depend everything -endif all: $(TARGET) @@ -28,10 +25,12 @@ clean: rm -f *.a *.o *~ $(PROGS) distclean: clean - rm -f .depend Makefile + rm -f Makefile depend: - $(CPP) $(CFLAGS) -M $(srcdir)/*.c > .depend + topdir_path=`( cd $(top_srcdir) && pwd )` ; \ + $(CPP) $(CFLAGS) -MM $(srcdir)/*.c | \ + sed s+$$topdir_path+$(top_srcdir)+g > .depend ifeq (.depend,$(wildcard .depend)) include .depend diff --git a/misc/getmntent.c b/misc/getmntent.c index 6b0092e48..4c0a400bc 100644 --- a/misc/getmntent.c +++ b/misc/getmntent.c @@ -40,7 +40,7 @@ our_mntent *getmntent(FILE *filep) { if (*chptr == COMMENTCHAR) continue; - #if __aix__ +# if __aix__ /* aix uses a screwed up file format */ if (*chptr == '/') { start = chptr; @@ -49,7 +49,7 @@ our_mntent *getmntent(FILE *filep) { item.mnt_dir = strdup(start); return &item; } - #else +# else while (!isspace(*chptr) && (*chptr)) chptr++; if (!*chptr) return NULL; @@ -62,7 +62,7 @@ our_mntent *getmntent(FILE *filep) { item.our_mntdir = strdup(start); return &item; - #endif +# endif } return NULL; diff --git a/misc/miscfn.h b/misc/miscfn.h index 8b21c68da..f7fb1fccf 100644 --- a/misc/miscfn.h +++ b/misc/miscfn.h @@ -35,13 +35,19 @@ char *realpath(const char *path, char resolved_path []); #endif +#if HAVE_SYS_STDTYPES_H +# include <sys/stdtypes.h> +#endif + +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + #if NEED_TIMEZONE -#include <sys/stdtypes.h> extern time_t timezone; #endif #if NEED_MYREALLOC -#include <sys/stdtypes.h> #define realloc(ptr,size) myrealloc(ptr,size) extern void *myrealloc(void *, size_t); #endif @@ -66,7 +72,15 @@ extern void *myrealloc(void *, size_t); #if HAVE_GETMNTINFO_R || HAVE_MNTCTL # define GETMNTENT_ONE 0 # define GETMNTENT_TWO 0 -# include <sys/mount.h> +# if HAVE_SYS_MNTCTL_H +# include <sys/mntctl.h> +# endif +# if HAVE_SYS_VMOUNT_H +# include <sys/vmount.h> +# endif +# if HAVE_SYS_MOUNT_H +# include <sys/mount.h> +# endif #elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB # if HAVE_MNTENT_H # include <stdio.h> @@ -74,15 +88,15 @@ extern void *myrealloc(void *, size_t); # define our_mntent struct mntent # define our_mntdir mnt_dir # elif HAVE_STRUCT_MNTTAB - #include <stdio.h> - #include <mnttab.h> +# include <stdio.h> +# include <mnttab.h> struct our_mntent { char * our_mntdir; }; struct our_mntent *getmntent(FILE *filep); # define our_mntent struct our_mntent # else - #include <stdio.h> +# include <stdio.h> struct our_mntent { char * our_mntdir; }; @@ -98,7 +112,7 @@ extern void *myrealloc(void *, size_t); # define GETMNTENT_TWO 1 # define our_mntent struct mnttab # define our_mntdir mnt_mountp -#else if !HAVE_MNTCTL +#else /* if !HAVE_MNTCTL */ # error Neither mntent.h, mnttab.h, or mntctl() exists. I cannot build on this system. #endif diff --git a/misc/strdup.c b/misc/strdup.c new file mode 100644 index 000000000..9236fe7db --- /dev/null +++ b/misc/strdup.c @@ -0,0 +1,44 @@ +/* + * Author: Tim Mooney <mooney@plains.nodak.edu> + * Copyright: This file is in the public domain. + * + * a replacement for strdup() for those platforms that don't have it, + * like Ultrix. + * + * Requires: malloc(), strlen(), strcpy(). + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#if defined(HAVE_STDLIB_H) || defined(STDC_HEADERS) +# include <stdlib.h> +#else +extern void *malloc(size_t); +#endif + +#if defined(HAVE_STRING_H) || defined(STDC_HEADERS) +# include <string.h> +#else +extern size_t strlen(const char *); +extern char *strcpy(char *, const char *); +#endif + +char * strdup(const char *s) { + void *p = NULL; + + p = malloc(strlen(s)+1); + if (!p) { + return NULL; + } + + strcpy( (char *) p, s); + return (char *) p; +} + |