Debian Codegraph @

util.h

raw
1 /**************************************************************************
2 * This program is Copyright (C) 1986-2002 by Jonathan Payne. JOVE is *
3 * provided by Jonathan and Jovehacks without charge and without *
4 * warranty. You may copy, modify, and/or distribute JOVE, provided that *
5 * this notice is included in all the source files and documentation. *
6 **************************************************************************/
7
8 /* some utility functions, as macros, to be included by jove.h */
9
10 extern int
11 fnamecomp(const void *, const void *); /* order file names */
12
13 #define IsModified(b) ((b)->b_modified)
14 #define SavLine(a, b) ((a)->l_dline = jputline((b)))
15 #define SetLine(line) DotTo((line), 0)
16 #define bobp() (firstp(curline) && bolp())
17 #define bolp() (curchar == 0)
18 #define eobp() (lastp(curline) && eolp())
19 #define eolp() (linebuf[curchar] == '\0')
20 #define firstp(line) ((line) == curbuf->b_first)
21 #define getDOT() jgetline(curline->l_dline, linebuf)
22 #define lastp(line) ((line) == curbuf->b_last)
23
24 extern void
25 *emalloc(size_t size),
26 *erealloc(void *ptr, size_t size);
27
28 extern char
29 *IOerr(const char *err, const char *file),
30 *copystr(const char *str),
31 *get_time(time_t *timep,char *buf,int from,int to),
32 *lcontents(LinePtr line),
33 *ltobuf(LinePtr line,char *buf);
34
35 extern const char
36 *jbasename(const char *f),
37 *filename(const Buffer *b);
38
39 extern long
40 inorder(LinePtr nextp,int char1,LinePtr endp,int char2),
41 LineDist(LinePtr nextp,LinePtr endp),
42 LinesTo(LinePtr from, LinePtr to);
43
44 extern int
45 length(LinePtr line),
46 jmax(int a,int b),
47 jmin(int a,int b),
48 numcomp(const char *s1, const char *s2),
49 numcompcase(const char *s1, const char *s2);
50
51 extern ZXchar
52 DecodePair(ZXchar first, ZXchar second);
53
54 extern jbool
55 caseeqn(const char *s1, const char *s2, size_t n),
56 TwoBlank(void),
57 blnkp(char *buf),
58 within_indent(void),
59 fixorder(LinePtr *line1,int *char1,LinePtr *line2,int *char2),
60 inlist(LinePtr first,LinePtr what),
61 sindex(const char *pattern, const char *string),
62 ModBufs(jbool allp);
63
64 extern void
65 DOTsave(Bufpos *buf),
66 DotTo(LinePtr line,int col),
67 PushPntp(LinePtr line),
68 SetDot(const Bufpos *bp),
69 ToFirst(void),
70 ToLast(void),
71 ins_c(DAPchar c,char *buf,int atchar,int num,int max),
72 len_error(int flag) NEVER_RETURNS,
73 linecopy(char *onto,int atchar,char *from),
74 modify(void),
75 diverge(Buffer *buf, jbool d),
76 null_ncpy(char *to, const char *from, size_t n),
77 #ifdef UNIX
78 dopipe(int p[2]),
79 pipeclose(int p[2]),
80 #endif
81 pop_env(jmp_buf),
82 push_env(jmp_buf),
83 to_word(int dir),
84 unmodify(void);
85
86 extern void *
87 freealloc(void *obj, size_t size);
88
89 #if defined(IPROCS) || defined(SUBSHELL)
90 # if !defined(OWCDOS) && !defined(MINGW)
91 /*
92 * The Open Watcom C and MinGW declaration of environ has some macro
93 * decorations that do not match with this, so we skip this,
94 * their declaration works and is available.
95 * Linux only provides this in unistd.h if _GNU_SOURCE is defined,
96 * which we do not.
97 * *BSD and OpenIndiana (Solaris) and probably most other
98 * systems do not provide it, since it is not part of POSIX,
99 * but environ seems remarkably portable, nonetheless!
100 */
101 extern char **environ; /* <unistd.h> */
102 # endif
103
104 typedef struct {
105 const char **e_data;
106 jbool e_malloced;
107 int e_headroom; /* remaining room in e_data array */
108 } Env;
109
110 extern const char **
111 jenvdata(Env *envp);
112 extern void
113 jputenv(Env *envp, const char *def),
114 junsetenv(Env *envp, const char *name);
115 #endif /* defined(IPROCS) */
116
117 /* copy a string into a possibly-too-small buffer
118 * trunc* silently truncates a too-large string.
119 * jam* complain if the string is too large.
120 */
121 #define truncstr(buf, str) truncstrsub(buf, str, sizeof(buf))
122 #define jamstr(buf, str) jamstrsub(buf, str, sizeof(buf))
123 extern void
124 truncstrsub(char *buf, const char *str, size_t bufsz),
125 jamstrsub(char *buf, const char *str, size_t bufsz),
126 jamstrcat(char *buf, const char *str, size_t bufsz);
127
128 /* Variables: */
129
130 extern int MarkThresh; /* VAR: moves greater than MarkThresh will SetMark */