| 1 | #cxx . . $ `<file>/src/utils.c`/include "utils.h"cxx . . $ `<file>/src/utils.h`/ |
| 2 | |
| 3 | #include <stdlib.h> |
| 4 | #include <stdarg.h> |
| 5 | #include <stdio.h> |
| 6 | #include <string.h> |
| 7 | #include <stdbool.h> |
| 8 | |
| 9 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! panic_use_colourscxx . . $ panic_use_colours. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 10 | |
| 11 | /* TODO these are actually a duplicate of the ones in text_reporter.c */ |
| 12 | #define GREENcxx . . $ `src/utils.c:12:9`! "\x1b[32m" |
| 13 | #define YELLOWcxx . . $ `src/utils.c:13:9`! "\x1b[33m" |
| 14 | #define REDcxx . . $ `src/utils.c:14:9`! "\x1b[31m" |
| 15 | #define MAGENTAcxx . . $ `src/utils.c:15:9`! "\x1b[35m" |
| 16 | #define RESETcxx . . $ `src/utils.c:16:9`! "\x1b[0m" |
| 17 | |
| 18 | #include "../gitrevision.h"cxx . . $ `<file>/gitrevision.h`/ |
| 19 | |
| 20 | char *cgreen_library_versioncxx . . $ cgreen_library_version. = VERSIONcxx . . $ `<built-in>:411:9`!; |
| 21 | char *cgreen_library_revisioncxx . . $ cgreen_library_revision. = GITREVISIONcxx . . $ `gitrevision.h:2:9`!; |
| 22 | |
| 23 | char *string_dupcxx . . $ string_dup(a8b8e32347182212).(const char *string) { |
| 24 | char *dup = (char *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(strlencxx . . $ strlen(751346f8406fd082).(string)+1); |
| 25 | if (dup) |
| 26 | strcpycxx . . $ strcpy(b7b3a83273496486).(dup, string); |
| 27 | return dup; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | static char *panic_message_buffercxx . . $ panic_message_buffer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 32 | |
| 33 | /* For unittesting */ |
| 34 | void panic_set_output_buffercxx . . $ panic_set_output_buffer(85c52e162fed56f9).(const char *buffer) { |
| 35 | panic_message_buffercxx . . $ panic_message_buffer. = (char *)buffer; |
| 36 | } |
| 37 | |
| 38 | void paniccxx . . $ panic(b8982657348efbf7).(const char *filename, int line, const char *fmt, ...) { |
| 39 | va_listcxx . . $ va_list# args; |
| 40 | char buffer[1000]; |
| 41 | |
| 42 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(args, fmt); |
| 43 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(buffer, "%sCGREEN EXCEPTION%s: <%s:%d>", |
| 44 | panic_use_colourscxx . . $ panic_use_colours.?MAGENTAcxx . . $ `src/utils.c:15:9`!:"", |
| 45 | panic_use_colourscxx . . $ panic_use_colours.?RESETcxx . . $ `src/utils.c:16:9`!:"", |
| 46 | filename, line); |
| 47 | vsprintfcxx . . $ vsprintf(d8921982374e5df0).(&buffer[strlencxx . . $ strlen(751346f8406fd082).(buffer)], fmt, args); |
| 48 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(args); |
| 49 | |
| 50 | if (panic_message_buffercxx . . $ panic_message_buffer. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 51 | strcpycxx . . $ strcpy(b7b3a83273496486).(panic_message_buffercxx . . $ panic_message_buffer., buffer); |
| 52 | else |
| 53 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s\n", buffer); |
| 54 | } |