1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 18:55:19 +03:00
lvm2/tools/tools.h

130 lines
2.8 KiB
C
Raw Normal View History

2001-09-25 16:49:28 +04:00
/*
* Copyright (C) 2001 Sistina Software
*
* LVM is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* LVM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
2001-10-09 21:20:02 +04:00
#ifndef _LVM_LVM_H
#define _LVM_LVM_H
2001-09-25 16:49:28 +04:00
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
2001-10-08 22:44:22 +04:00
#include "pool.h"
#include "dbg_malloc.h"
#include "list.h"
#include "log.h"
2001-10-01 19:14:39 +04:00
#include "metadata.h"
#include "config.h"
#include "dev-cache.h"
#include "device.h"
#include "display.h"
2001-09-25 16:49:28 +04:00
#include "errors.h"
2001-10-01 23:36:06 +04:00
#include "filter.h"
#include "filter-persistent.h"
2001-10-23 15:50:49 +04:00
#include "filter-composite.h"
#include "filter-regex.h"
2001-10-08 22:44:22 +04:00
#include "format1.h"
2001-09-25 16:49:28 +04:00
#include "toollib.h"
2001-10-16 20:25:28 +04:00
#include "activate.h"
2001-09-25 16:49:28 +04:00
#define CMD_LEN 256
#define MAX_ARGS 64
/* command functions */
typedef int (*command_fn)(int argc, char **argv);
#define xx(a, b...) int a(int argc, char **argv);
#include "commands.h"
#undef xx
/* define the enums for the command line switches */
enum {
#define xx(a, b, c, d) a ,
#include "args.h"
#undef xx
};
typedef enum {
SIGN_NONE = 0,
SIGN_PLUS = 1,
SIGN_MINUS = 2
} sign_t;
2001-09-25 16:49:28 +04:00
/* a global table of possible arguments */
struct arg {
char short_arg;
char *long_arg;
int (*fn)(struct arg *a);
int count;
char *value;
uint32_t i_value;
sign_t sign;
2001-09-25 16:49:28 +04:00
};
extern struct arg the_args[ARG_COUNT + 1];
void usage(const char *name);
/* the argument verify/normalise functions */
int yes_no_arg(struct arg *a);
int size_arg(struct arg *a);
int int_arg(struct arg *a);
int int_arg_with_sign(struct arg *a);
2001-09-25 16:49:28 +04:00
int string_arg(struct arg *a);
int permission_arg(struct arg *a);
char yes_no_prompt(const char *prompt, ...);
2001-09-25 16:49:28 +04:00
/* we use the enums to access the switches */
static inline int arg_count(int a) {
return the_args[a].count;
}
static inline char *arg_value(int a) {
return the_args[a].value;
}
static inline char *arg_str_value(int a, char *def)
{
return arg_count(a) ? the_args[a].value : def;
}
static inline uint32_t arg_int_value(int a, uint32_t def)
2001-09-25 16:49:28 +04:00
{
return arg_count(a) ? the_args[a].i_value : def;
}
static inline sign_t arg_sign_value(int a, sign_t def)
{
return arg_count(a) ? the_args[a].sign : def;
}
2001-09-25 16:49:28 +04:00
static inline int arg_count_increment(int a)
{
return the_args[a].count++;
}
2001-10-02 21:09:05 +04:00
struct config_file *active_config_file(void);
2001-10-08 22:44:22 +04:00
2001-11-12 18:10:01 +03:00
extern struct format_instance *fid;
2001-10-08 22:44:22 +04:00
2001-10-06 01:39:30 +04:00
#endif