081e6815 |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: str.h,v 1.1 1999/05/17 20:37:01 mdw Exp $ |
4 | * |
5 | * Functions for hacking with strings |
6 | * |
7 | * (c) 1999 Straylight/Edgeware |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of the mLib utilities library. |
13 | * |
14 | * mLib is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU Library General Public License as |
16 | * published by the Free Software Foundation; either version 2 of the |
17 | * License, or (at your option) any later version. |
18 | * |
19 | * mLib is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU Library General Public License for more details. |
23 | * |
24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with mLib; if not, write to the Free |
26 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
27 | * MA 02111-1307, USA. |
28 | */ |
29 | |
30 | /*----- Revision history --------------------------------------------------* |
31 | * |
32 | * $Log: str.h,v $ |
33 | * Revision 1.1 1999/05/17 20:37:01 mdw |
34 | * Some trivial string hacks. |
35 | * |
36 | */ |
37 | |
38 | #ifndef STR_H |
39 | #define STR_H |
40 | |
41 | #ifdef __cplusplus |
42 | extern "C" { |
43 | #endif |
44 | |
45 | /*----- Header files ------------------------------------------------------*/ |
46 | |
47 | #include <stddef.h> |
48 | |
49 | /*----- Functions provided ------------------------------------------------*/ |
50 | |
51 | /* --- @str_getword@ --- * |
52 | * |
53 | * Arguments: @char **pp@ = address of pointer into string |
54 | * |
55 | * Returns: Pointer to the next space-separated word from the string, |
56 | * or null. |
57 | * |
58 | * Use: Parses off space-separated words from a string. |
59 | */ |
60 | |
61 | extern char *str_getword(char **/*pp*/); |
62 | |
63 | /* --- @str_split@ --- * |
64 | * |
65 | * Arguments: @char *p@ = pointer to string |
66 | * @char *v[]@ = pointer to array to fill in |
67 | * @size_t c@ = count of strings to fill in |
68 | * |
69 | * Returns: Number of strings filled in. |
70 | * |
71 | * Use: Fills an array with pointers to the individual words of a |
72 | * string. The string is modified in place to contain zero |
73 | * bytes at the word boundaries, and the words have leading |
74 | * and trailing space stripped off. No more than @c@ words |
75 | * are read; the actual number is returned as the value of the |
76 | * function. Unused slots in the array are populated with |
77 | * null bytes. |
78 | */ |
79 | |
80 | extern size_t str_split(char */*p*/, char */*v*/[], size_t /*c*/); |
81 | |
82 | /* --- @str_sanitize@ --- * |
83 | * |
84 | * Arguments: @char *d@ = destination buffer |
85 | * @const char *p@ = pointer to source string |
86 | * @size_t sz@ = size of destination buffer |
87 | * |
88 | * Returns: --- |
89 | * |
90 | * Use: Writes a string into a buffer, being careful not to overflow |
91 | * the buffer, to null terminate the result, and to prevent |
92 | * nasty nonprintable characters ending up in the buffer. |
93 | */ |
94 | |
95 | extern void str_sanitize(char */*d*/, const char */*p*/, size_t /*sz*/); |
96 | |
97 | /*----- That's all, folks -------------------------------------------------*/ |
98 | |
99 | #ifdef __cplusplus |
100 | } |
101 | #endif |
102 | |
103 | #endif |