diff options
author | Joseph Hunkeler <jhunk@stsci.edu> | 2011-04-06 09:13:03 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunk@stsci.edu> | 2011-04-06 09:13:03 -0400 |
commit | 1a984e6cca24a77b3c62253a605f3645d25d459e (patch) | |
tree | fca25a754cdaef6bb19dd3b3c5f29ced97224210 | |
parent | 7b584bc4bb9c9c3a002328fca60a598da4cc2a4e (diff) | |
download | duser-1a984e6cca24a77b3c62253a605f3645d25d459e.tar.gz |
Starting to port to Solaris 10... sigh.testing-pre1a-sol10
-rw-r--r-- | duser.c | 18 | ||||
-rw-r--r-- | duser.h | 8 |
2 files changed, 25 insertions, 1 deletions
@@ -1,4 +1,5 @@ #define _GNU_SOURCE + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -9,6 +10,11 @@ #include <unistd.h> #include <fcntl.h> #include <libgen.h> + +#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 1) +# define HAVE_STRCHRNUL +#endif + #include "duser.h" char list_path[PATH_MAX]; @@ -25,6 +31,18 @@ int CMD_FLAG_HELP = 0; int CMD_FLAG_LOOK = 0; int CMD_FLAG_NULL = 0; +#ifndef HAVE_STRCHRNUL +char *dstrchrnul(const char* s, int c) +{ + while(*s && *s != c) + { + s++; + } + + return (char*)s; +} +#endif + int user_del_list(const char* filename) { char tmp[PATH_MAX]; @@ -1,7 +1,12 @@ #ifndef DUSER_H #define DUSER_H -#include <limits.h> + +#ifndef HAVE_STRCHRNUL +# define strchrnul(s, c) dstrchrnul(s, c) +#endif + +#include <limits.h> #define REGEX_MAX 255 #define CFG_PATH "/usr/local/etc/duser" #define SELF __FUNCTION__ @@ -44,5 +49,6 @@ int user_del(record_t* rec); int user_cmd(const int argc, char* argv[]); int user_choice(char c); int user_add(const char* filename, const char* needle); +char *dstrchrnul(const char* s, int c); #endif |