httxt2dbm.c revision 4a5329dc80d2da163d3eb2f3ab26234b5c271c7a
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* httxt2dbm.c: simple program for converting RewriteMap text files to DBM
* Rewrite databases for the Apache HTTP server
*
*/
#include "apr.h"
#include "apr_lib.h"
#include "apr_strings.h"
#include "apr_file_io.h"
#include "apr_file_info.h"
#include "apr_pools.h"
#include "apr_getopt.h"
#include "apu.h"
#include "apr_dbm.h"
#include <stdlib.h> /* for atexit() */
#endif
static const char *input;
static const char *output;
static const char *format;
static const char *shortname;
static apr_file_t *errfile;
static char errbuf[120];
static int verbose;
/* From mod_rewrite.c */
#ifndef REWRITE_MAX_TXT_MAP_LINE
#define REWRITE_MAX_TXT_MAP_LINE 1024
#endif
#define NL APR_EOL_STR
#define AVAIL "available"
#define UNAVAIL "unavailable"
static void usage(void)
{
const char *have_sdbm;
const char *have_gdbm;
const char *have_ndbm;
const char *have_db;
#if APU_HAVE_SDBM
#else
#endif
#if APU_HAVE_GDBM
#else
#endif
#if APU_HAVE_NDBM
#else
#endif
#if APU_HAVE_DB
#else
#endif
"%s -- Program to Create DBM Files for use by RewriteMap" NL
"Usage: %s [-v] [-f format] -i SOURCE_TXT -o OUTPUT_DBM" NL
"Options: " NL
" -v More verbose output"NL
" -i Source Text File. If '-', use stdin."NL
" -o Output DBM."NL
" -f DBM Format. If not specified, will use the APR Default." NL
" GDBM for GDBM files (%s)" NL
" SDBM for SDBM files (%s)" NL
" DB for berkeley DB files (%s)" NL
" NDBM for NDBM files (%s)" NL
" default for the default DBM type" NL
NL,
}
{
apr_pool_t* p;
apr_pool_create(&p, pool);
char *c, *value;
continue;
}
c = line;
while (*c && !apr_isspace(*c)) {
++c;
}
if (!*c) {
/* no value. solid line of data. */
continue;
}
while (*c && apr_isspace(*c)) {
++c;
}
if (!*c) {
apr_pool_clear(p);
continue;
}
value = c;
while (*c && !apr_isspace(*c)) {
++c;
}
if (verbose) {
}
apr_pool_clear(p);
if (rv != APR_SUCCESS) {
break;
}
}
return rv;
}
{
const char *opt_arg;
char ch;
verbose = 0;
if (argc) {
}
else {
shortname = "httxt2dbm";
}
if (rv != APR_SUCCESS) {
return 1;
}
if (argc <= 1) {
usage();
return 1;
}
switch (ch) {
case 'v':
if (verbose) {
usage();
return 1;
}
verbose = 1;
break;
case 'f':
if (format) {
usage();
return 1;
}
break;
case 'i':
if (input) {
usage();
return 1;
}
break;
case 'o':
if (output) {
usage();
return 1;
}
break;
}
}
usage();
return 1;
}
if (!input) {
usage();
return 1;
}
if (!output) {
usage();
return 1;
}
if (!format) {
format = "default";
}
if (verbose) {
}
}
else {
}
if (rv != APR_SUCCESS) {
return 1;
}
if (verbose) {
}
if (APR_STATUS_IS_ENOTIMPL(rv)) {
format);
return 1;
}
if (rv != APR_SUCCESS) {
return 1;
}
if (verbose) {
}
if (rv != APR_SUCCESS) {
return 1;
}
if (verbose) {
}
return 0;
}