File: Parse.h

package info (click to toggle)
fvwm 1:2.6.8-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,804 kB
  • sloc: ansic: 145,770; xml: 17,093; perl: 7,302; sh: 4,921; makefile: 1,094; yacc: 688; lex: 187; sed: 11
file content (86 lines) | stat: -rw-r--r-- 3,262 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* -*-c-*- */

#ifndef FVWMLIB_PARSE_H
#define FVWMLIB_PARSE_H

/* ---------------------------- included header files ---------------------- */

#include "libs/Strings.h"

/* ---------------------------- global definitions ------------------------- */

#define MAX_TOKEN_LENGTH 1023

/* ---------------------------- global macros ------------------------------ */

/*
 * Stuff for consistent parsing
 */
#define IsQuote(c) ((c) == '"' || (c) == '\'' || (c) =='`')
#define IsBlockStart(c) ((c) == '[' || (c) == '{' || (c) == '(')
#define IsBlockEnd(c,cs) (((c) == ']' && (cs) == '[') || ((c) == '}' && (cs) == '{') || ((c) == ')' && (cs) == '('))

/*
 *  function:            FindToken
 *  description:         find the entry of type 'struct_entry'
 *                       holding 'key' in 'table'
 *  returns:             pointer to the matching entry
 *                       NULL if not found
 *
 *  table must be sorted in ascending order for FindToken.
 */
#define FindToken(key,table,struct_entry) \
	(struct_entry *) bsearch( \
		key, \
		(char *)(table), \
		sizeof(table) / sizeof(struct_entry), \
		sizeof(struct_entry), \
		(int(*)(const void*, const void*))XCmpToken)

/* ---------------------------- type definitions --------------------------- */

/* ---------------------------- exported variables (globals) --------------- */

/* ---------------------------- interface functions ------------------------ */

char *EscapeString(char *s, const char *qchars, char echar);
char *SkipQuote(
	char *s, const char *qlong, const char *qstart, const char *qend);
char *GetQuotedString(
	char *sin, char **sout, const char *delims, const char *qlong,
	const char *qstart, const char *qend);
char *SkipSpaces(char *indata, char *spaces, int snum);
char *DoPeekToken(
	char *indata, char **token, char *spaces, char *delims,
	char *out_delim);
char *PeekToken(char *indata, char **token);
int MatchToken(char *pstr,char *tok);

/* old style parse routine: */
char *DoGetNextToken(
	char *indata,char **token, char *spaces, char *delims,
	char *out_delim);
char *GetNextToken(char *indata,char **token);
char *GetNextSimpleOption(char *indata, char **option);
char *GetNextFullOption(char *indata, char **option);
char *SkipNTokens(char *indata, unsigned int n);
char *GetModuleResource(char *indata, char **resource, char *module_name);
int GetSuffixedIntegerArguments(
	char *action, char **ret_action, int *retvals, int num,
	char *suffixlist, int *ret_suffixnum);
int GetIntegerArgumentsAnyBase(
	char *action, char **ret_action, int *retvals,int num);
int SuffixToPercentValue(int value, int suffix, int *unit_table);
int GetIntegerArguments(char *action, char**ret_action, int *retvals,int num);
int GetTokenIndex(char *token, char **list, int len, char **next);
char *GetNextTokenIndex(char *action, char **list, int len, int *index);
int GetRectangleArguments(char *action, int *width, int *height);
int GetOnePercentArgument(char *action, int *value, int *unit_io);
int GetTwoPercentArguments(
	char *action, int *val1, int *val2, int *val1_unit, int *val2_unit);
int ParseToggleArgument(
	char *action, char **ret_action, int default_ret, char no_toggle);
int XCmpToken(const char *s, const char **t);
char *GetFileNameFromPath(char *path);

#endif