]>
Commit | Line | Data |
---|---|---|
48864d28 FM |
1 | /*! \file util.c |
2 | \brief Various useful functions. | |
3 | */ | |
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | /*! \var static char mtab1[12][4]; | |
10 | The list of the months. | |
11 | */ | |
12 | ||
13 | ||
14 | ||
15 | ||
16 | ||
17 | /*! \fn int getword(char *word, int limit, char *line, int stop) | |
18 | ||
19 | Extract one "word" from the text line and remove it from the text line. The word's boundary is defined | |
20 | by the \a stop character. If multiple stop characters are found after the word, only the first one is | |
21 | removed. Therfore, passing the line buffer again to the function will remove the next word in a column | |
22 | like manner. | |
23 | ||
24 | \param word The buffer to store the extracted word. | |
25 | \param limit The size of the buffer. If the stop character isn't found before that limit is reached, | |
26 | the function displays an error message and returns an error code. | |
27 | \param line The text line from which the word must be extracted. | |
28 | \param stop The character indicating the end of the word. | |
29 | ||
30 | \retval 0 The word is extracted. | |
31 | \retval -1 The stop character was not found before the limit or the end of the string is reached. | |
32 | ||
33 | */ | |
34 | ||
35 | ||
36 | ||
37 | ||
38 | ||
39 | /*! \fn int getword_multisep(char *word, int limit, char *line, int stop) | |
40 | ||
41 | Extract one "word" from the text line and remove it from the text line. The word's boundary is defined | |
42 | by the \a stop character. All the stop characters following the word are removed too. Therefore, passing | |
43 | the line buffer again to the function will remove words even if they are separated by multiple stop | |
44 | characters. | |
45 | ||
46 | \param word The buffer to store the extracted word. | |
47 | \param limit The size of the buffer. If the stop character isn't found before that limit is reached, | |
48 | the function displays an error message and returns an error code. | |
49 | \param line The text line from which the word must be extracted. | |
50 | \param stop The character indicating the end of the word. | |
51 | ||
52 | \retval 0 The word is extracted. | |
53 | \retval -1 The stop character was not found before the limit or the end of the string is reached. | |
54 | ||
55 | */ | |
56 | ||
57 | ||
58 | ||
59 | ||
60 | ||
61 | /*! \fn int getword3(char *word, int limit, char *line, int stop) | |
62 | ||
63 | This function is now identical to getword(). | |
64 | ||
65 | \param word The buffer to store the extracted word. | |
66 | \param limit The size of the buffer. If the stop character isn't found before that limit is reached, | |
67 | the function displays an error message and returns an error code. | |
68 | \param line The text line from which the word must be extracted. | |
69 | \param stop The character indicating the end of the word. | |
70 | ||
71 | \retval 0 The word is extracted. | |
72 | \retval -1 The stop character was not found before the limit or the end of the string is reached. | |
73 | ||
74 | */ | |
75 | ||
76 | ||
77 | ||
78 | ||
79 | /*! \fn long long int my_atoll (const char *nptr) | |
80 | ||
81 | Convert a string into a long long. | |
82 | ||
83 | \param nptr The string containing the number to convert. | |
84 | ||
85 | \return The number found in the string or zero if no number was found. | |
86 | ||
87 | */ | |
88 | ||
89 | ||
90 | ||
91 | ||
92 | ||
93 | /*! \fn void my_mkdir(const char *name) | |
94 | ||
95 | Create the directory and all the non existing parent directories. | |
96 | ||
97 | \param name The absolute directory to create. | |
98 | ||
99 | */ | |
100 | ||
101 | ||
102 | ||
103 | ||
104 | ||
105 | /*! \fn void my_lltoa(unsigned long long int n, char s[], int len) | |
106 | ||
107 | Format a long long into a string. | |
108 | ||
109 | \param n The number to format. | |
110 | \param s The buffer to write the number. | |
111 | \param len The minimum number of digits to format in the output. If the formatted | |
112 | number is less than this length, it is padded with zeros. | |
113 | ||
114 | */ | |
115 | ||
116 | ||
117 | ||
118 | ||
119 | ||
120 | /*! \fn void builddia(char *dia, const char *mes, const char *ano, const char *df, char *wdata) | |
121 | ||
122 | Format a date into a YYYYMMDD string and into a DD/MM/YYYY or MM/DD/YYYY string depending on the value | |
123 | of the \a df parameter. | |
124 | ||
125 | \param dia The day of the date on input. It is replaced by the date in the human readable format. | |
126 | \param mes The name of the month as spelled in ::mtab1. If the month is invalid the output dates are | |
127 | set to month 13. | |
128 | \param ano The year. | |
129 | \param df The format for the human readable date. If the string start with a 'u', it is formatted as | |
130 | MM/DD/YYYY. Any other character format it as DD/MM/YYYY. | |
131 | \param wdata A buffer to store the machine formatted date YYYYMMDD. | |
132 | ||
133 | */ | |
134 | ||
135 | ||
136 | ||
137 | ||
138 | ||
139 | /*! \fn void buildymd(const char *dia, const char *mes, const char *ano, char *wdata) | |
140 | Convert the date into a machine format YYYYMMDD. | |
141 | ||
142 | \param dia The day. | |
143 | \param mes The name of the month as spelled in ::mtab1. If the month is invalid, the output date | |
144 | is set to month 13. | |
145 | \param ano The year. | |
146 | \param wdata The buffer to format the date. | |
147 | */ | |
148 | ||
149 | ||
150 | ||
151 | ||
152 | ||
153 | /*! \fn void conv_month(char *month) | |
154 | Convert the month's name into its two digits numerical equivalent. | |
155 | ||
156 | \param month The name of the month as spelled in ::mtab1. It is replaced by the month number on | |
157 | two digits with a padding zero. If the month name is not in ::mtab1, the string is not replaced. | |
158 | */ | |
159 | ||
160 | ||
161 | ||
162 | ||
163 | ||
164 | /*! \fn void conv_month_name(char *month) | |
165 | Convert a month number into a name. | |
166 | ||
167 | \param month The number of the month. It is replaced by the name of the month from ::mtab1 unless | |
168 | the month number is not between 1 and 12. | |
169 | */ | |
170 | ||
171 | ||
172 | ||
173 | ||
174 | ||
175 | /*! \fn void name_month(char *month,int month_len) | |
176 | Get the name of the month according to the language file selected by the user. | |
177 | ||
178 | \param month The number of the month. It is replaced by the month's name if the number is between | |
179 | 1 and 12 or by the name of December if the number is invalid. | |
180 | \param month_len The size of the \a month buffer. | |
181 | ||
182 | */ | |
183 | ||
184 | ||
185 | ||
186 | ||
187 | ||
188 | /*! \fn void fixper(char *tbuf, char *period, const char *duntil) | |
189 | Given a date in the form YYYYMMDD, the function format it as DD/mmm/YYYY | |
190 | or mmm/DD/YYYY according to the value of the ::df global variable and append | |
191 | it to \a period. | |
192 | ||
193 | \param tbuf Unused. | |
194 | \param period The string to which the formated date is appended. | |
195 | \param duntil The date to format. | |
196 | ||
197 | */ | |
198 | ||
199 | ||
200 | ||
201 | ||
202 | ||
203 | /*! \fn void debuga(const char *msg,...) | |
204 | Write a debug message to stderr. The message is prefixed by "SARG:" to identify its origin. | |
205 | ||
206 | \param msg The printf like message to format. | |
207 | \param ... The arguments to format in the message. | |
208 | ||
209 | */ | |
210 | ||
211 | ||
212 | ||
213 | ||
214 | ||
215 | /*! \fn void debugaz(const char *head, const char *msg) | |
216 | Write a debug message to stderr with the value of a parameter. The message is prefixed by "SARG: (util)". | |
217 | ||
218 | \param head The name of the parameter. | |
219 | \param msg The value of the parameter. | |
220 | */ | |
221 | ||
222 | ||
223 | ||
224 | ||
225 | ||
226 | /*! \fn void fixip(char *ip) | |
227 | Toggle the IP address format from nnn.nnn.nnn.nnn to nnn_nnn_nnn_nnn. Only the first three | |
228 | occurences of the . or _ are replaced. That limitation is imposed by a will to mimic as close | |
229 | as possible the previous code based on strings copying. | |
230 | ||
231 | \param ip The IP address to change. It is replaced in place. | |
232 | ||
233 | */ | |
234 | ||
235 | ||
236 | ||
237 | ||
238 | ||
239 | /*! \fn char *fixnum(long long int value, int n) | |
240 | Rewrite a number to make it more readable. The number may be written | |
241 | with the suffix K, M, G or T depending on its magnitude or the digits | |
242 | are grouped by three and separated by a dot or a comma. | |
243 | ||
244 | \param value The number to format. | |
245 | \param n If the number is abreviated and this parameter is true then append | |
246 | the suffix K, M, G or T if necessary. If it is zero, the number is shortened | |
247 | but no suffix is written. | |
248 | ||
249 | \return A static buffer containing the formatted number. It is overwritten on the next | |
250 | call of this function. | |
251 | ||
252 | */ | |
253 | ||
254 | ||
255 | ||
256 | ||
257 | ||
258 | /*! \def MAXLEN_FIXNUM | |
259 | The size of the buffer to format a number in fixnum(). | |
260 | */ | |
261 | ||
262 | ||
263 | ||
264 | ||
265 | ||
266 | /*! \fn char *fixnum2(long long int value, int n) | |
267 | Format a number by grouping the digits by three and separating the groups by | |
268 | a dot or a comma. | |
269 | */ | |
270 | ||
271 | ||
272 | ||
273 | ||
274 | /*! \def MAXLEN_FIXNUM2 | |
275 | The size of the buffer to format a number in fixnum2(). | |
276 | */ | |
277 | ||
278 | ||
279 | ||
280 | ||
281 | ||
282 | /*! \fn void buildhref(char * href) | |
283 | Replace the path given as argument by the first part of a HTML tag to link to the given | |
284 | directory (the A tag). More precisely, the argument is replaced by <a href=" followed by the given \a href. | |
285 | ||
286 | \param href The directory to replace by a HTML A tag with the open HREF to it. | |
287 | ||
288 | */ | |
289 | ||
290 | ||
291 | ||
292 | ||
293 | ||
294 | /*! \fn char *buildtime(long long int elap) | |
295 | Write the elapsed time given in milliseconds as a string in the format HH:MM:SS. | |
296 | ||
297 | \param elap The elapsed time in milliseconds. | |
298 | ||
299 | \return A static buffer with the formatted time. It is valid until the function is called again. | |
300 | */ | |
301 | ||
302 | ||
303 | ||
304 | ||
305 | ||
306 | /*! \fn void obtdate(const char *dirname, const char *name, char *data) | |
307 | Get the date stored in the <tt>sarg-date</tt> file of a directory with the connection data. | |
308 | ||
309 | \param dirname The directory to look for the connection directory. | |
310 | \param name The name of the directory whose <tt>sarg-date</tt> file must be read. | |
311 | \param data The buffer to store the content of the file. It must be more than 80 | |
312 | bytes long. | |
313 | */ | |
314 | ||
315 | ||
316 | ||
317 | ||
318 | ||
319 | /*! \fn void obtuser(const char *dirname, const char *name, char *tuser) | |
320 | Get the number of entries stored in a connection data directory. The number is read from | |
321 | the <tt>sarg-users</tt> file of the connection data's directory. | |
322 | ||
323 | \param dirname The directory to look for the connection directory. | |
324 | \param name The name of the connection directory whose <tt>sarg-users</tt> file must be read. | |
325 | \param tuser The buffer to store the content of the file. It must be more than 20 | |
326 | bytes long. | |
327 | */ | |
328 | ||
329 | ||
330 | ||
331 | ||
332 | ||
333 | /*! \fn void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media) | |
334 | Count the total size transfered in a connection directory and compute the average number of bytes | |
335 | per entry. | |
336 | ||
337 | \param dirname The directory to look for the connection directory. | |
338 | \param name The name of the connection directory whose <tt>sarg-general</tt> file must be read. | |
339 | \param tbytes A buffer to store the total number of bytes from this connection. | |
340 | \param tuser The number of entries in the connection directory. | |
341 | \param media A buffer to store the average number of bytes per entry. | |
342 | */ | |
343 | ||
344 | ||
345 | ||
346 | ||
347 | ||
348 | /*! \fn void gperiod(const char *dirname, const char *period) | |
349 | Write the current period for the connection directory in a file named <tt>sarg-period</tt> | |
350 | in the connection directory. | |
351 | ||
352 | \param dirname The connection directory to which the period must be written. | |
353 | \param period The period to write in the file. | |
354 | */ | |
355 | ||
356 | ||
357 | ||
358 | ||
359 | /*! \fn void vrfydir(const char *dir, const char *per1, const char *addr, const char *site, const char *us, const char *form) | |
360 | Create a directory to generate a report for the specified connection data and populate it with the a <tt>sarg-date</tt> file | |
361 | containing the current date. | |
362 | ||
363 | The function also create an <tt>images</tt> directory in \a dir and copy all the files from the <tt>SYSCONFDIR/images</tt> into | |
364 | that directory. | |
365 | ||
366 | \param dir The output directory to fill. | |
367 | \param per1 The date range in the form: YYYYMMMDD-YYYYMMMDD or DDMMMYYYY-DDMMMYYYY depending on the value of | |
368 | ::IndexTree. | |
369 | \param addr The ip address or host name to which the report is limited. If the string is empty, all the addresses are accepted. | |
370 | \param site The destination site to which the report is limited. If the string is empty, all the sites are accepted. | |
371 | \param us The user to whom the report is limited. It is an empty string if all the users are accepted. | |
372 | \param form The email address to which the report is sent. It is currently unused. | |
373 | ||
374 | */ | |
375 | ||
376 | ||
377 | ||
378 | ||
379 | ||
380 | /*! \fn void strip_latin(char *line) | |
381 | Remove any HTML entity from the line. A HTML entity starts with an ampersand and end at the next | |
382 | semicolon. | |
383 | ||
384 | \param line The text whose html entities are to be removed. | |
385 | */ | |
386 | ||
387 | ||
388 | ||
389 | ||
390 | ||
391 | /*! \fn void zdate(char *ftime, const char *DateFormat) | |
392 | Format the current date and time according to the date format. | |
393 | ||
394 | \param ftime The buffer to format the date. It must be at least 127 bytes long. | |
395 | \param DateFormat The format of the date. It can be: | |
396 | \arg u to format as mmm/dd/YYYY HH:MM | |
397 | \arg e to format as dd/mmm/YYYY HH:MM | |
398 | \arg w to format as WW-HH-MM where WW is the week number in the range 00 to 53. | |
399 | */ | |
400 | ||
401 | ||
402 | ||
403 | ||
404 | ||
405 | /*! \fn char *fixtime(long int elap) | |
406 | Format a "time" into a size or a time formatted as HH:MM:SS. | |
407 | ||
408 | \param elap The "time" to format in milliseconds if it is a time and into bytes if it is a size. | |
409 | ||
410 | \return The formatted time. | |
411 | ||
412 | \bug If the elapsed time is less than 1000ms, the time is formated with the milliseconds as the seconds. | |
413 | ||
414 | \todo Review this function and documentation based on the calls made to it and the arguments passed by the callers. | |
415 | */ | |
416 | ||
417 | ||
418 | ||
419 | ||
420 | ||
421 | /*! \fn void date_from(char *date, char *dfrom, char *duntil) | |
422 | Split a date range into a date from and a date until. If the date range | |
423 | is not a range but just a single date, it is duplicated to make a range out | |
424 | of it. | |
425 | ||
426 | \param date The date range to split in the form <tt>from-until</tt>. If it is a single date, | |
427 | it is transformed into a range like <tt>date-date</tt>. Each date is in the form DD/MM/YYYY. | |
428 | \param dfrom A buffer to write the start date in the form YYYYMMDD. | |
429 | \param duntil A buffer to write the end date in the form YYYYMMDD. | |
430 | */ | |
431 | ||
432 | ||
433 | ||
434 | ||
435 | ||
436 | /*! \fn char *strlow(char *string) | |
437 | Convert a string to all lowercases. | |
438 | ||
439 | \param string The string to convert. | |
440 | ||
441 | \return A pointer to the string passed as argument. | |
442 | */ | |
443 | ||
444 | ||
445 | ||
446 | ||
447 | ||
448 | /*! \fn char *strup(char *string) | |
449 | Convert a string to all uppercases. | |
450 | ||
451 | \param string The string to convert. | |
452 | ||
453 | \return A pointer to the string passed as argument. | |
454 | */ | |
455 | ||
456 | ||
457 | ||
458 | ||
459 | ||
460 | /*! \fn void subs(char *str, int size, char *from, char *to) | |
461 | Replace one occurence of the string \a from by \a to in the string \a str. | |
462 | ||
463 | \param str The string in which to replace the text. | |
464 | \param size The size of the string buffer to detect a buffer overflow if \a to is longer than \a from. | |
465 | \param from The fragment of text to replace. | |
466 | \param to The text to replace instead of \a from. | |
467 | */ | |
468 | ||
469 | ||
470 | ||
471 | ||
472 | ||
473 | /*! \fn void removetmp(const char *outdir) | |
474 | Remove the file <tt>sarg-period</tt> from the output directory and purge the file <tt>sarg-general</tt> from | |
475 | all the lines but the total. | |
476 | ||
477 | \param outdir The output directory to purge. | |
478 | */ | |
479 | ||
480 | ||
481 | ||
482 | ||
483 | ||
484 | /*! \fn void load_excludecodes(const char *ExcludeCodes) | |
485 | Load the list of the HTTP codes to exclude from the report. There must be one code per line. | |
486 | Any trailing space is removed and there is no provision for comments. | |
487 | ||
488 | \param ExcludeCodes The name of the file to load. | |
489 | ||
490 | This function allocate the memory to store the codes and it must be freed by a call to | |
491 | free_excludecodes(). | |
492 | */ | |
493 | ||
494 | ||
495 | ||
496 | ||
497 | ||
498 | /*! \fn void free_excludecodes(void) | |
499 | Free the memory allocated by load_excludecodes(). | |
500 | */ | |
501 | ||
502 | ||
503 | ||
504 | ||
505 | /*! \fn int vercode(const char *code) | |
506 | Check if the code is contained in the exclusion list loaded by load_excludecodes(). | |
507 | ||
508 | \param code The HTTP code to test. | |
509 | ||
510 | \retval 1 The code is excluded. | |
511 | \retval 0 The code is not excluded. | |
512 | */ | |
513 | ||
514 | ||
515 | ||
516 | ||
517 | ||
518 | /*! \fn void fixnone(char *str) | |
519 | Find if the string is the word none and clear the string if it matches. The function | |
520 | tolerates the trailing spaces and tabulations. | |
521 | ||
522 | \param str The text to test for the word "none". | |
523 | */ | |
524 | ||
525 | ||
526 | ||
527 | ||
528 | ||
2357ef77 FM |
529 | /*! \fn void fixendofline(char *str) |
530 | Remove the control codes and spaces at the end of the line. That is, it remove any ASCII | |
531 | code less than or equal to 0x20. | |
532 | ||
533 | \param str The string to truncate. | |
534 | */ | |
535 | ||
536 | ||
537 | ||
538 | ||
48864d28 FM |
539 | /*! \fn int testvaliduserchar(const char *user) |
540 | Tell if the user string contains any invalid character in a user name. The list | |
541 | of the invalid characters is defined by ::UserInvalidChar. | |
542 | ||
543 | \param user The user name to test. | |
544 | ||
545 | \retval 1 The string contains at least one invalid character. | |
546 | \retval 0 The string is valid. | |
547 | */ | |
548 | ||
549 | ||
550 | ||
551 | ||
552 | ||
553 | /*! \fn int compar( const void *a, const void *b ) | |
554 | Compare two integers for bsearch. | |
555 | ||
556 | \param a A pointer to the first integer. | |
557 | \param b A pointer to the second integer. | |
558 | ||
559 | \retval 1 If a > b. | |
560 | \retval 0 If a == b. | |
561 | \retval -1 If a < b. | |
562 | */ | |
563 | ||
564 | ||
565 | ||
566 | ||
567 | ||
568 | /*! \fn int getnumlist( char *buf, numlist *list, const int len, const int maxvalue ) | |
569 | Get a comma separated list of numbers and split them into separate values taking into account | |
570 | that no value may be greater than a maximum. If a value is in fact a range, it is expended. | |
571 | ||
572 | Any duplicate value is removed. | |
573 | ||
574 | \param buf The string with the list of numbers. | |
575 | \param list Where to store the numbers. | |
576 | \param len The size of the list. | |
577 | \param maxvalue The maximum value allowed in the list. | |
578 | ||
579 | \retval 0 No error. | |
580 | \retval -1 Error detected. | |
581 | */ | |
582 | ||
583 | ||
584 | ||
585 | ||
586 | ||
587 | /*! \fn void show_info(FILE *fp_ou) | |
588 | Write the HTML formatted message to indicate the version of sarg that produced | |
589 | the report and when the report was generated. | |
590 | ||
591 | \param fp_ou The HTML file to which the identification block must be appended. | |
592 | */ | |
593 | ||
594 | ||
595 | ||
596 | ||
597 | ||
598 | /*! \fn void show_sarg(FILE *fp_ou, const char *ind) | |
599 | Write the header of the report to tell that it was generated by sarg. | |
600 | ||
601 | \param fp_ou The handle of the HTML file. | |
602 | \param ind The path to use to have access to the images directory with the sarg logo. It is a succession of .. | |
603 | to move up until the root of the reports with the images directory. | |
604 | */ | |
605 | ||
606 | ||
607 | ||
608 | ||
609 | ||
610 | /*! \fn char *get_size(const char *path, const char *file) | |
611 | Get the size, in human readable form and kibibytes, of the content of a directory. | |
612 | ||
613 | \param path The path containing the directory to scan. | |
614 | \param file The last part of the path to the directory to scan. | |
615 | ||
616 | \return The size of the path. | |
617 | */ | |
618 | ||
619 | ||
620 | ||
621 | ||
622 | ||
623 | /*! \fn void write_html_header(FILE *fp_ou, const char * ind) | |
624 | Write the HTML header of a HTML report file. The DTD correspond to a | |
625 | transitional HTML version 4.01. The title of the document is taken from | |
626 | the global variable ::Title. | |
627 | ||
628 | \param fp_ou The file to which the HTML header is written. | |
629 | \param ind The path to pass to show_arg() to find the root directory where the | |
630 | images directory is. | |
631 | */ | |
632 | ||
633 | ||
634 | ||
635 | ||
636 | ||
637 | /*! \fn void baddata(void) | |
638 | Display an error message telling that sarg suspects an attempt to execute arbitrary code and terminate sarg. | |
639 | ||
640 | Any temporary file created by sarg is deleted. | |
641 | */ | |
642 | ||
643 | ||
644 | ||
645 | ||
646 | ||
647 | /*! \fn void url_module(const char *url, char *w2) | |
648 | Copy at most 254 bytes from the end of the URL or stops at the first /. | |
649 | ||
650 | \param url The URL to parse. | |
651 | \param w2 A buffer to store the copied portion of the URL. The buffer must | |
652 | be at least 255 characters long. | |
653 | */ | |
654 | ||
655 | ||
656 | ||
657 | ||
658 | ||
659 | /*! \fn void write_html_trailer(FILE *fp_ou) | |
660 | End the HTML file by closing the centered table that was opened by write_html_header(), writting | |
661 | the informations of show_info() and closing the body and html tag. After this function returns, the | |
662 | HTML file is complete and nothing should be written to it. | |
663 | ||
664 | \param fp_ou The HTML file to close. The file handle is not closed but you should not write anything | |
665 | to the file after this function returns. | |
666 | ||
667 | */ | |
668 | ||
669 | ||
670 | ||
671 | ||
672 | ||
673 | /*! \fn void version(void) | |
674 | Display the current version of sarg and terminate the program. | |
675 | */ | |
676 | ||
677 | ||
678 | ||
679 | ||
680 | ||
681 | /*! \fn char *get_param_value(const char *param,char *line) | |
682 | Get the value of a parameter formatted in the string as "param value" | |
683 | without the quotes. | |
684 | ||
685 | If the parameter name matches \a param, then the value following the parameter | |
686 | is returned. If it doesn't match, the function return NULL. | |
687 | ||
688 | The function is suitable to parse configuration files because it will ignore | |
689 | comments (anything but spaces and tabulations put before the parameter will make | |
690 | it unrecognized by this function) | |
691 | ||
692 | \param param The parameter name that must be found at the beginning of the line | |
693 | with possible spaces or tabulations before. | |
694 | \param line The text line to search for the parameter and it's value. | |
695 | ||
696 | \return The beginning of the value after the equal sign and with the possible | |
697 | spaces or tabulations removed. If the line doesn't start with the parameter name, | |
698 | the function returns NULL. | |
699 | ||
700 | */ | |
701 | ||
702 | ||
703 | ||
704 | ||
705 | ||
706 | /*! \fn void read_usertab(const char *UserTabFile) | |
a4aabea6 | 707 | Read the content of the \a UserTabFile and store it for further use with get_usertab_name(). |
48864d28 FM |
708 | |
709 | The file contains the IP address or ID of the user then some spaces and the real name of the user. | |
a4aabea6 FM |
710 | |
711 | Any trailing space or tabulation is removed from the real name. The user ID or IP cannot contain | |
712 | a space or a tabulation but it may contain any other character, including the colon that was | |
713 | forbidden in the past. That change was made to allow IPv6 addresses. | |
714 | ||
48864d28 FM |
715 | The file may contain comments if the line starts with a #. |
716 | ||
717 | \param UserTabFile The name of the file to read. If it is empty, the function does nothing. | |
718 | */ | |
719 | ||
720 | ||
721 | ||
722 | ||
723 | ||
724 | /*! \fn void get_usertab_name(const char *user,char *name,int namelen) | |
725 | Find the real name of the user with the ID or IP address in \a user. The name is fetched | |
726 | from the usertab file. | |
727 | ||
728 | The usertab file must have been read by read_usertab(). | |
729 | ||
730 | \param user The ID or IP address of the user. | |
731 | \param name A buffer to write the real name of the user. | |
732 | \param namelen The size of the buffer. | |
733 | */ | |
304a739d FM |
734 | |
735 | ||
736 | ||
737 | ||
738 | ||
739 | /*! \fn int is_download_suffix(const char *url) | |
740 | Tell if the URL correspond to a downloaded file. The function takes the extension at the end of the | |
741 | URL with a maximum of 9 characters and compare it to the list of the download suffix in | |
742 | ::DownloadSuffix. If the suffix is found in the list, the function reports the URL as the download | |
743 | of a file. | |
744 | ||
745 | \param url The URL to test. | |
746 | ||
747 | \retval 1 The URL matches a suffix of a download. | |
748 | \retval 0 The URL is not a known download. | |
749 | ||
750 | \note A downloaded file cannot be detected if the file name is embedded in a GET or POST request. Only requests | |
751 | that ends with the file name can be detected. | |
752 | ||
753 | \note A URL embedding another web site's address ending by .com at the end of the URL will match the download | |
754 | extension com if it is defined in the ::DownloadSuffix. | |
755 | */ | |
dfb337be FM |
756 | |
757 | ||
758 | ||
759 | ||
760 | /*! \fn void write_logo_image(FILE *fp_ou) | |
761 | Write a link of the logo of the organisation that generate the report in the HTML file. The logo | |
762 | is written in a centered table. | |
763 | ||
764 | \param fp_ou The handle of the HTML file being written. | |
765 | */ | |
766 | ||
767 | ||
768 | ||
769 | ||
770 | /*! \fn void output_html_string(FILE *fp_ou,const char *str) | |
771 | Write a string in a file and replace the problematic ASCII characters by their equivalent HTML entities. | |
772 | ||
773 | \param fp_ou The handle of the output file. | |
774 | \param str The string to output. | |
775 | */ |