apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: [PATCH] get string showing supported dbm types in typical usage-syntax manner
Date Fri, 31 Mar 2006 19:24:32 GMT
I was about to say 'wrong list?' - but yes.  Can we add a second arg to let
the user pick "|", ", " or some other list delim?  Is there something we can
do to indicate which one -is- the default?

Jeff Trawick wrote:
> Apache httpd's htdbm's often-incorrect usage statement could use
> something like this patch:
> 
> -    fprintf(stderr, "   -T   DBM Type (SDBM|GDBM|DB|default).\n");
> +    fprintf(stderr, "   -T   DBM Type (%s).\n",
> +            apr_dbm_typestring_get(pool));
> 
> Or should applications that need to do something like that build their
> own string via APU_HAVE_foo and assume that the apr-util they built
> with matches the one they're running with?
> 
> 
> ------------------------------------------------------------------------
> 
> Index: include/apr_dbm.h
> ===================================================================
> --- include/apr_dbm.h	(revision 376249)
> +++ include/apr_dbm.h	(working copy)
> @@ -216,6 +216,14 @@
>                                          const char **used1,
>                                          const char **used2);
>  
> +/**
> + * Return a string describing the supported dbm types, suitable for
> + * display to the user.  A typical value:
> + *   "GDBM|SDBM|default"
> + * @param pool The pool for allocating the string.
> + */
> +APU_DECLARE(const char *) apr_dbm_typestring_get(apr_pool_t *pool);
> +
>  /** @} */
>  #ifdef __cplusplus
>  }
> Index: dbm/apr_dbm.c
> ===================================================================
> --- dbm/apr_dbm.c	(revision 376249)
> +++ dbm/apr_dbm.c	(working copy)
> @@ -46,6 +46,29 @@
>  #error a DBM implementation was not specified
>  #endif
>  
> +static const char *dbm_typestring =
> +#if APU_HAVE_GDBM
> +"GDBM|"
> +#endif
> +#if APU_HAVE_SDBM
> +"SDBM|"
> +#endif
> +#if APU_HAVE_DB
> +"DB|"
> +#endif
> +#if APU_HAVE_NDBM
> +"NDBM|"
> +#endif
> +"default";
> +
> +APU_DECLARE(const char *) apr_dbm_typestring_get(apr_pool_t *pool)
> +{
> +    /* maybe we load this support dynamically in the future and
> +     * have to build the string at run-time?
> +     */
> +    return apr_pstrdup(pool, dbm_typestring);
> +}
> +
>  APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **pdb, const char*type, 
>                                         const char *pathname, 
>                                         apr_int32_t mode, apr_fileperms_t perm,
> 
> 
> 


Mime
View raw message