4 * (C) 1992 Joseph H. Allen
6 * This file is part of JOE (Joe's Own Editor)
12 __RCSID("$MirOS: contrib/code/jupp/b.h,v 1.5 2017/12/02 02:07:23 tg Exp $");
16 extern unsigned char stdbuf[stdsiz];
18 extern int force; /* Set to have final '\n' added to file */
19 extern int tabwidth; /* Default tab width */
21 extern VFILE *vmem; /* Virtual memory file used for buffer system */
23 extern const unsigned char *msgs[];
25 B *bmk PARAMS((B *prop));
26 void brm PARAMS((B *b));
28 B *bfind PARAMS((unsigned char *s));
29 B *bfind_scratch PARAMS((unsigned char *s));
30 B *bcheck_loaded PARAMS((unsigned char *s));
31 B *bfind_reload PARAMS((unsigned char *s));
33 P *pdup PARAMS((P *p));
34 P *pdupown PARAMS((P *p, P **o));
35 P *poffline PARAMS((P *p));
36 P *ponline PARAMS((P *p));
37 B *bonline PARAMS((B *b));
38 B *boffline PARAMS((B *b));
40 void prm PARAMS((P *p));
41 P *pset PARAMS((P *n, P *p));
43 P *p_goto_bof PARAMS((P *p)); /* move cursor to begging of file */
44 P *p_goto_eof PARAMS((P *p)); /* move cursor to end of file */
45 P *p_goto_bol PARAMS((P *p)); /* move cursor to begging of line */
46 P *p_goto_eol PARAMS((P *p)); /* move cursor to end of line */
48 P *p_goto_indent PARAMS((P *p,int c)); /* move cursor to indentation point */
50 int pisbof PARAMS((P *p));
51 int piseof PARAMS((P *p));
52 int piseol PARAMS((P *p));
53 int pisbol PARAMS((P *p));
54 int pisbow PARAMS((P *p));
55 int piseow PARAMS((P *p));
57 #define piscol(p) ((p)->valcol ? (p)->col : (pfcol(p), (p)->col))
59 int pisblank PARAMS((P *p));
60 int piseolblank PARAMS((P *p));
62 long pisindent PARAMS((P *p));
63 int pispure PARAMS((P *p,int c));
65 int pnext PARAMS((P *p));
66 int pprev PARAMS((P *p));
68 int pgetb PARAMS((P *p));
69 int prgetb PARAMS((P *p));
71 int pgetc PARAMS((P *p));
72 int prgetc PARAMS((P *p));
74 P *pgoto PARAMS((P *p, long int loc));
75 P *pfwrd PARAMS((P *p, long int n));
76 P *pbkwd PARAMS((P *p, long int n));
78 P *pfcol PARAMS((P *p));
80 P *pnextl PARAMS((P *p));
81 P *pprevl PARAMS((P *p));
83 P *pline PARAMS((P *p, long int line));
85 P *pcolwse PARAMS((P *p, long int goalcol));
86 P *pcol PARAMS((P *p, long int goalcol));
87 P *pcoli PARAMS((P *p, long int goalcol));
88 void pbackws PARAMS((P *p));
89 void pfill PARAMS((P *p, long int to, int usetabs));
91 P *pfind PARAMS((P *p, unsigned char *s, int len));
92 P *pifind PARAMS((P *p, unsigned char *s, int len));
93 P *prfind PARAMS((P *p, unsigned char *s, int len));
94 P *prifind PARAMS((P *p, unsigned char *s, int len));
96 /* copy text between 'from' and 'to' into new buffer */
97 B *bcpy PARAMS((P *from, P *to));
99 void pcoalesce PARAMS((P *p));
101 void bdel PARAMS((P *from, P *to));
103 /* insert buffer 'b' into another at 'p' */
104 P *binsb PARAMS((P *p, B *b));
105 /* insert a block 'blk' of size 'amnt' into buffer at 'p' */
106 P *binsm PARAMS((P *p, unsigned char *blk, int amnt));
108 /* insert character 'c' into buffer at 'p' */
109 P *binsc PARAMS((P *p, int c));
111 /* insert byte 'c' into buffer at at 'p' */
112 P *binsbyte PARAMS((P *p, unsigned char c));
114 /* insert zero term. string 's' into buffer at 'p' */
115 P *binss PARAMS((P *p, unsigned char *s));
117 /* B *bload(char *s);
118 * Load a file into a new buffer
120 * Returns with errno set to 0 for success,
121 * -1 for new file (file doesn't exist)
126 B *bload PARAMS((unsigned char *s));
127 B *bread PARAMS((int fi, long int max));
128 B *borphan PARAMS((void));
130 /* Save 'size' bytes beginning at 'p' into file with name in 's' */
131 int bsave PARAMS((P *p, unsigned char *s, long int size,int flag));
132 int bsavefd PARAMS((P *p, int fd, long int size));
134 unsigned char *parsens PARAMS((unsigned char *s, long int *skip, long int *amnt));
136 /* Get byte at pointer or return NO_MORE_DATA if pointer is at end of buffer */
137 int brc PARAMS((P *p));
139 /* Get character at pointer or return NO_MORE_DATA if pointer is at end of buffer */
140 int brch PARAMS((P *p));
142 /* Copy 'size' bytes from a buffer beginning at p into block 'blk' */
143 unsigned char *brmem PARAMS((P *p, unsigned char *blk, int size));
145 /* Copy 'size' bytes from a buffer beginning at p into a zero-terminated
146 * C-string in an malloc block.
148 unsigned char *brs PARAMS((P *p, int size));
150 /* Copy 'size' bytes from a buffer beginning at p into a variable length string. */
151 unsigned char *brvs PARAMS((P *p, int size));
153 /* Copy line into buffer. Maximum of size bytes will be copied. Buffer needs
154 to be one bigger for NIL */
155 unsigned char *brzs PARAMS((P *p, unsigned char *buf, int size));
157 B *bnext PARAMS((void));
158 B *bprev PARAMS((void));
163 unsigned char **getbufs PARAMS((void));