Helmut Leitner / String Funktionen
 
StartSeite | HelmutLeitner/ | Neues | TestSeite | ForumSeite | Teilnehmer | Kategorien | Index | Hilfe | Einstellungen | Ändern

Von IstAssertSinnvoll. Ergänzendes Material zur Diskussion.

/*
** gf_str.h GFL Advanced String Functions
** (C) Helmut Leitner Software 1990-1996
*/

/* BIT =================================================================*/

IN BitRetVal(CH *set,OS ind);

#define BitClear BitSetOff
VO BitSetOff(CH *set,OS ind);
VO BitSetOn(CH *set,OS ind);
VO BitSetVal(CH *set,OS ind,IN val);

VO BitChange(CH *set,OS ind);

VO BitmapSetStr(CH *set,CH *s);
OS BitmapRetCount(CH *set,OS bytes);
#define BitmapClear MemClear
#define BitmapNot   MemNot
#define BitmapAnd   MemAnd
#define BitmapXor   MemXor
#define BitmapOr    MemOr

#define BitFlagSet IntSetBitMaskVal
VO IntSetBitMaskVal(IN *pi,IN bitmask,IN val);

IN BitRetVal_Rev(CH *set,OS ind);
VO BitSetVal_Rev(CH *set,OS ind,CH val);


/* CHR =================================================================*/

#define CHRSETLEN 64
extern CH InStrBitmap[];
extern CH InValBitmap[];

extern CH ChrDecimalPoint;
extern CH ChrCommercialSep;
extern CH ChrUpperTabOem[256];
extern CH ChrLowerTabOem[256];
extern CH ChrKeyTabOem[256];
extern CH ChrUpperTabAnsi[256];
extern CH ChrLowerTabAnsi[256];
extern CH ChrKeyTabAnsi[256];
extern CH *ChrUpperTab; /* [256] */
extern CH *ChrLowerTab; /* [256] */
extern CH *ChrKeyTab;   /* [256] */

extern CH ChrAltTab[35];

IN ChrRetUpper(IN c);
IN ChrRetLower(IN c);

#define ChrEquUpper(s1,s2) (ChrCmpUpper((s1),(s2))==0)
IN ChrCmpUpper(CH c1,CH c2);

#define StrEquUpper(s1,s2) (StrCmpUpper((s1),(s2))==0)
IN StrCmpUpper(CH *s1,CH *s2);

IN ChrRetChrKey(IN c);
IN KeyAltRetChr(IN c);
ER ChrGetHex(CH c,IN *pi);

/* CHR2 ================================================================*/

extern CH ChrOemAnsiTab[256];
extern CH ChrAnsiOemTab[256];

IN ChrOemRetAnsi(IN c);
IN ChrAnsiRetOem(IN c);
VO StrOemCvtAnsi(CH *s);
VO StrAnsiCvtOem(CH *s);


/* STR =================================================================*/

#define lenof(s) (sizeof(s)-1)   /* use for CH buf[10];   StrCpyLen(buf,string,lenof(buf)); */

#define StrClear(s) *(s)='\0'
VO StrClearSave(CH *s);

#define StrSize StrRetSize
#define StrRetSize(s) (strlen(s)+1)

#define StrRetLen strlen
#define StrLen strlen

#define StrCpy strcpy
#define StrCat strcat

#define StrFindStr strstr
CH *StrFindStrUpper(CH *s,CH *ss);

#define StrFindChr strchr

#define StrFindAnyChr strpbrk
#define StrFindChrAny strpbrk
#define StrFindChrFromStr strpbrk

#define StrCmp strcmp
#define StrEqu(s,p) (!strcmp((s),(p)))
#define StrCmpLen strncmp
#define StrEquLen(s,p,len) (!strncmp(s,p,len))
#define StrCpyFmt sprintf

#define StrDelLen StrDel

extern CH StrBuf[256];

VO StrCvtChrTab(CH *s,CH *ctab);
VO StrCvtCodeset(CH *s,IN cs1,IN cs2);

VO StrCvtUpper(CH *s);
VO StrCvtLower(CH *s);
VO StrCvtKeyCodeset(CH *s,IN codeset);
IN StrCmpPlus(CH *s,CH *p);
VO StrSetChrLen(CH *s,CH c,OS len);
VO StrCpyLen(CH *d,CH *s,OS len);
ER StrCpyPosLen(CH *d,CH *s,OS pos,OS len);
VO StrCpyLenTerm(CH *d,CH *s,OS len,CH *term);
VO StrCpyLenTermChr(CH *d,CH *s,OS len,CH cterm);
VO StrCpyTermChr(CH *d,CH *s,CH cterm);
IN StrRange(CH *s1,CH *s,CH *s2);
VO StrFill(CH *s,OS len);
VO StrFillChr(CH *s,OS len,CH c);
VO StrStrip(CH *s);
VO StrStripChr(CH *s,CH c);
VO StrStripFront(CH *s);
VO StrStripChrFront(CH *s,CH c);
VO StrStripBoth(CH *s);
ER StrStripBrackets(CH *s,CH c1,CH c2);
CH *StrMoveToLastChr(CH *s);
IN StrEmpty(CH *s);
VO StrInsChr(CH *s,CH c);

#define StrDelChrAll StrDelChr
VO StrDelChr(CH *s,CH c);
VO StrDel(CH *s,OS n);
VO StrInsStr(CH *s,CH *i);
VO StrInsChrLen(CH *s,CH c,CH clen);

#if defined(WATCOM_C)
VO StrCpyFmtPtr(CH *buf,CH **pfmt,...);
#else
VO StrCpyFmtPtr(CH *buf,CH **pfmt);
#endif

#define StrCreate StrSave
#define StrCreateStr StrSave
#define PtrCreateStr StrSave
CH *StrSave(CH *s);
#define StrFree PtrFree

IN StrEmptyLen(CH *p,OS len);
OS StrChrPosEnd(CH *p,CH c,OS len);
ER StrFindChrPos(CH *s,CH c,OS *ppos);

#define StrFindChrLast StrFindLastChr
CH *StrFindLastChr(CH *s,CH c);
CH StrRetChrLast(CH *s);

OS StrLenChr(CH *s,CH c);

#define StrCountChr StrFindChrCount
#define StrGetChrCount StrFindChrCount
#define StrRetChrCount StrFindChrCount
OS StrFindChrCount(CH *p,CH c);

#define StrCountStr StrFindStrCount
#define StrGetStrCount StrFindStrCount
OS StrFindStrCount(CH *s,CH *ss);

VO SaveSetStr(CH **save,CH *s);
VO SaveSetFmt(CH **save,CH *fmt,...);

DO StrRetValPlus(CH *s,IN opt);
ER StrSetValPlus(CH *s,DO y,IN w,IN d,IN opt);

/* MEM */

#define MemCpy memmove
#define MemCpyFast memcpy
#define MemSetChr(p,size,c) memset((p),(c),(size))
#define MemClear(p,size) memset((p),'\0',(size))
#define MemCmp memcmp
#define MemEqu(s,p,size) (memcmp((s),(p),(size))==0)
#define StrEquMem(s,p,size) (StrCmpMem((s),(p),(size))==0)

IN MemEmpty(CH *p,OS len);
OS MemCountChr(CH *p,OS len,CH c);

#define PtrCreateMem MemSave
CH *MemSave(CH *s,OS len);
CH *MemSaveStr(CH *s,OS len);

VO StrCpyMem(CH *s,CH *p,OS len);
IN StrCmpMem(CH *s,CH *p,OS len);
CH *MemFindMem(CH *p,OS len,CH *ss,OS sslen);
CH *MemFindMemUpper(CH *p,OS len,CH *ss,OS sslen);
CH *MemFindStr(CH *p,OS len,CH *ss);
CH *MemFindStrUpper(CH *p,OS len,CH *ss);
VO MemFill(CH *p,OS len,CH c);
OS MemChrPosEnd(CH *p,CH c,OS len);

#define CRYPT_OFF 0  /* dir, falls erforderlich */
#define CRYPT_ON  1
VO MemCrypt(CH *p,OS size);
VO MemCrypt_txt(CH *p,OS size,IN dir);

VO MemRev(CH *p,OS len);
VO MemRollLeft(CH *p,OS len,OS shift);
VO MemAnd(CH *dset,CH *set,OS bytes);
VO MemOr(CH *dset,CH *set,OS bytes);
VO MemXor(CH *dset,CH *set,OS bytes);
VO MemNot(CH *set,OS bytes);
VO MemSwap(CH *p1,CH *p2,OS size);
VO PtrSwap(CH **p1,CH **p2);

/* MEMH */

VO MemCpyHuge(CH HUGE *d,CH HUGE *s,OS size);
VO MemNotHuge(CH HUGE *set,OS bytes);
VO BitHugeSetVal_Rev(CH HUGE *set,OS el,CH val);
IN BitHugeRetVal_Rev(CH HUGE *set,OS el);

/* STR2 =============================================================== */

#define StrFindStrGetPos StrFindStrPos
ER StrFindStrPos(CH *s,CH *ss,OS *ppos);
CH *StrFindWord(CH *p,CH *word);
ER StrFindWordPos(CH *pstart,CH *word,OS *ppos);
CH *StrFindHeadGetTail(CH *s,CH *head,CH tail[]);
IN StrFindStrFlag(CH *s,CH *ss);

CH *StrFindSepGetFrontEnd(CH *s,CH *sep,CH head[],CH tail[]);
CH *StrFindVarGetVal(CH *s,CH *var,CH val[]);

#define StrFindVarIndGetVal StrFindVarIndexGetVal
CH *StrFindVarIndexGetVal(CH *s,CH *var,IN j,CH val[]);
CH *StrFindVarGetInt(CH *s,CH *var,IN *pi);
CH *StrFindVarGetLong(CH *s,CH *var,LO *pl);
CH *StrFindVarGetDouble(CH *s,CH *var,DO *pd);
CH *StrFindVarGetIntDefault(CH *s,CH *var,IN *pi,IN def);
CH *StrFindVarGetLongDefault(CH *s,CH *var,LO *pl,LO def);

VO StrFindChrCut(CH *s,CH c);
VO StrGetVis(CH *line,CH *cmd);

VO StrStripLineTerm(CH *line);

VO StrStripIndex(CH *nam);
VO StrRepChr(CH *s,CH c1,CH c2);
ER StrFindChrCall(CH *p,CH c,ER (*f)(CH *));
ER StrFindStrCall(CH *p,CH *ss,ER (*f)(CH *));
ER StrChrIndGetStr(CH *s,CH c,IN ind,CH *d);

extern OS TextDimLinMax;
extern OS TextDimColMax;
VO TextGetExtent(CH *titel,CH *p,OS maxlin,OS maxcol,OS *pnlin,OS *pncol);

#define StrSepIndGetPart StrGetPart
#define StrChrIndGetPart StrGetChrPart
ER StrGetPart(CH *s,CH *ss,IN part,CH *d);
ER StrGetPartInt(CH *s,CH *ss,IN ind,IN *pval);
ER StrGetPartIntDefault(CH *s,CH *ss,IN ind,IN *pval,IN def);
ER StrGetChrPart(CH *s,CH c,IN part,CH *d);
ER StrGetMid(CH *s,OS pos,OS len,CH *part);

VO StrGetWinRet(CH *line,IN *pret);

#define SFB_TOTAL 0x0001   /* Liefert auch Kopf- und Fuázeilen */
ER StrFindBlockGetMemPlus(CH *s,CH *word,CH **pm,OS *plen,IN flags);

LO MemHexRetLong(CH *p,OS size);
LO StrHexRetLong(CH *s);

/* LINE =============================================================== */

VO StrCpyLine(CH *s,CH *line);
OS LineRetLen(CH *s);
OS LineRetSize(CH *s);
CH *LineFindStr(CH *s,CH *ss);
CH *LineFindChr(CH *p,CH c);

#define LineCvtStr StrStripLineTerm

/* SCAN =============================================================== */

OS ScanSpace(CH **ps);
OS ScanLong(CH **ps,LO *pl);
OS ScanInt(CH **ps,IN *pi);
OS ScanUI(CH **ps,UI *pi);
OS ScanOS(CH **ps,OS *pl);
OS ScanToChr(CH **ps,CH c1,CH c2);
OS ScanLine(CH **ps,CH *line);
OS ScanLineStrip(CH **ps,CH *line);

extern IN ScanStrPlus_StrFlag;
OS ScanStrPlus(CH **ps,CH **pd);
OS ScanStr(CH **ps,CH *d);


/* TOKEN ============================================================== */

/* Zeichen-Typ fr die Zerlegung von Text in Tokens */
#define SWI_DEFAULT 0
#define SWI_SPACE   1
#define SWI_SLASH   2
#define SWI_NULL    3
#define SWI_BLOCK   4
#define SWI_LOGIC   5
#define SWI_DELIM   6
#define SWI_NUMBER  7
#define SWI_IDENT   8
#define SWI_QUOTE   9
#define SWI_EOL    10
#define SWI_EOL2   11
#define SWI_OTHER  12

/* TokenLogic */
#define LOGIC_LT      1
#define LOGIC_LE      2
#define LOGIC_GT      3
#define LOGIC_GE      4
#define LOGIC_EQ      5
#define LOGIC_NE      6
#define LOGIC_OR      7
#define LOGIC_AND     8
#define LOGIC_BINOR   9
#define LOGIC_BINAND 10

/* TokenClass */
#define TOKEN_INVALID     -1
#define TOKEN_END          0
#define TOKEN_DELIMITER    1
#define TOKEN_IDENTIFIER   2
#define TOKEN_NUMBER       3
#define TOKEN_STRING       4
#define TOKEN_BLOCK        5
#define TOKEN_EOL          6
#define TOKEN_COMMENT      7
#define TOKEN_SPACE        8
#define TOKEN_OTHER        9
#define TOKEN_LINE        10   /* Nur bei TokenGetLine */

/* TokenMode */
#define TM_SEE_ALL  0xFFFF
#define TM_SEE_EOL       1
#define TM_SEE_COMMENT   2
#define TM_SEE_SPACE     4
#define TM_SEE_QUOTE     8
#define TM_SEE_LINEEOL  16

#define TOKEN_IS_ENDDELIM TokenEnd[TokenSwitchTable[*TokenReadPtr]]
#define TOKEN_IS_NUMBER (TokenSwitchTable[*TokenReadPtr]==SWI_NUMBER)
#define TOKEN_ADV  { TokenReadPtr++;  TokenLen++;  }
#define TOKEN_ADV2 { TokenReadPtr+=2; TokenLen+=2; }

extern CH *TokenReadPtr;
extern CH *Token;
extern IN TokenLen;
extern IN TokenClass; /* Frher TokenType */
extern IN TokenLogic;
extern IN TokenMode;
extern IN TokenMultiLines;  /* Frher TokenCommentLines */
extern CH TokenQuote;   /* aktuelles Begrenzungszeichen fr TOKEN_STRING */
extern CH TokenSwitchTable[256];
extern CH TokenEnd[16];

IN ScanToken(CH **pread,CH **ptoken,IN *ptype);
IN TokenGetLine(VO);

IN StrCmpToken(CH *s);
#define StrEquToken(s) (!StrCmpToken(s))
CH *TokenSave(VO);
VO StrCpyToken(CH *s);

VO BufferTokenInit(BUFFER *b,IN mode);
IN BufferAppToken(BUFFER *b);

/* STR3.C */
IN StrExist(CH *s);
VO StrFillFront(CH *s,IN n);

#define StrAppChr StrCatChr
VO StrCatChr(CH *s,CH c);

#define StrAppFmt StrCatFmt
VO StrCatFmt(CH *s,CH *fmt,...);
VO StrInsFmt(CH *s,CH *fmt,...);
#define StrAppSize StrCatSize
ER StrCatSize(CH *d,CH *s,OS size);
#define StrAppSizeFmt StrCatSizeFmt
ER StrCatSizeFmt(CH *s,OS size,CH *fmt,...);

#define StrEquLenUpper(s1,s2,len) (StrCmpLenUpper((s1),(s2),(len))==0)
IN StrCmpLenUpper(CH *s1,CH *s2,IN len);
CH *StrFindHeadTailGetVar(CH *s,CH *head,CH *tail,CH *var);
IN StrStripDigits(CH *s);
VO StrCpyChr(CH *buf,CH c);
VO StrInsChrSorted(CH *s,CH c);
VO StrRepStrAll(CH *s,CH *s1,CH *s2);

/* HTML */

extern CH HtmlKnowChr; /* ='@' */
CH *HtmlFindTagGetVal(CH *s,CH *tag,CH *val,IN maxsize);
CH *HtmlFindTagSimpleGetText(CH *s,CH *tag,CH *val,IN maxsize);
CH *HtmlFindPropGetValFull(CH *content,CH *prop,CH *val,IN maxsize);
CH *HtmlFindPropGetVal(CH *content,CH *prop,CH *val,IN maxsize);
CH *HtmlFindPropGetValKeepDefault(CH *content,CH *prop,CH *val,IN maxsize);
CH *HtmlFindPropGetInt(CH *content,CH *prop,IN *pi);
CH *HtmlFindPropGetIntKeepDefault(CH *content,CH *prop,IN *pi);
CH *HtmlFindPropGetLong(CH *content,CH *prop,LO *pl);
CH *HtmlFindPropGetLongKeepDefault(CH *content,CH *prop,LO *pl);
CH *HtmlFindPropGetDouble(CH *content,CH *prop,DO *pd);
CH *HtmlFindTagPropGetValFull(CH *s,CH *tag,CH *prop,CH *val,IN maxsize);
CH *HtmlFindTagPropGetVal(CH *s,CH *tag,CH *prop,CH *val,IN maxsize);

#if defined(HLS_WIN)
ER StrGetColor_HTML(CH *s,COLORREF *pcr);
CH *HtmlFindPropGetColor(CH *content,CH *prop,COLORREF *pcr);
CH *HtmlFindPropGetColorKeepDefault(CH *content,CH *prop,COLORREF *pcr);
CH *HtmlFindTagPropGetColorDefault(CH *s,CH *tag,CH *prop,COLORREF *pcr,COLORREF cr_default);
#endif


StartSeite | HelmutLeitner/ | Neues | TestSeite | ForumSeite | Teilnehmer | Kategorien | Index | Hilfe | Einstellungen | Ändern
Text dieser Seite ändern (zuletzt geändert: 28. Juni 2002 17:12 (diff))
Suchbegriff: gesucht wird
im Titel
im Text