Commit 40d6fa7e authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Merge commit 'b3b22bb8'

parents d2735204 b3b22bb8
......@@ -103,6 +103,10 @@ typedef struct blc_array
START_EXTERN_C
void blc_array_fatal_error(blc_array const *array, const char *name_of_file, const char* name_of_function, int numero_of_line, const char *message, ...);
void blc_array_destroy(blc_array *array);
/**Display a 3D matrix ( tipically a image). The interface will change to be simplified*/
void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int length0, int step1, int width, int step2, int height, int ansi_terminal);
END_EXTERN_C
///@}
......
......@@ -88,7 +88,12 @@ if ('UIN8' == STRING_TO_UINT32("UIN8")) ...
uint32_t value_str;
printf("type: %.4s", UINT32_TO_STRING(value_str, 'UIN8'));
@endcode*/
#define UINT32_TO_STRING(uint32_print, x) ((char*)&(uint32_print=htonl(x)))
#ifdef __cplusplus
#define UINT32_TO_STRING(uint32_str, x) ((char*)&(uint32_str=htonl(x)))
#else
char* blc_uint32_to_string(uint32_t *string, uint32_t x);
#define UINT32_TO_STRING(uint32_str, x) blc_uint32_to_string(&uint32_str, x)
#endif
///Shorcut to use in formated string to define a maximal size of the receiving string.
#define SCAN_CONV(size_max, format) "%" STRINGIFY_CONTENT(size_max)format
......
......@@ -564,7 +564,33 @@ void blc_array::save_tsv_file(char const *filename){
}
static void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int length0, int step1, int width, int step2, int height, int ansi_terminal)
void blc_array::fprint_surface_uchars(FILE *file, int ansi_terminal){
fprint_3Dmatrix(file, this, 0, 1, 1, dims[0].step, dims[0].length, dims[1].step, dims[1].length, ansi_terminal);
}
/* C wrapper */
START_EXTERN_C
// Envoie un message d'erreur avec name_of_file, name_of_function, number_of_line et affiche le message formate avec les parametres variables. Puis exit le programme avec le parametre EXIT_FAILURE. To be used with EXIT_ON_ERROR.
void blc_array_fatal_error(blc_array const *array, const char *name_of_file, const char* name_of_function, int numero_of_line, const char *message, ...){
va_list arguments;
va_start(arguments, message);
fprintf(stderr, "\n%s: %s \t %s \t %i :\nError: ", blc_program_name, name_of_file, name_of_function, numero_of_line);
color_vfprintf(BLC_BRIGHT_RED, stderr, message, arguments);
va_end(arguments);
array->fprint_debug(stderr);
fprintf(stderr, "\n\n");
fflush(stderr);
raise(SIGABRT);
exit(EXIT_FAILURE);
}
void blc_array_destroy(blc_array *array){
array->~blc_array();
}
void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int length0, int step1, int width, int step2, int height, int ansi_terminal)
{
char *data;
char tmp_string[8];
......@@ -638,27 +664,4 @@ static void fprint_3Dmatrix(FILE *file, blc_mem *mem, int offset, int step0, int
}
void blc_array::fprint_surface_uchars(FILE *file, int ansi_terminal){
fprint_3Dmatrix(file, this, 0, 1, 1, dims[0].step, dims[0].length, dims[1].step, dims[1].length, ansi_terminal);
}
/* C wrapper */
START_EXTERN_C
// Envoie un message d'erreur avec name_of_file, name_of_function, number_of_line et affiche le message formate avec les parametres variables. Puis exit le programme avec le parametre EXIT_FAILURE. To be used with EXIT_ON_ERROR.
void blc_array_fatal_error(blc_array const *array, const char *name_of_file, const char* name_of_function, int numero_of_line, const char *message, ...){
va_list arguments;
va_start(arguments, message);
fprintf(stderr, "\n%s: %s \t %s \t %i :\nError: ", blc_program_name, name_of_file, name_of_function, numero_of_line);
color_vfprintf(BLC_BRIGHT_RED, stderr, message, arguments);
va_end(arguments);
array->fprint_debug(stderr);
fprintf(stderr, "\n\n");
fflush(stderr);
raise(SIGABRT);
exit(EXIT_FAILURE);
}
void blc_array_destroy(blc_array *array){
array->~blc_array();
}
END_EXTERN_C
......@@ -34,7 +34,6 @@ FILE *blc_log_file = NULL;
char const *blc_program_name="";
size_t blc_get_type_size(uint32_t type)
{
uint32_t type_str;
......@@ -53,7 +52,6 @@ size_t blc_get_type_size(uint32_t type)
return 0;
}
//Envoie un message de warning avec name_of_file, name_of_function, number_of_line et affiche le message formate avec les parametres variables. To be used with PRINT_WARNING.
void print_warning(const char *name_of_file, const char* name_of_function, int numero_of_line, const char *message, ...)
{
......@@ -271,5 +269,11 @@ char const *blc_get_filename_extension(char const *filename){
return ext+1;
}
extern "C"{
char* blc_uint32_to_string(uint32_t *string, uint32_t x){
*string=htonl(x);
return (char*)string;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment