File: parse.h

package info (click to toggle)
pcb-rnd 3.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 29,624 kB
  • sloc: ansic: 197,571; yacc: 6,153; sh: 5,808; awk: 2,708; makefile: 2,139; lex: 1,107; python: 519; xml: 261; lisp: 169; tcl: 67; perl: 34; javascript: 6; ruby: 5
file content (30 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (4)
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
#include <stdio.h>
#include <string.h>
#include <ctype.h>

/* remove leading whitespace */
#define ltrim(s) while(isspace(*s)) s++

/* remove trailing newline;; trailing backslash is an error */
#define rtrim(s) \
	do { \
		char *end; \
		for(end = s + strlen(s) - 1; (end >= s) && ((*end == '\r') || (*end == '\n')); end--) \
			*end = '\0'; \
		if ((end[0] == '\\') && ((end == s) || (end[-1] != '\\'))) \
			return -1; \
	} while(0)

#define null_empty(s) ((s) == NULL ? "" : (s))

int tedax_getline(FILE *f, char *buff, int buff_size, char *argv[], int argv_size);

int tedax_seek_hdr(FILE *f, char *buff, int buff_size, char *argv[], int argv_size);
int tedax_seek_block(FILE *f, const char *blk_name, const char *blk_ver, const char *blk_id, int silent, char *buff, int buff_size, char *argv[], int argv_size);


/* print val with special chars escaped. Prints a single dash if val is NULL or empty. */
void tedax_fprint_escape(FILE *f, const char *val);
void tedax_fnprint_escape(FILE *f, const char *val, int len);
int tedax_strncpy_escape(char *dst, int dstlen, const char *val);