Re: [PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir /corrected

2004-03-24 Thread Eric Horner
who are you? stop emailing me!
- Original Message -
From: Guenter Knauf [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, March 13, 2004 6:35 PM
Subject: [PATCH] htdigest.c - remove ugly dependance on external cp; use
apr_temp_dir_get() for getting temp dir /corrected


Hi,
corrected cast for gcc; replaced some more printf() I just found.

this patch makes htdigest use the apr_temp_dir_get() for getting the temp
dir;
and also removes the dependance on external cp/copy;
changed printout to use apr function like htpasswd;
replaced tabs with spaces.
I've have tested this on NetWare and Win32.
The OMIT_DELONCLOSE I left in for now cause currently I've problems on
NetWare with copying open files, but I think we get that fixed in APR soon,
then it will be obsolete unless other platforms have similar problems.

--- htdigest.c.orig Mon Feb 09 21:59:50 2004
+++ htdigest.c  Sun Mar 14 00:28:58 2004
@@ -65,12 +65,13 @@
  *
  * XXX: Other systems affected? (Netware?, OS2?)
  */
-#if (defined(WIN32))
+#if defined(NETWARE)
 #define OMIT_DELONCLOSE 1
 #endif

 apr_file_t *tfp = NULL;
-apr_pool_t *cntxt;
+apr_file_t *errfile;
+apr_pool_t *pool;
 #if APR_CHARSET_EBCDIC
 apr_xlate_t *to_ascii;
 #endif
@@ -83,14 +84,14 @@
 char *filename = NULL;

 if (apr_file_name_get(cfilename, tfp) == APR_SUCCESS) {
-filename = apr_pstrdup(cntxt, cfilename);
+filename = apr_pstrdup(pool, cfilename);
 }
 #endif
- apr_file_close(tfp);
+apr_file_close(tfp);

 #ifdef OMIT_DELONCLOSE
 if (filename) {
-apr_file_remove(filename, cntxt);
+apr_file_remove(filename, pool);
 }
 #endif
 }
@@ -103,11 +104,11 @@
 int x = 0, y;

 for (x = 0; ((line[x])  (line[x] != stop)); x++)
- word[x] = line[x];
+word[x] = line[x];

 word[x] = '\0';
 if (line[x])
- ++x;
+++x;
 y = 0;

 while ((line[y++] = line[x++]));
@@ -138,7 +139,7 @@
 int x;

 for (x = 0; l[x]; x++)
- apr_file_putc(l[x], f);
+apr_file_putc(l[x], f);
 }


@@ -154,13 +155,13 @@
 apr_size_t len = sizeof(pwin);

 if (apr_password_get(New password: , pwin, len) != APR_SUCCESS) {
- fprintf(stderr, password too long);
- cleanup_tempfile_and_exit(5);
+apr_file_printf(errfile, password too long);
+cleanup_tempfile_and_exit(5);
 }
 len = sizeof(pwin);
 apr_password_get(Re-type new password: , pwv, len);
 if (strcmp(pwin, pwv) != 0) {
- fprintf(stderr, They don't match, sorry.\n);
+apr_file_printf(errfile, They don't match, sorry.\n);
 cleanup_tempfile_and_exit(1);
 }
 pw = pwin;
@@ -177,30 +178,30 @@
 apr_md5_final(digest, context);

 for (i = 0; i  16; i++)
- apr_file_printf(f, %02x, digest[i]);
+apr_file_printf(f, %02x, digest[i]);

 apr_file_printf(f, \n);
 }

 static void usage(void)
 {
-fprintf(stderr, Usage: htdigest [-c] passwordfile realm username\n);
-fprintf(stderr, The -c flag creates a new file.\n);
+apr_file_printf(errfile, Usage: htdigest [-c] passwordfile realm
username\n);
+apr_file_printf(errfile, The -c flag creates a new file.\n);
 exit(1);
 }

 static void interrupted(void)
 {
-fprintf(stderr, Interrupted.\n);
+apr_file_printf(errfile, Interrupted.\n);
 cleanup_tempfile_and_exit(1);
 }

 static void terminate(void)
 {
+apr_terminate();
 #ifdef NETWARE
 pressanykey();
 #endif
-apr_terminate();
 }

 int main(int argc, const char * const argv[])
@@ -208,23 +209,24 @@
 apr_file_t *f;
 apr_status_t rv;
 char tn[] = htdigest.tmp.XX;
+char *dirname;
 char user[MAX_STRING_LEN];
 char realm[MAX_STRING_LEN];
 char line[MAX_STRING_LEN];
 char l[MAX_STRING_LEN];
 char w[MAX_STRING_LEN];
 char x[MAX_STRING_LEN];
-char command[MAX_STRING_LEN];
 int found;

 apr_app_initialize(argc, argv, NULL);
 atexit(terminate);
-apr_pool_create(cntxt, NULL);
+apr_pool_create(pool, NULL);
+apr_file_open_stderr(errfile, pool);

 #if APR_CHARSET_EBCDIC
-rv = apr_xlate_open(to_ascii, ISO8859-1, APR_DEFAULT_CHARSET,
cntxt);
+rv = apr_xlate_open(to_ascii, ISO8859-1, APR_DEFAULT_CHARSET, pool);
 if (rv) {
-fprintf(stderr, apr_xlate_open(): %s (%d)\n,
+apr_file_printf(errfile, apr_xlate_open(): %s (%d)\n,
 apr_strerror(rv, line, sizeof(line)), rv);
 exit(1);
 }
@@ -232,81 +234,91 @@

 apr_signal(SIGINT, (void (*)(int)) interrupted);
 if (argc == 5) {
- if (strcmp(argv[1], -c))
- usage();
- rv = apr_file_open(f, argv[2], APR_WRITE | APR_CREATE, -1, cntxt);
+if (strcmp(argv[1], -c))
+usage();
+rv = apr_file_open(f, argv[2], APR_WRITE | APR_CREATE, -1, pool);
 if (rv != APR_SUCCESS) {
 char errmsg[120];

- fprintf(stderr, Could not open passwd file %s for writing: %s\n,
- argv[2],
+apr_file_printf(errfile

Re: [PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir

2004-03-15 Thread Guenter Knauf
Hi Thom,
 This really ought to be 4 seperate patches for ease of review.
 Please can you resend as such?
something's wrong with the four splitted patches, or simply no time to review??

Guenter.




Re: [PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir

2004-03-15 Thread Thom May
* Guenter Knauf ([EMAIL PROTECTED]) wrote :
 Hi Thom,
  This really ought to be 4 seperate patches for ease of review.
  Please can you resend as such?
 something's wrong with the four splitted patches, or simply no time to review??
 
Damn, dude. it's only been 1 *work*day.
-Thom


Re: [PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir

2004-03-14 Thread Thom May
* Guenter Knauf ([EMAIL PROTECTED]) wrote :
 Hi,
 this patch makes htdigest use the apr_temp_dir_get() for getting the temp dir;
 and also removes the dependance on external cp/copy;
 changed printout to use apr function like htpasswd;
 replaced tabs with spaces.
This really ought to be 4 seperate patches for ease of review.
Please can you resend as such?
-Thom


Re: [PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir

2004-03-14 Thread Guenter Knauf
Hi,
 * Guenter Knauf ([EMAIL PROTECTED]) wrote :
 Hi,
 this patch makes htdigest use the apr_temp_dir_get() for getting the temp
 dir;
 and also removes the dependance on external cp/copy;
 changed printout to use apr function like htpasswd;
 replaced tabs with spaces.
 This really ought to be 4 seperate patches for ease of review.
 Please can you resend as such?
sorry, I thought that too when I reviewed it before sending; will soon resend as 
separate patches.

Guenter.




[PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir /corrected

2004-03-13 Thread Guenter Knauf
Hi,
corrected cast for gcc; replaced some more printf() I just found.

this patch makes htdigest use the apr_temp_dir_get() for getting the temp dir;
and also removes the dependance on external cp/copy;
changed printout to use apr function like htpasswd;
replaced tabs with spaces.
I've have tested this on NetWare and Win32.
The OMIT_DELONCLOSE I left in for now cause currently I've problems on NetWare with 
copying open files, but I think we get that fixed in APR soon, then it will be 
obsolete unless other platforms have similar problems.

--- htdigest.c.orig Mon Feb 09 21:59:50 2004
+++ htdigest.c  Sun Mar 14 00:28:58 2004
@@ -65,12 +65,13 @@
  *
  * XXX: Other systems affected? (Netware?, OS2?)
  */
-#if (defined(WIN32))
+#if defined(NETWARE)
 #define OMIT_DELONCLOSE 1
 #endif
 
 apr_file_t *tfp = NULL;
-apr_pool_t *cntxt;
+apr_file_t *errfile;
+apr_pool_t *pool;
 #if APR_CHARSET_EBCDIC
 apr_xlate_t *to_ascii;
 #endif
@@ -83,14 +84,14 @@
 char *filename = NULL;
 
 if (apr_file_name_get(cfilename, tfp) == APR_SUCCESS) {
-filename = apr_pstrdup(cntxt, cfilename);
+filename = apr_pstrdup(pool, cfilename);
 }
 #endif
-   apr_file_close(tfp);
+apr_file_close(tfp);
 
 #ifdef OMIT_DELONCLOSE
 if (filename) {
-apr_file_remove(filename, cntxt);
+apr_file_remove(filename, pool);
 }
 #endif
 }
@@ -103,11 +104,11 @@
 int x = 0, y;
 
 for (x = 0; ((line[x])  (line[x] != stop)); x++)
-   word[x] = line[x];
+word[x] = line[x];
 
 word[x] = '\0';
 if (line[x])
-   ++x;
+++x;
 y = 0;
 
 while ((line[y++] = line[x++]));
@@ -138,7 +139,7 @@
 int x;
 
 for (x = 0; l[x]; x++)
-   apr_file_putc(l[x], f);
+apr_file_putc(l[x], f);
 }
 
 
@@ -154,13 +155,13 @@
 apr_size_t len = sizeof(pwin);
 
 if (apr_password_get(New password: , pwin, len) != APR_SUCCESS) {
-   fprintf(stderr, password too long);
-   cleanup_tempfile_and_exit(5);
+apr_file_printf(errfile, password too long);
+cleanup_tempfile_and_exit(5);
 }
 len = sizeof(pwin);
 apr_password_get(Re-type new password: , pwv, len);
 if (strcmp(pwin, pwv) != 0) {
-   fprintf(stderr, They don't match, sorry.\n);
+apr_file_printf(errfile, They don't match, sorry.\n);
 cleanup_tempfile_and_exit(1);
 }
 pw = pwin;
@@ -177,30 +178,30 @@
 apr_md5_final(digest, context);
 
 for (i = 0; i  16; i++)
-   apr_file_printf(f, %02x, digest[i]);
+apr_file_printf(f, %02x, digest[i]);
 
 apr_file_printf(f, \n);
 }
 
 static void usage(void)
 {
-fprintf(stderr, Usage: htdigest [-c] passwordfile realm username\n);
-fprintf(stderr, The -c flag creates a new file.\n);
+apr_file_printf(errfile, Usage: htdigest [-c] passwordfile realm username\n);
+apr_file_printf(errfile, The -c flag creates a new file.\n);
 exit(1);
 }
 
 static void interrupted(void)
 {
-fprintf(stderr, Interrupted.\n);
+apr_file_printf(errfile, Interrupted.\n);
 cleanup_tempfile_and_exit(1);
 }
 
 static void terminate(void)
 {
+apr_terminate();
 #ifdef NETWARE
 pressanykey();
 #endif
-apr_terminate();
 }
 
 int main(int argc, const char * const argv[])
@@ -208,23 +209,24 @@
 apr_file_t *f;
 apr_status_t rv;
 char tn[] = htdigest.tmp.XX;
+char *dirname;
 char user[MAX_STRING_LEN];
 char realm[MAX_STRING_LEN];
 char line[MAX_STRING_LEN];
 char l[MAX_STRING_LEN];
 char w[MAX_STRING_LEN];
 char x[MAX_STRING_LEN];
-char command[MAX_STRING_LEN];
 int found;

 apr_app_initialize(argc, argv, NULL);
 atexit(terminate); 
-apr_pool_create(cntxt, NULL);
+apr_pool_create(pool, NULL);
+apr_file_open_stderr(errfile, pool);
 
 #if APR_CHARSET_EBCDIC
-rv = apr_xlate_open(to_ascii, ISO8859-1, APR_DEFAULT_CHARSET, cntxt);
+rv = apr_xlate_open(to_ascii, ISO8859-1, APR_DEFAULT_CHARSET, pool);
 if (rv) {
-fprintf(stderr, apr_xlate_open(): %s (%d)\n,
+apr_file_printf(errfile, apr_xlate_open(): %s (%d)\n,
 apr_strerror(rv, line, sizeof(line)), rv);
 exit(1);
 }
@@ -232,81 +234,91 @@
 
 apr_signal(SIGINT, (void (*)(int)) interrupted);
 if (argc == 5) {
-   if (strcmp(argv[1], -c))
-   usage();
-   rv = apr_file_open(f, argv[2], APR_WRITE | APR_CREATE, -1, cntxt);
+if (strcmp(argv[1], -c))
+usage();
+rv = apr_file_open(f, argv[2], APR_WRITE | APR_CREATE, -1, pool);
 if (rv != APR_SUCCESS) {
 char errmsg[120];
 
-   fprintf(stderr, Could not open passwd file %s for writing: %s\n,
-   argv[2],
+apr_file_printf(errfile, Could not open passwd file %s for writing: 
%s\n,
+argv[2],
 apr_strerror(rv, errmsg, sizeof errmsg));
-   exit(1);
-   }
-

[PATCH] htdigest.c - remove ugly dependance on external cp; use apr_temp_dir_get() for getting temp dir

2004-03-11 Thread Guenter Knauf
Hi,
this patch makes htdigest use the apr_temp_dir_get() for getting the temp dir;
and also removes the dependance on external cp/copy;
changed printout to use apr function like htpasswd;
replaced tabs with spaces.
I've have tested this on NetWare and Win32.
The OMIT_DELONCLOSE I left in for now cause currently I've problems on NetWare with 
copying open files, but I think we get that fixed in APR soon, then it will be 
obsolete unless other platforms have similar problems.

--- htdigest.c.orig Mon Feb 09 21:59:50 2004
+++ htdigest.c  Fri Mar 12 00:01:58 2004
@@ -65,12 +65,13 @@
  *
  * XXX: Other systems affected? (Netware?, OS2?)
  */
-#if (defined(WIN32))
+#if defined(NETWARE)
 #define OMIT_DELONCLOSE 1
 #endif
 
 apr_file_t *tfp = NULL;
-apr_pool_t *cntxt;
+apr_file_t *errfile;
+apr_pool_t *pool;
 #if APR_CHARSET_EBCDIC
 apr_xlate_t *to_ascii;
 #endif
@@ -83,14 +84,14 @@
 char *filename = NULL;
 
 if (apr_file_name_get(cfilename, tfp) == APR_SUCCESS) {
-filename = apr_pstrdup(cntxt, cfilename);
+filename = apr_pstrdup(pool, cfilename);
 }
 #endif
-   apr_file_close(tfp);
+apr_file_close(tfp);
 
 #ifdef OMIT_DELONCLOSE
 if (filename) {
-apr_file_remove(filename, cntxt);
+apr_file_remove(filename, pool);
 }
 #endif
 }
@@ -103,11 +104,11 @@
 int x = 0, y;
 
 for (x = 0; ((line[x])  (line[x] != stop)); x++)
-   word[x] = line[x];
+word[x] = line[x];
 
 word[x] = '\0';
 if (line[x])
-   ++x;
+++x;
 y = 0;
 
 while ((line[y++] = line[x++]));
@@ -138,7 +139,7 @@
 int x;
 
 for (x = 0; l[x]; x++)
-   apr_file_putc(l[x], f);
+apr_file_putc(l[x], f);
 }
 
 
@@ -154,13 +155,13 @@
 apr_size_t len = sizeof(pwin);
 
 if (apr_password_get(New password: , pwin, len) != APR_SUCCESS) {
-   fprintf(stderr, password too long);
-   cleanup_tempfile_and_exit(5);
+apr_file_printf(errfile, password too long);
+cleanup_tempfile_and_exit(5);
 }
 len = sizeof(pwin);
 apr_password_get(Re-type new password: , pwv, len);
 if (strcmp(pwin, pwv) != 0) {
-   fprintf(stderr, They don't match, sorry.\n);
+apr_file_printf(errfile, They don't match, sorry.\n);
 cleanup_tempfile_and_exit(1);
 }
 pw = pwin;
@@ -177,30 +178,30 @@
 apr_md5_final(digest, context);
 
 for (i = 0; i  16; i++)
-   apr_file_printf(f, %02x, digest[i]);
+apr_file_printf(f, %02x, digest[i]);
 
 apr_file_printf(f, \n);
 }
 
 static void usage(void)
 {
-fprintf(stderr, Usage: htdigest [-c] passwordfile realm username\n);
-fprintf(stderr, The -c flag creates a new file.\n);
+apr_file_printf(errfile, Usage: htdigest [-c] passwordfile realm username\n);
+apr_file_printf(errfile, The -c flag creates a new file.\n);
 exit(1);
 }
 
 static void interrupted(void)
 {
-fprintf(stderr, Interrupted.\n);
+apr_file_printf(errfile, Interrupted.\n);
 cleanup_tempfile_and_exit(1);
 }
 
 static void terminate(void)
 {
+apr_terminate();
 #ifdef NETWARE
 pressanykey();
 #endif
-apr_terminate();
 }
 
 int main(int argc, const char * const argv[])
@@ -208,23 +209,24 @@
 apr_file_t *f;
 apr_status_t rv;
 char tn[] = htdigest.tmp.XX;
+char *dirname;
 char user[MAX_STRING_LEN];
 char realm[MAX_STRING_LEN];
 char line[MAX_STRING_LEN];
 char l[MAX_STRING_LEN];
 char w[MAX_STRING_LEN];
 char x[MAX_STRING_LEN];
-char command[MAX_STRING_LEN];
 int found;

 apr_app_initialize(argc, argv, NULL);
 atexit(terminate); 
-apr_pool_create(cntxt, NULL);
+apr_pool_create(pool, NULL);
+apr_file_open_stderr(errfile, pool);
 
 #if APR_CHARSET_EBCDIC
-rv = apr_xlate_open(to_ascii, ISO8859-1, APR_DEFAULT_CHARSET, cntxt);
+rv = apr_xlate_open(to_ascii, ISO8859-1, APR_DEFAULT_CHARSET, pool);
 if (rv) {
-fprintf(stderr, apr_xlate_open(): %s (%d)\n,
+apr_file_printf(errfile, apr_xlate_open(): %s (%d)\n,
 apr_strerror(rv, line, sizeof(line)), rv);
 exit(1);
 }
@@ -232,81 +234,89 @@
 
 apr_signal(SIGINT, (void (*)(int)) interrupted);
 if (argc == 5) {
-   if (strcmp(argv[1], -c))
-   usage();
-   rv = apr_file_open(f, argv[2], APR_WRITE | APR_CREATE, -1, cntxt);
+if (strcmp(argv[1], -c))
+usage();
+rv = apr_file_open(f, argv[2], APR_WRITE | APR_CREATE, -1, pool);
 if (rv != APR_SUCCESS) {
 char errmsg[120];
 
-   fprintf(stderr, Could not open passwd file %s for writing: %s\n,
-   argv[2],
+apr_file_printf(errfile, Could not open passwd file %s for writing: 
%s\n,
+argv[2],
 apr_strerror(rv, errmsg, sizeof errmsg));
-   exit(1);
-   }
-   printf(Adding password for %s in realm %s.\n, argv[4],