Commit 16dd6151 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

return size of properties

parent deb1f60a
...@@ -93,11 +93,11 @@ typedef struct blc_array ...@@ -93,11 +93,11 @@ typedef struct blc_array
/**Print the properties of the dims in a file or stderr by default (i.e. "3x800x600" )*/ /**Print the properties of the dims in a file or stderr by default (i.e. "3x800x600" )*/
int fprint_dims(FILE *file=stderr) const; int fprint_dims(FILE *file=stderr) const;
/**Print all the informations about the blc_array. Useful for debuging.*/ /**Print all the informations about the blc_array. Useful for debuging.*/
void fprint_debug(FILE *file=stderr) const; int fprint_debug(FILE *file=stderr) const;
/**Print all the properties of the array in a string (i.e. "UIN8 RGB3 3x800x600")*/ /**Print all the properties of the array in a string (i.e. "UIN8 RGB3 3x800x600")*/
void sprint_properties(char *string, size_t max_string_size) const; int sprint_properties(char *string, size_t max_string_size) const;
/**Print all the properties of the array in a file or stderr by default. (i.e. "UIN8 RGB3 3x800x600")*/ /**Print all the properties of the array in a file or stderr by default. (i.e. "UIN8 RGB3 3x800x600")*/
void fprint_properties(FILE *file=stderr) const; int fprint_properties(FILE *file=stderr) const;
/* Modifying the properties of the array /* Modifying the properties of the array
======================================*/ ======================================*/
......
...@@ -261,7 +261,7 @@ int blc_array::sscan_dims(char const *string){ ...@@ -261,7 +261,7 @@ int blc_array::sscan_dims(char const *string){
//Should use code in common with fprint_info //Should use code in common with fprint_info
void blc_array::sprint_properties(char *buffer, size_t buffer_size) const{ int blc_array::sprint_properties(char *buffer, size_t buffer_size) const{
int width; int width;
uint32_t str_type; uint32_t str_type;
uint32_t str_format; uint32_t str_format;
...@@ -270,10 +270,11 @@ void blc_array::sprint_properties(char *buffer, size_t buffer_size) const{ ...@@ -270,10 +270,11 @@ void blc_array::sprint_properties(char *buffer, size_t buffer_size) const{
if (format==0) EXIT_ON_ERROR("The format should not be NULL. Use 'NDEF' by default."); if (format==0) EXIT_ON_ERROR("The format should not be NULL. Use 'NDEF' by default.");
width=snprintf(buffer, buffer_size, "%.4s %.4s ", UINT32_TO_STRING(str_type, type), UINT32_TO_STRING(str_format, format)); width=snprintf(buffer, buffer_size, "%.4s %.4s ", UINT32_TO_STRING(str_type, type), UINT32_TO_STRING(str_format, format));
width+=sprint_dims(buffer+width,buffer_size-width); width+=sprint_dims(buffer+width, buffer_size-width);
return width;
} }
void blc_array::fprint_properties(FILE *file) const { int blc_array::fprint_properties(FILE *file) const {
int width; int width;
uint32_t net_type = htonl(type); uint32_t net_type = htonl(type);
uint32_t net_format = htonl(format); uint32_t net_format = htonl(format);
...@@ -281,9 +282,10 @@ void blc_array::fprint_properties(FILE *file) const { ...@@ -281,9 +282,10 @@ void blc_array::fprint_properties(FILE *file) const {
if (type==0) EXIT_ON_ERROR("The type should not be NULL. Use 'NDEF' by default."); if (type==0) EXIT_ON_ERROR("The type should not be NULL. Use 'NDEF' by default.");
if (format==0) EXIT_ON_ERROR("The format should not be NULL. Use 'NDEF' by default."); if (format==0) EXIT_ON_ERROR("The format should not be NULL. Use 'NDEF' by default.");
width=fprintf(file, "%.4s %.4s ", (char*)&net_type, (char*)&net_format);
width+=fprint_dims(file);
fprintf(file, "%.4s %.4s ", (char*)&net_type, (char*)&net_format); return width;
width=fprint_dims(file);
} }
//Should use code in common with fscan_info //Should use code in common with fscan_info
...@@ -335,13 +337,16 @@ void blc_array::fscan_properties(FILE *file){ ...@@ -335,13 +337,16 @@ void blc_array::fscan_properties(FILE *file){
return size; return size;
}*/ }*/
void blc_array::fprint_debug (FILE *file) const{ int blc_array::fprint_debug (FILE *file) const{
int width;
uint32_t type_str, format_str; uint32_t type_str, format_str;
fprintf(file, "\nblc_array:\n type:%.4s, format:%.4s, dims_nb:%d, size:%ld \n", UINT32_TO_STRING(type_str, type), UINT32_TO_STRING(format_str, format), dims_nb, size); width=fprintf(file, "\nblc_array:\n type:%.4s, format:%.4s, dims_nb:%d, size:%ld \n", UINT32_TO_STRING(type_str, type), UINT32_TO_STRING(format_str, format), dims_nb, size);
fprint_dims(file); width+=fprint_dims(file);
fprintf(file, "\n"); width+=fprintf(file, "\n");
if (data==NULL) fprintf(file, "data is null\n"); if (data==NULL) width+=fprintf(file, "data is null\n");
return width;
} }
void blc_array::def_with_blc_file(char const *filename){ void blc_array::def_with_blc_file(char const *filename){
......
Markdown is supported
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