Import upstream 2.3.14
[packages/xinetd.git] / libs / src / str / str.h
1 /*
2  * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
3  * All rights reserved.  The file named COPYRIGHT specifies the terms 
4  * and conditions for redistribution.
5  */
6
7
8 #ifndef __STR_H
9 #define __STR_H
10
11 /*
12  * $Id: str.h,v 1.4 2003/06/07 16:46:32 steveg Exp $
13  */
14
15 #include <stdarg.h>
16
17 #ifdef __GNUC__
18 #define PRINTF_FORMAT(n, m) \
19    __attribute__ ((format (printf, n, m)))
20 #else
21 #define PRINTF_FORMAT(n, m)
22 #endif
23
24 typedef void *str_h ;
25
26 /*
27  * strprint(3) functions
28  */
29 char *strx_sprint ( char *buf, int len, const char *fmt, ... ) 
30    PRINTF_FORMAT(3, 4);
31 int strx_nprint ( char *buf, int len, const char *fmt, ... ) 
32    PRINTF_FORMAT(3, 4);
33 void strx_print ( int *count, char *buf, int len, const char *fmt, ... )
34    PRINTF_FORMAT(4, 5);
35
36 int strx_nprintv ( char *buf, int len, const char *fmt, va_list )
37    PRINTF_FORMAT(3, 0);
38 void strx_printv ( int *cnt, char *buf, int len, const char *fmt, va_list ) 
39    PRINTF_FORMAT(4, 0);
40  
41
42 /*
43  * strparse(3) functions
44  */
45 int str_setstr( str_h handle, char *newstr );
46    
47 /*
48  * Return values
49  */
50 #define STR_OK                                  0
51 #define STR_ERR                                 (-1)
52    
53
54 /* 
55  * Flags for the string parsing functions
56  */
57 #define STR_NOFLAGS                     0x0
58 #define STR_RETURN_ERROR                0x1
59 #define STR_NULL_START                  0x2
60 #define STR_NULL_END                    0x4
61 #define STR_MALLOC                      0x8
62
63 /*
64  * Error values
65  */
66 #define STR_ENULLSEPAR                  1
67 #define STR_ENULLSTRING                 2
68 #define STR_ENOMEM                      3
69
70 char *new_string(const char *) ;
71 str_h str_parse ( char *str, const char *separ, int flags, int *errnop ) ;
72 void str_endparse ( str_h handle ) ;
73 char *str_component ( str_h handle ) ;
74
75
76 /*
77  * strutil(3) functions
78  */
79 char *str_casefind ( char *s1, const char *s2 ) ;
80 void str_fill ( char *s, char c ) ;
81
82
83 #endif  /* __STR_H */
84