#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include "cmd.h"
Go to the source code of this file.
Defines | |
#define | FALSE 0 |
#define | TRUE 1 |
#define | LINSIZ 10240 |
Functions | |
static char *** | str2array (char *s, char *sep) |
static int | SetParam (Cmd_T *cmd, char *s) |
static int | SetEnum (Cmd_T *cmd, char *s) |
static int | SetFlag (Cmd_T *cmd, char *s) |
static int | SetSubrange (Cmd_T *cmd, char *s) |
static int | SetStrArray (Cmd_T *cmd, char *s) |
static int | SetNumArray (Cmd_T *cmd, char *s) |
static int | SetGte (Cmd_T *cmd, char *s) |
static int | SetLte (Cmd_T *cmd, char *s) |
static int | CmdError (char *opt) |
static int | EnumError (Cmd_T *cmd, char *s) |
static int | SubrangeError (Cmd_T *cmd, int n) |
static int | GteError (Cmd_T *cmd, int n) |
static int | LteError (Cmd_T *cmd, int n) |
static int | PrintParam (Cmd_T *cmd, int TypeFlag, int ValFlag, FILE *fp) |
static int | PrintParams4 (int TypeFlag, int ValFlag, int MsgFlag, FILE *fp) |
static int | FreeParam (Cmd_T *cmd) |
static int | PrintEnum (Cmd_T *cmd, int TypeFlag, int ValFlag, FILE *fp) |
static int | PrintFlag (Cmd_T *cmd, int TypeFlag, int ValFlag, FILE *fp) |
static int | PrintStrArray (Cmd_T *cmd, int TypeFlag, int ValFlag, FILE *fp) |
static int | PrintIntArray (Cmd_T *cmd, int TypeFlag, int ValFlag, FILE *fp) |
static int | PrintDblArray (Cmd_T *cmd, int TypeFlag, int ValFlag, FILE *fp) |
static int | BuildCmdList (Cmd_T **cmdp, int *cmdSz, char *ParName, va_list args) |
static int | StoreCmdLine (char *s) |
int | DeclareParams (char *ParName,...) |
int | GetParams (int *n, char ***a, char *DefCmd) |
int | GetDotParams (char *ParName,...) |
int | GetStrParams (char **lines, int n, char *parName,...) |
int | PrintParams (int ValFlag, FILE *fp) |
int | FullPrintParams (int TypeFlag, int ValFlag, int MsgFlag, FILE *fp) |
int | SPrintParams (char ***a, char *pfx) |
int | EnumIdx (Enum_T *en, char *s) |
char * | EnumStr (Enum_T *en, int i) |
#define FALSE 0 |
Definition at line 43 of file cmd.c.
Referenced by CmdError(), and MosesTuning::SentenceLevelScorer::Init().
#define LINSIZ 10240 |
#define TRUE 1 |
Definition at line 44 of file cmd.c.
Referenced by CmdError(), and MosesTuning::SentenceLevelScorer::Init().
static int BuildCmdList | ( | Cmd_T ** | cmdp, | |
int * | cmdSz, | |||
char * | ParName, | |||
va_list | args | |||
) |
Definition at line 421 of file cmd.c.
References CMDBOOLTYPE, CMDDBLARRAYTYPE, CMDDOUBLETYPE, CMDENUMTYPE, CMDFLAGTYPE, CMDFLOATTYPE, CMDGTETYPE, CMDINTARRAYTYPE, CMDINTTYPE, CMDLTETYPE, CMDMSG, CMDSTRARRAYTYPE, CMDSTRINGTYPE, CMDSUBRANGETYPE, Cmd_T::Flag, Cmd_T::Msg, Cmd_T::Name, Cmd_T::p, Cmd_T::Type, and Cmd_T::Val.
Referenced by DeclareParams(), GetDotParams(), and GetStrParams().
static int CmdError | ( | char * | opt | ) |
Definition at line 513 of file cmd.c.
References FALSE, PrintParams4(), and TRUE.
Referenced by GetParams().
int DeclareParams | ( | char * | ParName, | |
... | ||||
) |
Definition at line 158 of file cmd.c.
References BuildCmdList().
Referenced by main(), and mixture::mixture().
static int EnumError | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 905 of file cmd.c.
References Enum_T::Name, Cmd_T::Name, and Cmd_T::p.
Referenced by SetEnum(), and SetFlag().
int EnumIdx | ( | Enum_T * | en, | |
char * | s | |||
) |
char* EnumStr | ( | Enum_T * | en, | |
int | i | |||
) |
static int FreeParam | ( | Cmd_T * | cmd | ) |
Definition at line 523 of file cmd.c.
References CMDDBLARRAYTYPE, CMDGTETYPE, CMDINTARRAYTYPE, CMDLTETYPE, CMDSTRARRAYTYPE, CMDSUBRANGETYPE, Cmd_T::p, and Cmd_T::Type.
Referenced by GetDotParams(), and GetStrParams().
int FullPrintParams | ( | int | TypeFlag, | |
int | ValFlag, | |||
int | MsgFlag, | |||
FILE * | fp | |||
) |
Definition at line 352 of file cmd.c.
References PrintParams4().
Referenced by print_help().
int GetDotParams | ( | char * | ParName, | |
... | ||||
) |
Definition at line 303 of file cmd.c.
References BuildCmdList(), FreeParam(), and Moses::Scan().
int GetParams | ( | int * | n, | |
char *** | a, | |||
char * | DefCmd | |||
) |
Definition at line 170 of file cmd.c.
References CmdError(), LINSIZ, NULL, pclose(), popen(), Moses::Scan(), and StoreCmdLine().
Referenced by main(), and mixture::mixture().
int GetStrParams | ( | char ** | lines, | |
int | n, | |||
char * | parName, | |||
... | ||||
) |
Definition at line 322 of file cmd.c.
References BuildCmdList(), FreeParam(), and Moses::Scan().
static int GteError | ( | Cmd_T * | cmd, | |
int | n | |||
) |
Definition at line 922 of file cmd.c.
References Cmd_T::Name, and Cmd_T::p.
Referenced by SetGte().
static int LteError | ( | Cmd_T * | cmd, | |
int | n | |||
) |
Definition at line 934 of file cmd.c.
References Cmd_T::Name, and Cmd_T::p.
Referenced by SetLte().
static int PrintDblArray | ( | Cmd_T * | cmd, | |
int | TypeFlag, | |||
int | ValFlag, | |||
FILE * | fp | |||
) |
Definition at line 1083 of file cmd.c.
References Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by PrintParam().
static int PrintEnum | ( | Cmd_T * | cmd, | |
int | TypeFlag, | |||
int | ValFlag, | |||
FILE * | fp | |||
) |
Definition at line 958 of file cmd.c.
References Enum_T::Idx, Enum_T::Name, Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by PrintParam().
static int PrintFlag | ( | Cmd_T * | cmd, | |
int | TypeFlag, | |||
int | ValFlag, | |||
FILE * | fp | |||
) |
Definition at line 989 of file cmd.c.
References Enum_T::Idx, Enum_T::Name, Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by PrintParam().
static int PrintIntArray | ( | Cmd_T * | cmd, | |
int | TypeFlag, | |||
int | ValFlag, | |||
FILE * | fp | |||
) |
Definition at line 1051 of file cmd.c.
References Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by PrintParam().
static int PrintParam | ( | Cmd_T * | cmd, | |
int | TypeFlag, | |||
int | ValFlag, | |||
FILE * | fp | |||
) |
Definition at line 543 of file cmd.c.
References CMDDBLARRAYTYPE, CMDDOUBLETYPE, CMDENUMTYPE, CMDFLAGTYPE, CMDFLOATTYPE, CMDGTETYPE, CMDINTARRAYTYPE, CMDINTTYPE, CMDLTETYPE, CMDSTRARRAYTYPE, CMDSTRINGTYPE, CMDSUBRANGETYPE, Cmd_T::Name, Cmd_T::p, PrintDblArray(), PrintEnum(), PrintFlag(), PrintIntArray(), PrintStrArray(), Cmd_T::Type, and Cmd_T::Val.
Referenced by PrintParams4().
int PrintParams | ( | int | ValFlag, | |
FILE * | fp | |||
) |
Definition at line 343 of file cmd.c.
References PrintParams4().
static int PrintParams4 | ( | int | TypeFlag, | |
int | ValFlag, | |||
int | MsgFlag, | |||
FILE * | fp | |||
) |
Definition at line 369 of file cmd.c.
References Cmd_T::Msg, Cmd_T::Name, and PrintParam().
Referenced by CmdError(), FullPrintParams(), and PrintParams().
static int PrintStrArray | ( | Cmd_T * | cmd, | |
int | TypeFlag, | |||
int | ValFlag, | |||
FILE * | fp | |||
) |
Definition at line 1022 of file cmd.c.
References Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by PrintParam().
static int SetEnum | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 781 of file cmd.c.
References EnumError(), Enum_T::Idx, Enum_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by SetParam().
static int SetFlag | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 814 of file cmd.c.
References EnumError(), Enum_T::Idx, Enum_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by SetParam().
static int SetGte | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 850 of file cmd.c.
References GteError(), Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by SetParam().
static int SetLte | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 886 of file cmd.c.
References LteError(), Cmd_T::Name, Cmd_T::p, and Cmd_T::Val.
Referenced by SetParam().
static int SetNumArray | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 877 of file cmd.c.
References Cmd_T::p, Cmd_T::Type, and Cmd_T::Val.
Referenced by SetParam().
static int SetParam | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 691 of file cmd.c.
References Cmd_T::ArgStr, CMDDBLARRAYTYPE, CMDDOUBLETYPE, CMDENUMTYPE, CMDFLAGTYPE, CMDFLOATTYPE, CMDGTETYPE, CMDINTARRAYTYPE, CMDINTTYPE, CMDLTETYPE, CMDSTRARRAYTYPE, CMDSTRINGTYPE, CMDSUBRANGETYPE, Cmd_T::Flag, Cmd_T::Name, SetEnum(), SetFlag(), SetGte(), SetLte(), SetNumArray(), SetStrArray(), SetSubrange(), Cmd_T::Type, and Cmd_T::Val.
static int SetStrArray | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 869 of file cmd.c.
References Cmd_T::p, str2array(), and Cmd_T::Val.
Referenced by SetParam().
static int SetSubrange | ( | Cmd_T * | cmd, | |
char * | s | |||
) |
Definition at line 831 of file cmd.c.
References Cmd_T::Name, Cmd_T::p, SubrangeError(), and Cmd_T::Val.
Referenced by SetParam().
int SPrintParams | ( | char *** | a, | |
char * | pfx | |||
) |
static int StoreCmdLine | ( | char * | s | ) |
Definition at line 1187 of file cmd.c.
Referenced by GetParams().
static char ** str2array | ( | char * | s, | |
char * | sep | |||
) |
Definition at line 1115 of file cmd.c.
Referenced by SetStrArray().
static int SubrangeError | ( | Cmd_T * | cmd, | |
int | n | |||
) |
Definition at line 946 of file cmd.c.
References Cmd_T::Name, and Cmd_T::p.
Referenced by SetSubrange().