OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
analyse_comment.c
Go to the documentation of this file.
1//Copyright> OpenRadioss
2//Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3//Copyright>
4//Copyright> This program is free software: you can redistribute it and/or modify
5//Copyright> it under the terms of the GNU Affero General Public License as published by
6//Copyright> the Free Software Foundation, either version 3 of the License, or
7//Copyright> (at your option) any later version.
8//Copyright>
9//Copyright> This program is distributed in the hope that it will be useful,
10//Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11//Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//Copyright> GNU Affero General Public License for more details.
13//Copyright>
14//Copyright> You should have received a copy of the GNU Affero General Public License
15//Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16//Copyright>
17//Copyright>
18//Copyright> Commercial Alternative: Altair Radioss Software
19//Copyright>
20//Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21//Copyright> software under a commercial license. Contact Altair to discuss further if the
22//Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23#include <string.h> /* strlen strcat */
24#include <stdio.h> /* sprintf */
25
26#include "analyse_define.h" /* ANALYSE_SIZE_OF_LINE
27 ANALYSE_ERROR_TITLE ANALYSE_ERROR_DESCRIPTION ANALYSE_CHECK_GROUP ANALYSE_CHECK */
28
29#include "analyse.h" /* analyse_get_datas */
30
31#include "analyse_string.h" /* analyse_convert_int_to_string */
32#include "analyse_memory.h" /* analyse_malloc */
33#include "analyse_error.h" /* analyse_error_info_t */
34#include "analyse_check.h" /* analyse_check_t analyse_check_group_t */
35
36#include "analyse_comment.h"
37
38void analyse_add_comment(int object_type, void *object, analyse_comment_t *comment)
39{
41
42 switch(object_type)
43 {
45 scan = ((analyse_error_info_t *)object)->title;
46 break;
47
49 scan = ((analyse_error_info_t *)object)->description;
50 break;
51
53 scan = ((analyse_check_group_t *)object)->title;
54 break;
55
56 case ANALYSE_CHECK:
57 scan = ((analyse_check_t *)object)->title;
58 break;
59
60 default:
61 return;
62 }
63
64 if (scan == NULL)
65 {
66 scan = comment;
67 scan->prev=NULL;
68 scan->next = NULL;
69
70 switch(object_type)
71 {
73 ((analyse_error_info_t *)object)->title = scan;
74 break;
75
77 ((analyse_error_info_t *)object)->description = scan ;
78 break;
79
81 ((analyse_check_group_t *)object)->title = scan;
82 break;
83
84 case ANALYSE_CHECK:
85 ((analyse_check_t *)object)->title = scan;
86 break;
87
88 default:
89 return;
90 }
91 }
92 else
93 {
94 while (scan->next != NULL)
95 {
96 scan = scan->next;
97 }
98
99 scan->next = comment;
100 comment->prev = scan;
101 comment->next = NULL;
102 }
103}
104
105analyse_comment_t * analyse_get_right_comment(analyse_comment_t *start_comment, int language, int default_language)
106{
107 analyse_comment_t *scan_comment;
108
109 scan_comment = start_comment;
110 while( (scan_comment->language != language) &&
111 (scan_comment->next != NULL))
112 {
113 scan_comment = scan_comment->next;
114 }
115
116 if ( scan_comment->language != language)
117 {
118 scan_comment = start_comment;
119 while( (scan_comment->language != default_language) &&
120 (scan_comment->next != NULL))
121 {
122 scan_comment = scan_comment->next;
123 }
124
125 if ( scan_comment->language != default_language)
126 return start_comment;
127 else
128 return scan_comment;
129 }
130 else
131 {
132 return scan_comment;
133 }
134}
135
136
137char *analyse_fill_description(int object_type, char *description)
138{
139 int length, nb;
140
141 int int_step=0;
142 int float_step=0;
143
144 char *scan_in_description;
145 char *scan_out_description;
146 char *final_description;
147
148 int nb_int;
149 int *tab_int=NULL;
150
151 int nb_float;
152 float *tab_float=NULL;
153
154 char line[ANALYSE_SIZE_OF_LINE];
155
156 int final_description_length;
157 line[0]='\0';
158
159 analyse_get_datas(object_type, &nb_int, &tab_int, &nb_float, &tab_float);
160
161 length = strlen(description);
162
163 /* Cls41k14 length = length + nb_int*6 + nb_float*10 + 1; */
164 length = length + nb_int*4*((int)sizeof(int)) + nb_float*4*((int)sizeof(float)) + 1;
165
166 final_description_length=length;
167 final_description = (char *)analyse_malloc(length*sizeof(char));
168
169 scan_in_description = description;
170 scan_out_description = final_description;
171
172 *(scan_out_description)='\0';
173
174 while((*scan_in_description) != '\0')
175 {
176 if ((*scan_in_description) == '%')
177 {
178 if ((*(scan_in_description+1)) == 'd')
179 {
180 if (int_step < nb_int)
181 {
182 sprintf(line, "%d", *(tab_int+int_step));
183 int_step++;
184 }
185 }
186 else if ((*(scan_in_description+1)) == 'f')
187 {
188 if (float_step < nb_float)
189 {
190 /* Cls41k14 sprintf(line, "%f", *(tab_float+float_step)); */
191 sprintf(line, "%g", *(tab_float+float_step));
192 float_step++;
193 }
194 }
195 else if ((*(scan_in_description+1)) == 's')
196 {
197 if (int_step < nb_int)
198 {
199 length = *(tab_int+int_step);
200 int_step++;
201 }
202 else
203 {
204 length = 0;
205 }
206
207 if ( ( length != 0) && ((nb_int-int_step) >= length))
208 {
209 if ( length >= ANALYSE_SIZE_OF_LINE)
211 else
212 nb=length;
213
214 analyse_convert_int_to_string(nb, tab_int+int_step, line);
215 int_step = int_step+length;
216 }
217 }
218
219 length = strlen(line);
220 #ifdef _WIN64
221 strcat_s(final_description,final_description_length, line);
222 #else
223 strcat(final_description, line);
224 #endif
225 line[0]='\0';
226
227 scan_out_description = scan_out_description + length;
228
229 scan_in_description = scan_in_description +2;
230 }
231 else
232 {
233 *scan_out_description=*scan_in_description;
234 *(scan_out_description+1)='\0';
235 scan_out_description=scan_out_description+1;
236
237 scan_in_description = scan_in_description +1;
238 }
239 }
240
241 return final_description;
242}
243
int analyse_get_datas(int name_id, int *nb_int, int **tab_int, int *nb_float, float **tab_float)
Definition analyse.c:364
struct analyse_check_group_s analyse_check_group_t
struct analyse_check_s analyse_check_t
void analyse_add_comment(int object_type, void *object, analyse_comment_t *comment)
analyse_comment_t * analyse_get_right_comment(analyse_comment_t *start_comment, int language, int default_language)
char * analyse_fill_description(int object_type, char *description)
struct analyse_comment_s analyse_comment_t
#define ANALYSE_CHECK
#define ANALYSE_ERROR_DESCRIPTION
#define ANALYSE_CHECK_GROUP
#define ANALYSE_ERROR_TITLE
#define ANALYSE_SIZE_OF_LINE
struct analyse_error_info_s analyse_error_info_t
void * analyse_malloc(size_t size)
void analyse_convert_int_to_string(int nb_int, int *tab_int, char *message)
struct analyse_comment_s * next
struct analyse_comment_s * prev