提交 6d96fab9 编写于 作者: E Eric Blake

virsh: kill some double underscores

C99 says that __foo naming is reserved for the compiler.  Besides,
we had several different styles in use; this consolidates things
to set up the typedefs up front then declare the types with
consistent naming.

* tools/virsh.h: Use consistent struct naming.
* tools/virsh.c (_vshCommandParser): Likewise.
上级 f4a7b87d
...@@ -1581,15 +1581,16 @@ typedef enum { ...@@ -1581,15 +1581,16 @@ typedef enum {
VSH_TK_END /* No more commands */ VSH_TK_END /* No more commands */
} vshCommandToken; } vshCommandToken;
typedef struct __vshCommandParser { typedef struct _vshCommandParser vshCommandParser;
vshCommandToken(*getNextArg)(vshControl *, struct __vshCommandParser *, struct _vshCommandParser {
char **); vshCommandToken(*getNextArg)(vshControl *, vshCommandParser *,
char **);
/* vshCommandStringGetArg() */ /* vshCommandStringGetArg() */
char *pos; char *pos;
/* vshCommandArgvGetArg() */ /* vshCommandArgvGetArg() */
char **arg_pos; char **arg_pos;
char **arg_end; char **arg_end;
} vshCommandParser; };
static bool static bool
vshCommandParse(vshControl *ctl, vshCommandParser *parser) vshCommandParse(vshControl *ctl, vshCommandParser *parser)
......
...@@ -140,9 +140,15 @@ enum { ...@@ -140,9 +140,15 @@ enum {
VSH_OFLAG_REQ_OPT = (1 << 2), /* --optionname required */ VSH_OFLAG_REQ_OPT = (1 << 2), /* --optionname required */
}; };
/* dummy */ /* forward declarations */
typedef struct __vshControl vshControl; typedef struct _vshCmd vshCmd;
typedef struct __vshCmd vshCmd; typedef struct _vshCmdDef vshCmdDef;
typedef struct _vshCmdGrp vshCmdGrp;
typedef struct _vshCmdInfo vshCmdInfo;
typedef struct _vshCmdOpt vshCmdOpt;
typedef struct _vshCmdOptDef vshCmdOptDef;
typedef struct _vshControl vshControl;
typedef struct _vshCtrlData vshCtrlData;
/* /*
* vshCmdInfo -- name/value pair for information about command * vshCmdInfo -- name/value pair for information about command
...@@ -151,21 +157,21 @@ typedef struct __vshCmd vshCmd; ...@@ -151,21 +157,21 @@ typedef struct __vshCmd vshCmd;
* "name" - command name * "name" - command name
* "desc" - description of command, or empty string * "desc" - description of command, or empty string
*/ */
typedef struct { struct _vshCmdInfo {
const char *name; /* name of information, or NULL for list end */ const char *name; /* name of information, or NULL for list end */
const char *data; /* non-NULL information */ const char *data; /* non-NULL information */
} vshCmdInfo; };
/* /*
* vshCmdOptDef - command option definition * vshCmdOptDef - command option definition
*/ */
typedef struct { struct _vshCmdOptDef {
const char *name; /* the name of option, or NULL for list end */ const char *name; /* the name of option, or NULL for list end */
vshCmdOptType type; /* option type */ vshCmdOptType type; /* option type */
unsigned int flags; /* flags */ unsigned int flags; /* flags */
const char *help; /* non-NULL help string; or for VSH_OT_ALIAS const char *help; /* non-NULL help string; or for VSH_OT_ALIAS
* the name of a later public option */ * the name of a later public option */
} vshCmdOptDef; };
/* /*
* vshCmdOpt - command options * vshCmdOpt - command options
...@@ -173,11 +179,11 @@ typedef struct { ...@@ -173,11 +179,11 @@ typedef struct {
* After parsing a command, all arguments to the command have been * After parsing a command, all arguments to the command have been
* collected into a list of these objects. * collected into a list of these objects.
*/ */
typedef struct vshCmdOpt { struct _vshCmdOpt {
const vshCmdOptDef *def; /* non-NULL pointer to option definition */ const vshCmdOptDef *def; /* non-NULL pointer to option definition */
char *data; /* allocated data, or NULL for bool option */ char *data; /* allocated data, or NULL for bool option */
struct vshCmdOpt *next; vshCmdOpt *next;
} vshCmdOpt; };
/* /*
* Command Usage Flags * Command Usage Flags
...@@ -190,27 +196,27 @@ enum { ...@@ -190,27 +196,27 @@ enum {
/* /*
* vshCmdDef - command definition * vshCmdDef - command definition
*/ */
typedef struct { struct _vshCmdDef {
const char *name; /* name of command, or NULL for list end */ const char *name; /* name of command, or NULL for list end */
bool (*handler) (vshControl *, const vshCmd *); /* command handler */ bool (*handler) (vshControl *, const vshCmd *); /* command handler */
const vshCmdOptDef *opts; /* definition of command options */ const vshCmdOptDef *opts; /* definition of command options */
const vshCmdInfo *info; /* details about command */ const vshCmdInfo *info; /* details about command */
unsigned int flags; /* bitwise OR of VSH_CMD_FLAG */ unsigned int flags; /* bitwise OR of VSH_CMD_FLAG */
} vshCmdDef; };
/* /*
* vshCmd - parsed command * vshCmd - parsed command
*/ */
typedef struct __vshCmd { struct _vshCmd {
const vshCmdDef *def; /* command definition */ const vshCmdDef *def; /* command definition */
vshCmdOpt *opts; /* list of command arguments */ vshCmdOpt *opts; /* list of command arguments */
struct __vshCmd *next; /* next command */ vshCmd *next; /* next command */
} __vshCmd; };
/* /*
* vshControl * vshControl
*/ */
typedef struct __vshControl { struct _vshControl {
char *name; /* connection name */ char *name; /* connection name */
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */ virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
vshCmd *cmd; /* the current command */ vshCmd *cmd; /* the current command */
...@@ -237,13 +243,13 @@ typedef struct __vshControl { ...@@ -237,13 +243,13 @@ typedef struct __vshControl {
const char *escapeChar; /* String representation of const char *escapeChar; /* String representation of
console escape character */ console escape character */
} __vshControl; };
typedef struct vshCmdGrp { struct _vshCmdGrp {
const char *name; /* name of group, or NULL for list end */ const char *name; /* name of group, or NULL for list end */
const char *keyword; /* help keyword */ const char *keyword; /* help keyword */
const vshCmdDef *commands; const vshCmdDef *commands;
} vshCmdGrp; };
void vshError(vshControl *ctl, const char *format, ...) void vshError(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); ATTRIBUTE_FMT_PRINTF(2, 3);
...@@ -338,11 +344,11 @@ double prettyCapacity(unsigned long long val, const char **unit); ...@@ -338,11 +344,11 @@ double prettyCapacity(unsigned long long val, const char **unit);
* There are used by some long lingering commands like * There are used by some long lingering commands like
* migrate, dump, save, managedsave. * migrate, dump, save, managedsave.
*/ */
typedef struct __vshCtrlData { struct _vshCtrlData {
vshControl *ctl; vshControl *ctl;
const vshCmd *cmd; const vshCmd *cmd;
int writefd; int writefd;
} vshCtrlData; };
typedef void (*jobWatchTimeoutFunc) (vshControl *ctl, virDomainPtr dom, typedef void (*jobWatchTimeoutFunc) (vshControl *ctl, virDomainPtr dom,
void *opaque); void *opaque);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册