~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to incl/str.h

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
2
.TYPE           Header
 
3
.NAME           str.h
 
4
.LANGUAGE       C
 
5
.AUTHOR         Francois Ochsenbein [ESO-IPG]
 
6
.CATEGORY       Operations on Strings.
 
7
.ENVIRONMENT    
 
8
.COMMENTS       System-independent string functions, using osc routines.
 
9
                Strings are assumed to be terminated with a null character.
 
10
                Mnemonics are str for case-sensitive function, stu for
 
11
                case insensitive functions. 
 
12
                The function name is terminated with the underscore (_) for
 
13
                functions requiring a table.
 
14
.VERSION 1.0    06-Jun-1986: creation
 
15
.VERSION 1.1    23-Jun-1987: Control chars definition
 
16
.VERSION 2.0    21-Jan-1988: Inserted as ctype
 
17
.VERSION 2.1    12-May-1989: Added strncopy
 
18
.VERSION 2.2    22-Jun-1989: Added strsave
 
19
.VERSION 2.3    31-Jan-1990: Added tokenisation functions, strloc1, strscan1
 
20
.VERSION 2.4    29-Mar-1990: Renamed string tokenization functions.
 
21
                Changed strred to a function.
 
22
.VERSION 2.5    11-Sep-1990: Added strnins strins
 
23
 070829         last modif
 
24
------------------------------------------------------------*/
 
25
 
 
26
#ifndef STR_DEF
 
27
#define STR_DEF         0
 
28
 
 
29
#include <atype.h>
 
30
 
 
31
/*===========================================================================
 
32
 *                      Copy functions  (with overlay)
 
33
 *===========================================================================*/
 
34
 
 
35
int strcopy     (char *dest, char *source);
 
36
int strncopy    (char *dest, int dest_size, char *source);
 
37
int strfill     (char *dest, int len, int filler);
 
38
int strnins     (char *dest, int dest_size, char *text);
 
39
int strins      (char *dest, char *text);
 
40
char *mm_ssave  (char *source);
 
41
 
 
42
/*======================================================================
 
43
 *                      Locate / Skip characters
 
44
 *======================================================================*/
 
45
 
 
46
int strloc      (char *str, int c);
 
47
int strloc1     (char *str, int c);     /* char not escaped */
 
48
int stuloc      (char *str, int c);
 
49
int strbloc     (char *str, int c);
 
50
int stubloc     (char *str, int c);
 
51
 
 
52
int strskip     (char *str, int c);
 
53
int stuskip     (char *str, int c);
 
54
int strbskip    (char *str, int c);
 
55
int stubskip    (char *str, int c);
 
56
 
 
57
int strline_    (char *source, int linesize, unsigned char mask, 
 
58
                        unsigned char *table);
 
59
 
 
60
/*======================================================================
 
61
 *                      Scan / Span Functions
 
62
 *======================================================================*/
 
63
 
 
64
int strspan_    (char *source, unsigned char mask, unsigned char *table);
 
65
int strbspan_   (char *source, unsigned char mask, unsigned char *table);
 
66
 
 
67
int strspans    (char *source, char *matching_list);
 
68
int stuspans    (char *source, char *matching_list);
 
69
int strbspans   (char *source, char *matching_list);
 
70
int stubspans   (char *source, char *matching_list);
 
71
 
 
72
int strscan_    (char *source, unsigned char mask, unsigned char *table);
 
73
int strbscan_   (char *source, unsigned char mask, unsigned char *table);
 
74
 
 
75
int strscans    (char *source, char *matching_list);
 
76
int strscan1    (char *source, char *matching_list);
 
77
int stuscans    (char *source, char *matching_list);
 
78
int strbscans   (char *source, char *matching_list);
 
79
int stubscans   (char *source, char *matching_list);
 
80
 
 
81
int strset      (unsigned char *generated_table, char *list);
 
82
int stuset      (unsigned char *generated_table, char *list);
 
83
 
 
84
 
 
85
/*======================================================================
 
86
 *                      Comparison macros
 
87
 *======================================================================*/
 
88
 
 
89
int strcomp     (char *str1, char *str2);
 
90
int stucomp     (char *str1, char *str2);
 
91
 
 
92
int strmatch    (char *str1, char *str2);
 
93
int stumatch    (char *str1, char *str2);
 
94
 
 
95
int strindex    (char *source, char *substring);
 
96
int stuindex    (char *source, char *substring);
 
97
 
 
98
int stritem     (char *source, char *item, char *list_of_seperators);
 
99
int stuitem     (char *source, char *item, char *list_of_seperators);
 
100
 
 
101
/*======================================================================
 
102
 *                      Conversion Function
 
103
 *======================================================================*/
 
104
 
 
105
int strupper    (char *str);
 
106
int strlower    (char *str);
 
107
int strcase     (char *str);
 
108
 
 
109
int strsetr     (unsigned char *table, char *from,  char *to);
 
110
 
 
111
int strtr_      (char *dest, char *source, unsigned char *table);
 
112
int strtrs      (char *dest, char *source, char *to_convert, char *converted);
 
113
 
 
114
int strred_     (char *str, unsigned char mask, unsigned char *table);
 
115
int strred      (char *str);
 
116
int strred1     (char *str, char escape);
 
117
 
 
118
int strdel_     (char *str, unsigned char mask, unsigned char *table);
 
119
 
 
120
int ed_tab      (char *dest, int desst_size, char *source, int source_len, 
 
121
                int tab_len);
 
122
 
 
123
/*======================================================================
 
124
 *              Compute Length of Token (str2)
 
125
 *======================================================================*/
 
126
int stkid       (char *str);            /* Identifier   */
 
127
int stkint      (char *str);            /* Integer      */
 
128
int stknum      (char *str);            /* Numeric      */
 
129
int stkstr      (char *str);            /* Quoted str   */
 
130
int stkcomment  (char *str);            /* / * ... * /  */
 
131
 
 
132
 
 
133
/*======================================================================
 
134
 *                      Macros
 
135
 *======================================================================*/
 
136
 
 
137
#define strdiff(s1,s2)                  strcomp(s1,s2)
 
138
#define studiff(s1,s2)                  stucomp(s1,s2)
 
139
#define strblank(dest,len)              strfill(dest,len,' ')
 
140
 
 
141
#define strline(s,lmax)                 strline_(s,lmax,_SPACE_,main_ascii)
 
142
#define strspan(s,mask)                 strspan_(s,mask,main_ascii)
 
143
#define strbspan(s,mask)                strbspan_(s,mask,main_ascii)
 
144
#define strscan(s,mask)                 strscan_(s,mask,main_ascii)
 
145
#define strbscan(s,mask)                strbscan_(s,mask,main_ascii)
 
146
#define strdel(s,mask)                  strdel_(s, mask, main_ascii)
 
147
 
 
148
#define strfree(s)                      mm_free(s)
 
149
#define strsave(s)                      mm_ssave(s)
 
150
 
 
151
#define stripspaces(s)                  s[1+strbspan(s,_SPACE_)] = EOS   \
 
152
                                        /* Remove Trailing Blanks       */
 
153
 
 
154
#endif