⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hshell.h

📁 实现HMM算法
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ----------------- Command Line Argument Handling ------------------ */typedef enum {SWITCHARG, STRINGARG, INTARG, FLOATARG, NOARG} ArgKind;int  NumArgs(void);/*   Returns number of command line args which have not yet been processed.   Initially this is equal to argc-1 since actual command name is ignored*/ArgKind NextArg(void);/*   Returns the kind of the next command line argument.  If NumArgs()==0 then   NOARG will be returned. */char * GetStrArg(void);char * GetSwtArg(void);int    GetIntArg(void);long   GetLongArg(void);float  GetFltArg(void);/*   Return value of next arg and 'consume' that arg.  An error is raised if   the kind of the next arg is different to that requested except that    GetFltArg will accept either an integer or a float argument*/int   GetChkedInt(int min, int max, char * swtname);long   GetChkedLong(long min, long max, char * swtname);float GetChkedFlt(float min, float max, char * swtname);/*    Range checked versions of GetIntArg and GetFltArg.  Swtname   is the name of the preceding switch and is only used in   error message.*/Boolean GetIntEnvVar(char *envVar, int *value);/*   Get the integer value of env variable envVar.   Returns false if envVar not set*/Boolean GetFileNameExt(char *logfn, char *actfn, long *st, long *en);/*    Return true if given file has extensions, i.e. an alias and/or st/end   indices.  If true actual file name is copied into actfn and indices   are copied into st and en.   Extended file names have the form             file[1,999]   or        logfile=actfile   or        logfile=actfile[1,999]        File extensions can be disabled by seting EXTENDFILENAMES to F*/       /* ---------------------- Input Handling ----------------------------- */FILE *FOpen(char *fname, IOFilter filter, Boolean *isPipe);/*   Open the file fname for reading or writing (depending on   whether IOFilter is a Filter or OFilter) and return a file pointer.     If the environment variable HxxxxFILTER is set to a    command of the form "foo $ a b ..." then the given fname   replaces the $ and popen is used to connect to the output   of foo. The Boolean isPipe returns true if input is a pipe.   In addition, if the environment variable HMAXTRY is set to   an integer n, then an fopen call which fails will be retried   n-1 more times before failing completely.  This is useful    in combatting occassional NFS errors.*/void FClose(FILE *f, Boolean isPipe);/*   Close the given file or pipe*/ReturnStatus InitSource(char *fname, Source *src, IOFilter filter);/*   Initialise a text source using file fname and filter - returns*/void CloseSource(Source *src);/*   Close source*/void AttachSource(FILE *file, Source *src);/*   Attach a source to already open file*/char *SrcPosition(Source src, char *s);/*    return string describing the current position in src*/int  GetCh(Source *src);void UnGetCh(int c, Source *src);/*   Get/Unget a character from the given source */Boolean ReadString(Source *src, char *s);Boolean ReadStringWithLen(Source *src, char *s, int buflen); /* With specified length of buffer*/char *ParseString(char *src, char *s);/*   Read a string from the given source where a string is any   sequence of non-white space characters, or any sequence of   characters enclosed by single or double quotes.   Also supports use of escape character to allow quotes to appear   within the string and also to allow three digit octal specification   of any character.     Return TRUE (for ReadString) or pointer to next unread character   (for ParseString) if no error.   '"QUOTE' "\"QUOTE" \"QUOTE \042QUOTE all return "QUOTE in s*/Boolean ReadRawString(Source *src, char *s);/*    Read a raw string (i.e. word upto next white-space) from src and store it in s */void WriteString(FILE *f,char *s,char q);char *ReWriteString(char *s,char *dst, char q);/*   Write string s in ReadString format (with quotes and escapes as   needed).  Either writes direct to file (WriteString), to supplied   buffer (dst!=NULL) or to static buffer (dst==NULL).   q can either be SING_QUOTE, DBL_QUOTE to force quoting of string   or 0 to quote strings that contain quotes, or ESCAPE_CHAR to never   quote the string. */Boolean SkipLine(Source *src);/*    skip to next line in source, return FALSE when EOF reached*/Boolean ReadLine(Source *src,char *s);/*    read to next newline in source, return FALSE when EOF reached*/void ReadUntilLine (Source *src, char *s);/*    read to next occurrence of string */void SkipWhiteSpace(Source *src);/*    skip white space (if any)   if any space is skipped sets wasNewline to indicate if the space   contained a newline character*/void SkipComment(Source *src);/*    skip to next non-blank, if it is a # then skip to next line*/Boolean ReadShort(Source *src, short *s, int n, Boolean binary);Boolean ReadInt  (Source *src, int *i,   int n, Boolean binary);Boolean ReadFloat(Source *src, float *x, int n, Boolean binary);/*   Read n short/int/float(s) from the given source, return    TRUE if no error.  If binary then binary read is performed -    byte swapping is controlled by HShell config variables.*/Boolean RawReadShort(Source *src, short *s, int n, Boolean bin, Boolean swap);Boolean RawReadInt(Source *src, int *i, int n, Boolean bin, Boolean swap);Boolean RawReadFloat(Source *src, float *x, int n, Boolean bin, Boolean swap);/*   Read n short/int/float(s) from the given source, return    TRUE if no error.     If binary then binary read is performed.   If swap then values are byte swapped after reading.*/void SwapShort(short *p);void SwapInt32(int32 *p);/*    Byte swap various types*/Boolean KeyPressed(int tWait);/*   Returns TRUE if input is pending on stdin within tWait seconds*/   /* -------------------------- Output Handling ------------------------ */void WriteShort(FILE *f, short *s, int n, Boolean binary);void WriteInt  (FILE *f, int *i,   int n, Boolean binary);void WriteFloat(FILE *f, float *x, int n, Boolean binary);/*   Write n short/int/float(s) to the given file.     If binary then binary Write is performed.*//* ---------------------- File Name Manipulation --------------------- */#if defined MPW#define PATHCHAR ':'#endif#if defined UNIX#define PATHCHAR '/'#endif#if defined WIN32#define PATHCHAR '/'#define ALTPATHCHAR '\\'#endif#if defined VMS#define PATHCHAR ']'#endifchar * NameOf(char *fn, char *s);char * BaseOf(char *fn, char *s);char * PathOf(char *fn, char *s);char * ExtnOf(char *fn, char *s);/*   Given a filename of the general form "path/n.x" in fn, the above   functions return "n.x", "n", "x" and "path/", respectively. In each case,   the string is returned in s which must be large enough and s is returned   as the function result.*/char * MakeFN(char *fn, char *path, char *ext, char *s);/*   The supplied file name fn is used as a template for constructing a    new file name returned in s as function result.  The construction   rules are as follows:      a) if path is not NULL then any path is stripped from fn and         replaced by the given path      b) if ext is not NULL then any extension is stripped from fn          and replaced by the given extension*/char * CounterFN(char *prefix, char* suffix, int count, int width, char *s);/*   creates a file name in s of form "PREFNNNSUF" where NNNN is count    expressed in width digits with leading zeroes if needed.*/void SubstFName(char *fname, char *s);/*    Subst fname for any occurrences of $ in s which must be large   enough to accommodate the expanded string*//* ------------------------ Pattern Matching ------------------------- */Boolean DoMatch(char *s, char *p);/*    Returns true if the string s matches the pattern p.   The pattern p may contain the metacharacters '?'   which will match exactly 1 character and '*'   which will match zero or more characters.*/Boolean MaskMatch(char *mask, char *spkr, char *str);/* Returns true if the string str matches the pattern.   The string matched to the '%' is returned in spkr.*/char *RetrieveCommandLine(void);/*   Retrieves the savedCommandLine, that contains the   actual command line used to run the program at hand.*/#ifdef __cplusplus}#endif#endif  /* _HSHELL_H_ *//* ----------------------- End of HShell.h --------------------------- */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -