OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
analyse_string.h File Reference

Go to the source code of this file.

Functions

char * analyse_string_strset (char *name, int ch)
char * analyse_string_strrev (char *name)
char * analyse_string_fit_start (char *name)
char * analyse_string_fit_end (char *name)
char * analyse_string_fit_start_end (char *name)
char * analyse_string_fit_all (char *name)
int analyse_string_length_brackett (char *string, int n1, int n2)
void analyse_convert_int_to_string (int nb_int, int *tab_int, char *message)
void analyse_convert_string_to_int (char *message, int *nb_int, int **tab_int)

Function Documentation

◆ analyse_convert_int_to_string()

void analyse_convert_int_to_string ( int nb_int,
int * tab_int,
char * message )

Definition at line 202 of file analyse_string.c.

203{
204 int i;
205
206 if ( ( message != NULL ) &&
207 ( tab_int != NULL ))
208 {
209 for(i=0; i<nb_int; i++)
210 {
211 message[i]=(char)(tab_int[i]);
212 }
213
214 message[nb_int]='\0';
215 }
216 else
217 {
218 if ( message != NULL ) message[0]='\0';
219 }
220}

◆ analyse_convert_string_to_int()

void analyse_convert_string_to_int ( char * message,
int * nb_int,
int ** tab_int )

Definition at line 224 of file analyse_string.c.

225{
226 int i;
227
228 if ( ( message != NULL ) &&
229 ( nb_int != NULL ) &&
230 ( tab_int != NULL ))
231 {
232 *nb_int=strlen(message);
233 (*tab_int) = (int *)analyse_malloc((*nb_int)*sizeof(int));
234
235 for(i=0; i<(*nb_int); i++)
236 {
237 (*tab_int)[i] = (int)message[i];
238 }
239 }
240 else
241 {
242 if ( nb_int != NULL) *nb_int = 0;
243 if ( tab_int != NULL) *tab_int = NULL;
244 }
245}
void * analyse_malloc(size_t size)

◆ analyse_string_fit_all()

char * analyse_string_fit_all ( char * name)

Definition at line 134 of file analyse_string.c.

135{
136 char *blank;
137
138 if (name != NULL)
139 {
140 blank = strchr(name,' ');
141
142 while ( blank != NULL )
143 {
144 strcpy(blank,blank+1);
145 blank = strchr(name,' ');
146 }
147 }
148 return name;
149}

◆ analyse_string_fit_end()

char * analyse_string_fit_end ( char * name)

Definition at line 97 of file analyse_string.c.

98{
99 int length;
100
101 if ( name != NULL)
102 {
103 length = strlen(name);
104
105 while ( ( length > 0) && ( *(name+length-1) == ' ' ) )
106 {
107 *(name+length-1)= '\0';
108 length = length -1;
109 }
110
111 }
112 return name;
113}

◆ analyse_string_fit_start()

char * analyse_string_fit_start ( char * name)

Definition at line 81 of file analyse_string.c.

82{
83 if (name != NULL)
84 {
85 while ( (*name) == ' ')
86 {
87 strcpy(name,name+1);
88 }
89 }
90 return name;
91}

◆ analyse_string_fit_start_end()

char * analyse_string_fit_start_end ( char * name)

Definition at line 120 of file analyse_string.c.

121{
122 if (name != NULL)
123 {
126 }
127 return name;
128}
char * analyse_string_fit_start(char *name)
char * analyse_string_fit_end(char *name)

◆ analyse_string_length_brackett()

int analyse_string_length_brackett ( char * string,
int n1,
int n2 )

Definition at line 155 of file analyse_string.c.

156{
157 int length = 0 ;
158 int buf = 0 ;
159 char *buf_string = NULL ;
160 char *pos = NULL ;
161
162 if (strlen(string)==0) return -1 ;
163 if (n1-n2 > 0)
164 {
165 buf = n1 ;
166 n1 = n2 ;
167 n2 = buf ;
168 }
169
170 buf_string = (char *)analyse_calloc(strlen(string)+1, sizeof(char)) ;
171
172 strcpy(buf_string, string) ;
173 pos = strrchr(buf_string, '/') ;
174 if (pos != NULL)
175 {
176 pos = pos + 1 ;
177 length = strlen(pos) ;
178 }
179 else
180 {
181 length = strlen(buf_string) ;
182 }
183
184 if (length < n1)
185 {
186 analyse_free(buf_string) ;
187 return -1 ;
188 }
189 if (length > n2)
190 {
191 analyse_free(buf_string) ;
192 return 1 ;
193 }
194
195 analyse_free(buf_string) ;
196 return 0 ;
197}
void * analyse_calloc(size_t nitems, size_t size)
void analyse_free(void *block)

◆ analyse_string_strrev()

char * analyse_string_strrev ( char * name)

Definition at line 53 of file analyse_string.c.

54{
55 char *reverse;
56 int length,i;
57
58 if ( name != NULL)
59 {
60 length = strlen(name);
61 reverse = (char *) analyse_malloc( ( length)*sizeof(char));
62
63 for ( i=0; i<length; i++)
64 {
65 reverse[i]=name[length-1-i];
66 }
67
68 for ( i=0; i<length; i++)
69 {
70 name[i]=reverse[i];
71 }
72
73 analyse_free(reverse);
74 }
75 return name;
76}

◆ analyse_string_strset()

char * analyse_string_strset ( char * name,
int ch )

Definition at line 32 of file analyse_string.c.

33{
34 int length,i;
35
36 if ( name != NULL)
37 {
38 length = strlen(name);
39
40 for ( i=0; i<length; i++)
41 {
42 name[i]= ch;
43 }
44
45 }
46 return name;
47}