BRL-CAD
Loading...
Searching...
No Matches
vls.h
Go to the documentation of this file.
1/* V L S . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2025 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20
21#ifndef BU_VLS_H
22#define BU_VLS_H
23
24#include "common.h"
25#include <stdio.h> /* for FILE */
26#include <stddef.h> /* for size_t */
27#include <stdarg.h> /* For va_list */
28
29
30#include "bu/defines.h"
31#include "bu/magic.h"
32
34
35/*----------------------------------------------------------------------*/
36/** @addtogroup bu_vls
37 *
38 * @brief
39 * Variable length strings provide a way for programmers to easily handling
40 * dynamic strings - they serve a function similar to that of std::string in
41 * C++.
42 *
43 * This frees the programmer from concerns about having character arrays large
44 * enough to hold strings.
45 *
46 * Assumption: libc-provided sprintf() function is safe to use in parallel, on
47 * parallel systems.
48 */
49/** @{ */
50/** @file bu/vls.h */
51
52/** Primary bu_vls container */
53struct bu_vls {
55 char *vls_str; /**< Dynamic memory for buffer */
56 size_t vls_offset; /**< Positive index into vls_str where string begins */
57 size_t vls_len; /**< Length, not counting the null */
58 size_t vls_max;
59};
60typedef struct bu_vls bu_vls_t;
61#define BU_VLS_NULL ((struct bu_vls *)0)
62
63/**
64 * assert the integrity of a bu_vls struct.
65 */
66#define BU_CK_VLS(_vp) BU_CKMAG(_vp, BU_VLS_MAGIC, "bu_vls")
67
68/**
69 * initializes a bu_vls struct without allocating any memory.
70 */
71#define BU_VLS_INIT(_vp) { \
72 (_vp)->vls_magic = BU_VLS_MAGIC; \
73 (_vp)->vls_str = NULL; \
74 (_vp)->vls_offset = (_vp)->vls_len = (_vp)->vls_max = 0; \
75 }
76
77/**
78 * macro suitable for declaration statement initialization of a bu_vls
79 * struct. does not allocate memory.
80 */
81#define BU_VLS_INIT_ZERO { BU_VLS_MAGIC, NULL, 0, 0, 0 }
82
83/**
84 * returns truthfully whether a bu_vls struct has been initialized.
85 * is not reliable unless the struct has been allocated with
86 * BU_ALLOC(), bu_calloc(), or a previous call to bu_vls_init() or
87 * BU_VLS_INIT() has been made.
88 */
89#define BU_VLS_IS_INITIALIZED(_vp) (((struct bu_vls *)(_vp) != BU_VLS_NULL) && ((_vp)->vls_magic == BU_VLS_MAGIC))
90
91/**
92 * No storage should be allocated at this point, and bu_vls_addr()
93 * must be able to live with that.
94 */
95BU_EXPORT extern void bu_vls_init(struct bu_vls *vp);
96
97/**
98 * Allocate storage for a struct bu_vls, call bu_vls_init on it, and
99 * return the result. Allows for creation of dynamically allocated
100 * VLS strings.
101 */
102BU_EXPORT extern struct bu_vls *bu_vls_vlsinit(void);
103
104/**
105 * Return a pointer to the null-terminated string in the vls array.
106 * If no storage has been allocated yet, give back a valid string.
107 */
108BU_EXPORT extern char *bu_vls_addr(const struct bu_vls *vp);
109
110/**
111 * Return a pointer to the null-terminated string in the vls array.
112 * If no storage has been allocated yet, give back a valid string.
113 * (At the moment this function is a mnemonically-named convenience
114 * function which returns a call to bu_vls_addr.)
115 */
116BU_EXPORT extern const char *bu_vls_cstr(const struct bu_vls *vp);
117
118/**
119 * Ensure that the provided VLS has at least 'extra' characters of
120 * space available. Additional space is allocated in minimum step
121 * sized amounts and may allocate more than requested.
122 */
123BU_EXPORT extern void bu_vls_extend(struct bu_vls *vp,
124 size_t extra);
125
126/**
127 * Ensure that the vls has a length of at least 'newlen', and make
128 * that the current length.
129 *
130 * Useful for subroutines that are planning on mucking with the data
131 * array themselves. Not advisable, but occasionally useful.
132 *
133 * Does not change the offset from the front of the buffer, if any.
134 * Does not initialize the value of any of the new bytes.
135 */
136BU_EXPORT extern void bu_vls_setlen(struct bu_vls *vp,
137 size_t newlen);
138/**
139 * Return length of the string, in bytes, not including the null
140 * terminator.
141 */
142BU_EXPORT extern size_t bu_vls_strlen(const struct bu_vls *vp);
143
144/**
145 * Truncate string to at most 'len' characters. If 'len' is negative,
146 * trim off that many from the end. If 'len' is zero, don't release
147 * storage -- user is probably just going to refill it again,
148 * e.g. with bu_vls_gets().
149 */
150BU_EXPORT extern void bu_vls_trunc(struct bu_vls *vp,
151 int len);
152
153/**
154 * "Nibble" 'len' characters off the front of the string. Changes the
155 * length and offset; no data is copied.
156 *
157 * 'len' may be positive or negative. If negative, characters are
158 * un-nibbled.
159 */
160BU_EXPORT extern void bu_vls_nibble(struct bu_vls *vp,
161 b_off_t len);
162
163/**
164 * Releases the memory used for the string buffer.
165 */
166BU_EXPORT extern void bu_vls_free(struct bu_vls *vp);
167
168/**
169 * Releases the memory used for the string buffer and the memory for
170 * the vls structure
171 */
172BU_EXPORT extern void bu_vls_vlsfree(struct bu_vls *vp);
173/**
174 * Return a dynamic copy of a vls. Memory for the string being
175 * returned is acquired using bu_malloc() implying the caller must
176 * bu_free() the returned string.
177 */
178BU_EXPORT extern char *bu_vls_strdup(const struct bu_vls *vp);
179
180/**
181 * Like bu_vls_strdup(), but destructively grab the string from the
182 * source argument 'vp'. This is more efficient than bu_vls_strdup()
183 * for those instances where the source argument 'vp' is no longer
184 * needed by the caller, as it avoids a potentially long buffer copy.
185 *
186 * The source string is destroyed, as if bu_vls_free() had been
187 * called.
188 */
189BU_EXPORT extern char *bu_vls_strgrab(struct bu_vls *vp);
190
191/**
192 * Empty the vls string, and copy in a regular string.
193 */
194BU_EXPORT extern void bu_vls_strcpy(struct bu_vls *vp,
195 const char *s);
196
197/**
198 * Empty the vls string, and copy in a regular string, up to N bytes
199 * long.
200 */
201BU_EXPORT extern void bu_vls_strncpy(struct bu_vls *vp,
202 const char *s,
203 size_t n);
204
205/**
206 * Concatenate a new string onto the end of the existing vls string.
207 */
208BU_EXPORT extern void bu_vls_strcat(struct bu_vls *vp,
209 const char *s);
210
211/**
212 * Concatenate a new string onto the end of the existing vls string.
213 */
214BU_EXPORT extern void bu_vls_strncat(struct bu_vls *vp,
215 const char *s,
216 size_t n);
217
218/**
219 * Concatenate a new vls string onto the end of an existing vls
220 * string. The storage of the source string is not affected.
221 */
222BU_EXPORT extern void bu_vls_vlscat(struct bu_vls *dest,
223 const struct bu_vls *src);
224
225/**
226 * Concatenate a new vls string onto the end of an existing vls
227 * string. The storage of the source string is released (zapped).
228 */
230 struct bu_vls *src);
231
232/**
233 * Lexicographically compare two vls strings. Returns an integer
234 * greater than, equal to, or less than 0, according as the string s1
235 * is greater than, equal to, or less than the string s2.
236 */
237BU_EXPORT extern int bu_vls_strcmp(struct bu_vls *s1,
238 struct bu_vls *s2);
239
240/**
241 * Lexicographically compare two vls strings up to n characters.
242 * Returns an integer greater than, equal to, or less than 0,
243 * according as the string s1 is greater than, equal to, or less than
244 * the string s2.
245 */
246BU_EXPORT extern int bu_vls_strncmp(struct bu_vls *s1,
247 struct bu_vls *s2,
248 size_t n);
249
250/**
251 * Given and argc & argv pair, convert them into a vls string of
252 * space-separated words.
253 */
254BU_EXPORT extern void bu_vls_from_argv(struct bu_vls *vp,
255 int argc,
256 const char *argv[]);
257
258/**
259 * Write the VLS to the provided file pointer.
260 */
261BU_EXPORT extern void bu_vls_fwrite(FILE *fp,
262 const struct bu_vls *vp);
263
264/**
265 * Write the VLS to the provided file descriptor.
266 */
267BU_EXPORT extern void bu_vls_write(int fd,
268 const struct bu_vls *vp);
269
270/**
271 * Read the remainder of a UNIX file onto the end of a vls.
272 *
273 * Returns -
274 * nread number of characters read
275 * 0 if EOF encountered immediately
276 * -1 read error
277 */
278BU_EXPORT extern int bu_vls_read(struct bu_vls *vp,
279 int fd);
280
281/**
282 * Append a newline-terminated string from the file pointed to by "fp"
283 * to the end of the vls pointed to by "vp". The newline from the
284 * file is read, but not stored into the vls.
285 *
286 * The most common error is to forget to bu_vls_trunc(vp, 0) before
287 * reading the next line into the vls.
288 *
289 * Returns -
290 * >=0 the length of the resulting vls
291 * -1 on EOF where no characters were read or added to the vls
292 */
293BU_EXPORT extern int bu_vls_gets(struct bu_vls *vp,
294 FILE *fp);
295
296/**
297 * Append the given character to the vls.
298 */
299BU_EXPORT extern void bu_vls_putc(struct bu_vls *vp,
300 int c);
301
302/**
303 * Remove leading and trailing white space from a vls string.
304 */
305BU_EXPORT extern void bu_vls_trimspace(struct bu_vls *vp);
306
307
308/**
309 * Format a string into a vls using standard variable arguments.
310 *
311 * %s continues to be a regular null-terminated 'C' string (char *).
312 * %V is a libbu variable-length string (struct bu_vls *).
313 *
314 * Other format specifiers should behave identical to printf().
315 *
316 * This routine appends to the given vls similar to how vprintf
317 * appends to stdout (see bu_vls_sprintf for overwriting the vls).
318 * The implementation ends up calling bu_vls_vprintf().
319 */
320BU_EXPORT extern void bu_vls_printf(struct bu_vls *vls,
321 const char *fmt, ...) _BU_ATTR_PRINTF23;
322
323/**
324 * Format a string into a vls, setting the vls to the given print
325 * specifier expansion. This routine truncates any existing vls
326 * contents beforehand (i.e. it doesn't append, see bu_vls_vprintf for
327 * appending to the vls).
328 *
329 * %s continues to be a regular 'C' string, null terminated.
330 * %V is a pointer to a (struct bu_vls *) string.
331 */
332BU_EXPORT extern void bu_vls_sprintf(struct bu_vls *vls,
333 const char *fmt, ...) _BU_ATTR_PRINTF23;
334
335/**
336 * Efficiently append 'cnt' spaces to the current vls.
337 */
338BU_EXPORT extern void bu_vls_spaces(struct bu_vls *vp,
339 size_t cnt);
340
341/**
342 * Returns number of printed spaces used on final output line of a
343 * potentially multi-line vls. Useful for making decisions on when to
344 * line-wrap.
345 *
346 * Accounts for normal UNIX tab-expansion:
347 * 1 2 3 4
348 * 1234567890123456789012345678901234567890
349 * x x x x
350 *
351 * 0-7 --> 8, 8-15 --> 16, 16-23 --> 24, etc.
352 */
354
355/**
356 * Given a vls, return a version of that string which has had all
357 * "tab" characters converted to the appropriate number of spaces
358 * according to the UNIX tab convention.
359 */
360BU_EXPORT extern void bu_vls_detab(struct bu_vls *vp);
361
362
363/**
364 * Add a string to the beginning of the vls.
365 */
366BU_EXPORT extern void bu_vls_prepend(struct bu_vls *vp,
367 const char *str);
368
369
370/**
371 * Copy a substring from a source vls into a destination vls
372 *
373 * where:
374 *
375 * begin - the index (0-based) of the beginning character position
376 * in the source vls
377 * nchars - the number of characters to copy
378 *
379 */
380BU_EXPORT extern void bu_vls_substr(struct bu_vls *dest, const struct bu_vls *src,
381 size_t begin, size_t nchars);
382
383/** @brief bu_vls_vprintf implementation */
384
385/**
386 * Format a string into a vls using a varargs list.
387 *
388 * %s continues to be a regular null-terminated 'C' string (char *).
389 * %V is a libbu variable-length string (struct bu_vls *).
390 *
391 * Other format specifiers should behave identical to printf().
392 *
393 * This routine appends to the given vls similar to how vprintf
394 * appends to stdout (see bu_vls_sprintf for overwriting the vls).
395 */
396BU_EXPORT extern void bu_vls_vprintf(struct bu_vls *vls,
397 const char *fmt,
398 va_list ap);
399
400
401/** @brief Routines to encode/decode strings into bu_vls structures. */
402
403/**
404 * given an input string, wrap the string in double quotes if there is
405 * a space and append it to the provided bu_vls. escape any existing
406 * double quotes.
407 *
408 * TODO: consider a specifiable quote character and octal encoding
409 * instead of double quote wrapping. perhaps specifiable encode type:
410 * BU_ENCODE_QUOTE
411 * BU_ENCODE_OCTAL
412 * BU_ENCODE_XML
413 *
414 * More thoughts on encode/decode - the nature of "quoting" is going to
415 * vary depending on the usage context and the language. For some
416 * applications, HEX or BASE64 may be appropriate. For others (like
417 * the problems with arbitrary strings in Tcl which initially motivated
418 * these functions) such wholesale encoding is not needed and it is just
419 * a subset of characters that must be escaped or otherwise identified.
420 *
421 * Given the large set of possible scenarios, it definitely makes sense
422 * to allow an encoding specifying variable, and probably other optional
423 * variables (which may be NULL, depending on the encoding type) specifying
424 * active characters (that need quoting) and an escape character (or
425 * characters? does it take more than one in some scenarios? perhaps start
426 * and end of escape strings would be the most general?)
427 *
428 * This probably makes sense as its own header given that is is really
429 * a feature on top of vls rather than something integral to vls
430 * itself - it would be workable (maybe even practical, if the final
431 * length of the encoded data can be pre-determined) to just work with
432 * char arrays: see bu_str_escape()
433 *
434 * the behavior of this routine is subject to change but should remain
435 * a reversible operation when used in conjunction with
436 * bu_vls_decode().
437 *
438 * returns a pointer to the encoded string (i.e., the substring held
439 * within the bu_vls)
440 */
441BU_EXPORT extern const char *bu_vls_encode(struct bu_vls *vp, const char *str);
443
444/**
445 * given an encoded input string, unwrap the string from any
446 * surrounding double quotes and unescape any embedded double quotes.
447 *
448 * the behavior of this routine is subject to change but should remain
449 * the reverse operation of bu_vls_encode().
450 *
451 * returns a pointer to the decoded string (i.e., the substring held
452 * within the bu_vls)
453 */
454BU_EXPORT extern const char *bu_vls_decode(struct bu_vls *vp, const char *str);
456/**
457 @brief
458 Automatic string generation routines.
459
460 There are many situations where a calling program, given an input string,
461 needs to produce automatically derived output strings that satisfy some
462 criteria (incremented, special characters removed, etc.) The functions
463 below perform this type of work.
464*/
465
466
467/**
468 * A problem frequently encountered when working with strings in BRL-CAD
469 * is the presence of special characters, characters active in the scripting
470 * language being applied, or other problematic contents that interfere with
471 * processing or readability of strings. This function takes a vls as an
472 * input and simplifies it as follows:
473 *
474 * 1) Reduce characters present to alphanumeric characters and those
475 * characters supplied to the routine in the "keep" string. Substitute
476 * is performed as follows:
477 *
478 * * Skip any character in the "keep" string
479 *
480 * * Replace diacritic characters(code >= 192) from the extended ASCII set
481 * with a specific mapping from the standard ASCII set. See discussion at:
482 * http://stackoverflow.com/questions/14094621/ for more about this.
483 *
484 * * Replace any non-keep characters that aren't replaced by other
485 * approaches with the '_' underscore character
486 *
487 * 2) Collapses duplicate characters in the "de_dup" string.
488 *
489 * 3) Remove leading and trailing characters in the "trim' string.
490 *
491 * Returns 0 if string was not altered, 1 otherwise.
492 */
493BU_EXPORT extern int bu_vls_simplify(struct bu_vls *vp, const char *keep, const char *de_dup, const char *trim);
495
496/**
497 * callback type for bu_vls_incr()
498 */
499typedef int (*bu_vls_uniq_t)(struct bu_vls *v, void *data);
501
502/**
503 * A problem frequently encountered when generating names is
504 * generating names that are in some sense structured but avoid
505 * colliding. For example, given a geometry object named:
506 *
507 * @verbatim
508 * engine_part.s
509 * @endverbatim
510 *
511 * An application wanting to make multiple copies of engine_part.s
512 * automatically might want to produce a list of names such as:
513 *
514 * @verbatim
515 * engine_part.s-1, engine_part.s-2, engine_part.s-3, ...
516 * @endverbatim
517 *
518 * However, it is equally plausible that the desired pattern might be:
519 *
520 * @verbatim
521 * engine_part_0010.s, engine_part_0020.s, engine_part_0030.s, ...
522 * @endverbatim
523 *
524 * This function implements an engine for generating the "next" name
525 * in a sequence, given an initial name supplied by the caller and
526 * (optionally) information to identify the incrementor in the string
527 * and the incrementing behavior desired. bu_vls_incr does not track
528 * any "state" for individual strings - all information is contained
529 * either in the current state of the input string itself or the
530 * incrementation specifier (more details on the latter can be found
531 * below.)
532 *
533 * @param[in,out] name Contains the "seed" string for the name
534 * generation. Upon return the old string is cleared and the new one
535 * resides in name
536 *
537 * @param[in] regex_str Optional - user supplied regular expression
538 * for locating the incrementer substring.
539 *
540 * @param[in] incr_spec Optional - string of colon separated
541 * parameters defining function behavior.
542 *
543 * @param[in] uniq_test Optional - uniqueness testing function.
544 *
545 * @param[in] data Optional - data to pass to the uniq_test
546 * function call.
547 *
548 *
549 * @section bu_vls_incr_regexp Incrementer Substring Identification
550 *
551 * bu_vls_incr uses regular expressions to identify the numerical part
552 * of a supplied string. By default, if no regular expression is
553 * supplied by the caller, bu_vls_incr will use a numerical sequence
554 * at the end of the string (more precisely, it will use the last
555 * sequence of numbers if and only if there are no non-numerical
556 * characters between that sequence and the end of the string.) If no
557 * appropriate match is found, the incrementer will be appended to the
558 * end of the string.
559 *
560 * When no pre-existing number is found to start the sequence, the
561 * default behavior is to treat the existing string as the "0"-th item
562 * in the sequence. In such cases bu_vls_incr will thus return one,
563 * not zero, as the first incremented name in the sequence.
564 *
565 * If the caller wishes to be more sophisticated about where
566 * incrementers are found in strings, they may supply their own
567 * regular expression that uses parenthesis bounded matchers to
568 * identify numerical identifiers. For example, the regular
569 * expression:
570 *
571 * @verbatim
572 * ([-_:]*[0-9]+[-_:]*)[^0-9]*$
573 * @endverbatim
574 *
575 * will instruct bu_vls_incr to define not just the last number but
576 * the last number and any immediately surrounding separator
577 * characters as the subset of the string to process. Combined with a
578 * custom incrementation specifier, this option allows calling
579 * programs to exercise broad flexibility in how they process strings.
580 *
581 * @section bu_vls_incr_inc Specifying Incrementor Behavior
582 *
583 * The caller may optionally specify incrementation behavior with an
584 * incrementer specification string, which has the following form:
585 * "minwidth:init:max:step[:left_sepchar:right_sepchar]"
586 *
587 * The table below explains the individual elements.
588 *
589 * <table>
590 * <tr><th colspan="2">"minwidth:init:max:step[:left_sepchar:right_sepchar]"</th></tr>
591 * <tr><td>minwidth</td> <td>specifies the minimum number of digits used when printing the incrementer substring</td>
592 * <tr><td>init</td> <td>specifies the initial minimum value to use when returning an incremented string. Overrides the string-based value if that value is less than the init value.</td>
593 * <tr><td>max</td> <td>specifies the maximum value of the incrementer - if the step takes the value past this number, the counter "rolls over" to the init value.</td>
594 * <tr><td>step</td> <td>value by which the incrementor value is increased</td>
595 * <tr><td>left_sepchar</td> <td>optional - specify a character to insert to the left of the numerical substring</td>
596 * <tr><td>right_sepchar</td><td>optional - specify a character to insert to the right of the numerical substring</td>
597 * </table>
598 *
599 * In the case of minwidth, init, max, and step a '0' always indicates
600 * unspecified (i.e. "default") behavior. So, an incrementer
601 * specified as 0:0:0:0 would behave as follows:
602 *
603 * minwidth: width found in string, or standard printf handling if
604 * nothing useful is found. For example, engine_part-001.s would by
605 * default be incremented to engine_part-002.s, preserving the prefix
606 * zeros.
607 *
608 * init: from initial name string, or 0 if not found
609 *
610 * max: LONG_MAX
611 *
612 * step: 1
613 *
614 * The last two separator chars are optional - they are useful if the
615 * caller wants to guarantee a separation between the active
616 * incremented substring and its surroundings. For example, the
617 * following would prefix the incrementer output with an underscore
618 * and add a suffix with a dash:
619 *
620 * @verbatim
621 * 0:0:0:0:_:-
622 * @endverbatim
623 *
624 * @section bu_vls_incr_ex Examples
625 *
626 * To generate a suffix pattern, e.g.,:
627 *
628 * @verbatim
629 * engine_part.s-1, engine_part.s-2, engine_part.s-3, ...
630 * @endverbatim
631 *
632 * Example code is as follows:
633 *
634 * @code
635 * struct bu_vls name = BU_VLS_INIT_ZERO;
636 * bu_vls_sprintf(&name, "engine_part.s");
637 * for (int i = 0; i < 10; i++) {
638 * bu_vls_incr(&name, NULL, "0:0:0:0:-", NULL, NULL);
639 * bu_log("%s\n", bu_vls_cstr(&name));
640 * }
641 * bu_vls_free(&name);
642 * @endcode
643 *
644 * Here we show an infix case. There is no number present in the
645 * original string, we want the number *before* the .s suffix, we're
646 * incrementing by more than 1, we want four numerical digits in the
647 * string, and we want an underscore prefix spacer before the number:
648 *
649 * @verbatim
650 * engine_part_0010.s, engine_part_0020.s, engine_part_0030.s, ...
651 * @endverbatim
652 *
653 * To set this up correctly we take advantage of the bu_path_component
654 * function and construct an initial "seed" string with a zero
655 * incrementer where we need it:
656 *
657 * @code
658 * const char *estr = "engine_part.s"
659 * struct bu_vls name = BU_VLS_INIT_ZERO;
660 * bu_vls_sprintf(&name, "%s0.%s",
661 * bu_path_component(estr, BU_PATH_EXTLESS),
662 * bu_path_component(estr, BU_PATH_EXT));
663 * for (int i = 0; i < 10; i++) {
664 * bu_vls_incr(&name, NULL, "4:10:0:10:_", NULL, NULL);
665 * bu_log("%s\n", bu_vls_cstr(&name));
666 * }
667 * bu_vls_free(&name);
668 * @endcode
669 *
670 */
671BU_EXPORT extern int bu_vls_incr(struct bu_vls *name, const char *regex_str, const char *incr_spec, bu_vls_uniq_t uniq_test, void *data);
674
675/** @} */
676
677#endif /* BU_VLS_H */
678
679/*
680 * Local Variables:
681 * mode: C
682 * tab-width: 8
683 * indent-tabs-mode: t
684 * c-file-style: "stroustrup"
685 * End:
686 * ex: shiftwidth=4 tabstop=8
687 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
#define _BU_ATTR_PRINTF23
Definition defines.h:95
void bu_vls_putc(struct bu_vls *vp, int c)
int bu_vls_read(struct bu_vls *vp, int fd)
int(* bu_vls_uniq_t)(struct bu_vls *v, void *data)
Definition vls.h:500
char * bu_vls_strdup(const struct bu_vls *vp)
void bu_vls_trimspace(struct bu_vls *vp)
void bu_vls_from_argv(struct bu_vls *vp, int argc, const char *argv[])
void bu_vls_vlsfree(struct bu_vls *vp)
char * bu_vls_strgrab(struct bu_vls *vp)
void bu_vls_vlscat(struct bu_vls *dest, const struct bu_vls *src)
void bu_vls_free(struct bu_vls *vp)
const char * bu_vls_encode(struct bu_vls *vp, const char *str)
Routines to encode/decode strings into bu_vls structures.
struct bu_vls * bu_vls_vlsinit(void)
void bu_vls_write(int fd, const struct bu_vls *vp)
int bu_vls_strcmp(struct bu_vls *s1, struct bu_vls *s2)
void bu_vls_sprintf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
char * bu_vls_addr(const struct bu_vls *vp)
void bu_vls_init(struct bu_vls *vp)
void bu_vls_prepend(struct bu_vls *vp, const char *str)
int bu_vls_strncmp(struct bu_vls *s1, struct bu_vls *s2, size_t n)
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
void bu_vls_fwrite(FILE *fp, const struct bu_vls *vp)
void bu_vls_spaces(struct bu_vls *vp, size_t cnt)
const char * bu_vls_decode(struct bu_vls *vp, const char *str)
void bu_vls_strncat(struct bu_vls *vp, const char *s, size_t n)
int bu_vls_simplify(struct bu_vls *vp, const char *keep, const char *de_dup, const char *trim)
Automatic string generation routines.
void bu_vls_nibble(struct bu_vls *vp, b_off_t len)
int bu_vls_gets(struct bu_vls *vp, FILE *fp)
void bu_vls_detab(struct bu_vls *vp)
void bu_vls_trunc(struct bu_vls *vp, int len)
void bu_vls_vlscatzap(struct bu_vls *dest, struct bu_vls *src)
void bu_vls_extend(struct bu_vls *vp, size_t extra)
void bu_vls_strcpy(struct bu_vls *vp, const char *s)
void bu_vls_setlen(struct bu_vls *vp, size_t newlen)
void bu_vls_substr(struct bu_vls *dest, const struct bu_vls *src, size_t begin, size_t nchars)
int bu_vls_incr(struct bu_vls *name, const char *regex_str, const char *incr_spec, bu_vls_uniq_t uniq_test, void *data)
void bu_vls_strcat(struct bu_vls *vp, const char *s)
void bu_vls_vprintf(struct bu_vls *vls, const char *fmt, va_list ap)
bu_vls_vprintf implementation
size_t bu_vls_strlen(const struct bu_vls *vp)
void bu_vls_strncpy(struct bu_vls *vp, const char *s, size_t n)
const char * bu_vls_cstr(const struct bu_vls *vp)
size_t bu_vls_print_positions_used(const struct bu_vls *vp)
void float float int * n
Definition tig.h:74
void int * c
Definition tig.h:139
#define b_off_t
Definition common.h:223
Global registry of recognized magic numbers.
Definition vls.h:53
uint32_t vls_magic
Definition vls.h:54
size_t vls_offset
Definition vls.h:56
char * vls_str
Definition vls.h:55
size_t vls_len
Definition vls.h:57
size_t vls_max
Definition vls.h:58