htdbm.c revision d6fc66efa723db8b3ee5e9fd32579bed884e4e58
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/* Licensed to the Apache Software Foundation (ASF) under one or more
* htdbm.c: simple program for manipulating DBM
* Contributed by Mladen Turk <mturk mappingsoft.com>
#include "passwd_common.h"
#include "apr_file_io.h"
#include "apr_file_info.h"
#include "apr_pools.h"
#include "apr_signal.h"
#include "apr_md5.h"
#include "apr_sha1.h"
#include "apr_dbm.h"
#include "apr_getopt.h"
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include "apr_xlate.h"
#include <unistd.h>
#if APR_HAVE_CRYPT_H
#include <crypt.h>
struct htdbm_t {
char *filename;
char *username;
char *comment;
char *type;
int create;
int rdonly;
#define HTDBM_MAKE 0
static void terminate(void)
#ifdef NETWARE
pressanykey();
static htdbm_t *h;
static void htdbm_interrupted(void)
htdbm_terminate(h);
if (rv) {
return APR_EGENERAL;
if (rv) {
return APR_EGENERAL;
if (rv) {
return APR_EGENERAL;
return APR_SUCCESS;
return APR_SUCCESS;
return APR_ENOENT;
char *pwd;
return APR_ENOENT;
return APR_ENOENT;
if (cmnt)
char *cmnt;
return APR_ENOENT;
return APR_EGENERAL;
if (cmnt)
return APR_SUCCESS;
int ret;
if (ret != 0) {
return ret;
return APR_EINVAL;
return APR_EINVAL;
return APR_SUCCESS;
static void htdbm_usage(void)
int need_cmnt = 0;
int changed = 0;
char opt;
const char *opt_arg;
switch (opt) {
need_file = 0;
args_left--;
need_pwd = 0;
need_user = 0;
args_left--;
args_left++;
need_pwd = 0;
if (ret) {
need_pwd = 0;
args_left++;
htdbm_usage();
if (need_file) {
if (need_user) {
if (need_pwd) {
if (ret) {
if (need_cmnt)
switch (cmd) {
case HTDBM_VERIFY:
case HTDBM_DELETE:
case HTDBM_LIST:
htdbm_list(h);
if (ret)
if (!need_cmnt) {
h->comment);
htdbm_terminate(h);