diff options
author | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 1999-11-22 18:01:28 +0000 |
---|---|---|
committer | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 1999-11-22 18:01:28 +0000 |
commit | 8d70d953d2f5bf25d243768425ed039395af42cf (patch) | |
tree | 72c673dfe66224a697b58532b188dc87e28de1fb | |
parent | e83dce462fc0b1870657a9e4360f13655fddcb99 (diff) | |
download | libapr-8d70d953d2f5bf25d243768425ed039395af42cf.tar.gz |
Begin to update apr/lib files to follow the standard APR function format.
This is the incredibly low hanging fruit, where all I am doing is
standardizing the return codes for functions that already returned int's.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59484 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | inc/apr_fnmatch.h | 3 | ||||
-rw-r--r-- | include/apr_errno.h | 4 | ||||
-rw-r--r-- | include/apr_fnmatch.h | 3 | ||||
-rw-r--r-- | include/apr_lib.h | 4 | ||||
-rw-r--r-- | include/apr_md5.h | 10 | ||||
-rw-r--r-- | lib/apr_execve.c | 15 | ||||
-rw-r--r-- | lib/apr_fnmatch.c | 10 | ||||
-rw-r--r-- | lib/apr_md5.c | 21 |
8 files changed, 40 insertions, 30 deletions
diff --git a/inc/apr_fnmatch.h b/inc/apr_fnmatch.h index 1b28b1923..a8c96bba7 100644 --- a/inc/apr_fnmatch.h +++ b/inc/apr_fnmatch.h @@ -39,6 +39,7 @@ #else #include "apr_win.h" #endif +#include "apr_errno.h" #ifndef _APR_FNMATCH_H_ #define _APR_FNMATCH_H_ @@ -55,7 +56,7 @@ extern "C" { /* This flag is an Apache addition */ #define FNM_CASE_BLIND 0x08 /* Compare characters case ap_context_t nsensitively. */ -API_EXPORT(int) ap_fnmatch(const char *pattern, const char *strings, +API_EXPORT(ap_status_t) ap_fnmatch(const char *pattern, const char *strings, int flags); /* this function is an Apache addition */ diff --git a/include/apr_errno.h b/include/apr_errno.h index b40728bf7..e68b786cd 100644 --- a/include/apr_errno.h +++ b/include/apr_errno.h @@ -128,6 +128,10 @@ typedef int ap_status_t; */ #define APR_ENOTIMPL (APR_OS_START_STATUS + 17) +/* Passwords do not match. + */ +#define APR_EMISMATCH (APR_OS_START_STATUS + 18) + /* * APR equivalents to what should be standard errno codes. */ diff --git a/include/apr_fnmatch.h b/include/apr_fnmatch.h index 1b28b1923..a8c96bba7 100644 --- a/include/apr_fnmatch.h +++ b/include/apr_fnmatch.h @@ -39,6 +39,7 @@ #else #include "apr_win.h" #endif +#include "apr_errno.h" #ifndef _APR_FNMATCH_H_ #define _APR_FNMATCH_H_ @@ -55,7 +56,7 @@ extern "C" { /* This flag is an Apache addition */ #define FNM_CASE_BLIND 0x08 /* Compare characters case ap_context_t nsensitively. */ -API_EXPORT(int) ap_fnmatch(const char *pattern, const char *strings, +API_EXPORT(ap_status_t) ap_fnmatch(const char *pattern, const char *strings, int flags); /* this function is an Apache addition */ diff --git a/include/apr_lib.h b/include/apr_lib.h index 107551b89..13293968b 100644 --- a/include/apr_lib.h +++ b/include/apr_lib.h @@ -169,8 +169,8 @@ API_EXPORT(int) ap_tokenize_to_argv(ap_context_t *token_context, API_EXPORT(const char *) ap_filename_of_pathname(const char *pathname); /*API_EXPORT(ap_mutex_t *) ap_create_mutex(void *m);*/ API_EXPORT(int) ap_slack(int l, int h); -API_EXPORT_NONSTD(int) ap_execle(const char *c, const char *a, ...); -API_EXPORT_NONSTD(int) ap_execve(const char *c, const char *argv[], +API_EXPORT_NONSTD(ap_status_t) ap_execle(const char *c, const char *a, ...); +API_EXPORT_NONSTD(ap_status_t) ap_execve(const char *c, const char *argv[], const char *envp[]); #define ap_create_mutex(x) (0) diff --git a/include/apr_md5.h b/include/apr_md5.h index 55ac978d5..a70a94add 100644 --- a/include/apr_md5.h +++ b/include/apr_md5.h @@ -113,13 +113,13 @@ typedef struct { unsigned char buffer[64]; /* input buffer */ } APR_MD5_CTX; -API_EXPORT(void) ap_MD5Init(APR_MD5_CTX * context); -API_EXPORT(void) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, +API_EXPORT(ap_status_t) ap_MD5Init(APR_MD5_CTX * context); +API_EXPORT(ap_status_t) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, unsigned int inputLen); -API_EXPORT(void) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context); -API_EXPORT(void) ap_MD5Encode(const char *password, const char *salt, +API_EXPORT(ap_status_t) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context); +API_EXPORT(ap_status_t) ap_MD5Encode(const char *password, const char *salt, char *result, size_t nbytes); -API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash); +API_EXPORT(ap_status_t) ap_validate_password(const char *passwd, const char *hash); #ifdef __cplusplus } diff --git a/lib/apr_execve.c b/lib/apr_execve.c index d31b96e2d..be758ff8d 100644 --- a/lib/apr_execve.c +++ b/lib/apr_execve.c @@ -112,7 +112,7 @@ static const char **hashbang(const char *filename, char **argv); * local argv[] array. The va_arg logic makes sure we do the right thing. * XXX: malloc() is used because we expect to be overlaid soon. */ -int ap_execle(const char *filename, const char *argv0, ...) +ap_status_t ap_execle(const char *filename, const char *argv0, ...) { va_list adummy; char **envp; @@ -127,8 +127,7 @@ int ap_execle(const char *filename, const char *argv0, ...) va_end(adummy); if ((argv = (char **) malloc((argc + 2) * sizeof(*argv))) == NULL) { - fprintf(stderr, "Ouch! Out of memory in ap_execle()!\n"); - return -1; + return APR_ENOMEM; } /* Pass two --- copy the argument strings into the result space */ @@ -140,7 +139,8 @@ int ap_execle(const char *filename, const char *argv0, ...) envp = va_arg(adummy, char **); va_end(adummy); - ret = ap_execve(filename, argv, envp); + ap_execve(filename, argv, envp); + ret = errno; free(argv); return ret; @@ -163,7 +163,7 @@ count_args(const char **args) * We have to fiddle with the argv array to make it work on platforms * which don't support the "hashbang" interpreter line by default. */ -int ap_execve(const char *filename, const char *argv[], +ap_status_t ap_execve(const char *filename, const char *argv[], const char *envp[]) { const char **script_argv; @@ -225,8 +225,7 @@ int ap_execve(const char *filename, const char *argv[], int i = count_args(argv) + 1; /* +1 for leading SHELL_PATH */ if ((script_argv = malloc(sizeof(*script_argv) * i)) == NULL) { - fprintf(stderr, "Ouch! Out of memory in ap_execve()!\n"); - return -1; + return APR_ENOMEM; } script_argv[0] = SHELL_PATH; @@ -241,7 +240,7 @@ int ap_execve(const char *filename, const char *argv[], free(script_argv); } } - return -1; + return errno; } /*---------------------------------------------------------------*/ diff --git a/lib/apr_fnmatch.c b/lib/apr_fnmatch.c index 6e65ce580..c2368b105 100644 --- a/lib/apr_fnmatch.c +++ b/lib/apr_fnmatch.c @@ -56,7 +56,7 @@ static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; static const char *rangematch(const char *, int, int); -API_EXPORT(int) ap_fnmatch(const char *pattern, const char *string, int flags) +API_EXPORT(ap_status_t) ap_fnmatch(const char *pattern, const char *string, int flags) { const char *stringstart; char c, test; @@ -64,7 +64,7 @@ API_EXPORT(int) ap_fnmatch(const char *pattern, const char *string, int flags) for (stringstart = string;;) { switch (c = *pattern++) { case EOS: - return (*string == EOS ? 0 : FNM_NOMATCH); + return (*string == EOS ? APR_SUCCESS : FNM_NOMATCH); case '?': if (*string == EOS) { return (FNM_NOMATCH); @@ -95,10 +95,10 @@ API_EXPORT(int) ap_fnmatch(const char *pattern, const char *string, int flags) /* Optimize for pattern with * at end or before /. */ if (c == EOS) { if (flags & FNM_PATHNAME) { - return (strchr(string, '/') == NULL ? 0 : FNM_NOMATCH); + return (strchr(string, '/') == NULL ? APR_SUCCESS : FNM_NOMATCH); } else { - return (0); + return (APR_SUCCESS); } } else if (c == '/' && flags & FNM_PATHNAME) { @@ -111,7 +111,7 @@ API_EXPORT(int) ap_fnmatch(const char *pattern, const char *string, int flags) /* General case, use recursion. */ while ((test = *string) != EOS) { if (!ap_fnmatch(pattern, string, flags & ~FNM_PERIOD)) { - return (0); + return (APR_SUCCESS); } if (test == '/' && flags & FNM_PATHNAME) { break; diff --git a/lib/apr_md5.c b/lib/apr_md5.c index 43d42e6e4..2c1b25d47 100644 --- a/lib/apr_md5.c +++ b/lib/apr_md5.c @@ -178,7 +178,7 @@ static unsigned char PADDING[64] = /* MD5 initialization. Begins an MD5 operation, writing a new context. */ -API_EXPORT(void) ap_MD5Init(APR_MD5_CTX * context) +API_EXPORT(ap_status_t) ap_MD5Init(APR_MD5_CTX * context) { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. */ @@ -186,13 +186,14 @@ API_EXPORT(void) ap_MD5Init(APR_MD5_CTX * context) context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; + return APR_SUCCESS; } /* MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context. */ -API_EXPORT(void) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, +API_EXPORT(ap_status_t) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, unsigned int inputLen) { unsigned int i, idx, partLen; @@ -242,12 +243,13 @@ API_EXPORT(void) ap_MD5Update(APR_MD5_CTX * context, const unsigned char *input, /* Buffer remaining input */ ebcdic2ascii_strictly(&context->buffer[idx], &input[i], inputLen - i); #endif /*CHARSET_EBCDIC*/ + return APR_SUCCESS; } /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -API_EXPORT(void) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) +API_EXPORT(ap_status_t) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) { unsigned char bits[8]; unsigned int idx, padLen; @@ -284,6 +286,8 @@ API_EXPORT(void) ap_MD5Final(unsigned char digest[16], APR_MD5_CTX * context) /* Zeroize sensitive information. */ memset(context, 0, sizeof(*context)); + + return APR_SUCCESS; } /* MD5 basic transformation. Transforms state based on block. */ @@ -426,7 +430,7 @@ static void to64(char *s, unsigned long v, int n) } } -API_EXPORT(void) ap_MD5Encode(const char *pw, const char *salt, +API_EXPORT(ap_status_t) ap_MD5Encode(const char *pw, const char *salt, char *result, size_t nbytes) { /* @@ -573,16 +577,17 @@ API_EXPORT(void) ap_MD5Encode(const char *pw, const char *salt, memset(final, 0, sizeof(final)); ap_cpystrn(result, passwd, nbytes - 1); + return APR_SUCCESS; } /* * Validate a plaintext password against a smashed one. Use either * crypt() (if available) or ap_MD5Encode(), depending upon the format - * of the smashed input password. Return NULL if they match, or - * an explanatory text string if they don't. + * of the smashed input password. Return APR_SUCCESS if they match, or + * APR_EMISMATCH if they don't. */ -API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash) +API_EXPORT(ap_status_t) ap_validate_password(const char *passwd, const char *hash) { char sample[120]; #ifndef WIN32 @@ -605,5 +610,5 @@ API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash) ap_cpystrn(sample, crypt_pw, sizeof(sample) - 1); #endif } - return (strcmp(sample, hash) == 0) ? NULL : "password mismatch"; + return (strcmp(sample, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH; } |