00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifdef HAVE_CONFIG_H
00050 # include <config.h>
00051 #endif
00052
00053
00060
00061
00064 #include <sinfo_dump.h>
00065 #include <sinfo_utils.h>
00066 #include <sinfo_error.h>
00067 #include <sinfo_msg.h>
00068 #include <cpl.h>
00069
00070
00082
00083 cpl_error_code
00084 sinfo_print_cpl_propertylist(const cpl_propertylist *pl, long low, long high)
00085 {
00086 cpl_property *prop;
00087 long i = 0;
00088
00089 assure (0 <= low && high <= cpl_propertylist_get_size(pl) && low <= high,
00090 CPL_ERROR_ILLEGAL_INPUT, "Illegal range");
00091
00092
00093 if (pl == NULL){
00094 sinfo_msg("NULL");
00095 }
00096 else if (cpl_propertylist_is_empty(pl)) {
00097 sinfo_msg("[Empty property list]");
00098 }
00099 else
00100 for (i = low; i < high; i++)
00101 {
00102
00103
00104 prop = cpl_propertylist_get((cpl_propertylist *)pl, i);
00105 check (sinfo_print_cpl_property(prop),
00106 "Error printing property");
00107 }
00108
00109 cleanup:
00110 return cpl_error_get_code();
00111 }
00112
00120
00121
00122 cpl_error_code
00123 sinfo_print_cpl_property(const cpl_property *prop)
00124 {
00125 cpl_type t;
00126
00127 if (prop == NULL)
00128 {
00129 sinfo_msg("NULL");
00130 }
00131 else
00132 {
00133
00134
00135
00136
00137
00138
00139
00140
00141 sinfo_msg("%s =", cpl_property_get_name(prop));
00142
00143
00144
00145 check( t = cpl_property_get_type(prop),
00146 "Could not read property type");
00147
00148 switch(t & (~CPL_TYPE_FLAG_ARRAY))
00149 {
00150 case CPL_TYPE_CHAR:
00151 if (t & CPL_TYPE_FLAG_ARRAY)
00152 {
00153 sinfo_msg(" '%s'", cpl_property_get_string(prop));
00154 }
00155 else
00156 {
00157 sinfo_msg(" %c", cpl_property_get_char(prop));
00158 }
00159 break;
00160 case CPL_TYPE_BOOL: if (cpl_property_get_bool(prop))
00161 {sinfo_msg(" true");}
00162 else
00163 {sinfo_msg(" false");}
00164 break;
00165 case CPL_TYPE_UCHAR: sinfo_msg("%c",cpl_property_get_char(prop)); break;
00166 case CPL_TYPE_INT: sinfo_msg("%d",cpl_property_get_int(prop)); break;
00167 case CPL_TYPE_UINT: sinfo_msg("%d",cpl_property_get_int(prop)); break;
00168 case CPL_TYPE_LONG: sinfo_msg("%ld",cpl_property_get_long(prop)); break;
00169 case CPL_TYPE_ULONG: sinfo_msg("%ld",cpl_property_get_long(prop)); break;
00170 case CPL_TYPE_FLOAT: sinfo_msg("%f",cpl_property_get_float(prop)); break;
00171 case CPL_TYPE_DOUBLE: sinfo_msg("%f",cpl_property_get_double(prop)); break;
00172 case CPL_TYPE_POINTER: sinfo_msg("POINTER"); break;
00173 case CPL_TYPE_INVALID: sinfo_msg("INVALID"); break;
00174 default: sinfo_msg(" unrecognized property"); break;
00175 }
00176
00177
00178 if (t & CPL_TYPE_FLAG_ARRAY){
00179 sinfo_msg(" (array size = %ld)", cpl_property_get_size(prop));
00180 }
00181
00182
00183 if (cpl_property_get_comment(prop) != NULL){
00184 sinfo_msg(" %s", cpl_property_get_comment(prop));
00185 }
00186 }
00187
00188 cleanup:
00189 return cpl_error_get_code();
00190 }
00191
00192
00200
00201 cpl_error_code
00202 sinfo_print_cpl_frameset(const cpl_frameset *frames)
00203 {
00204
00205
00206 if (frames == NULL)
00207 {
00208 sinfo_msg("NULL");
00209 }
00210 else
00211 {
00212 cpl_frame *f = NULL;
00213 check( f = cpl_frameset_get_first(frames),
00214 "Error reading frameset");
00215
00216 if (f == NULL)
00217 {
00218 sinfo_msg("[Empty frame set]");
00219 }
00220 else
00221 {
00222 while(f != NULL)
00223 {
00224 check( sinfo_print_cpl_frame(f),
00225 "Could not print frame");
00226 check( f = cpl_frameset_get_next(frames),
00227 "Error reading frameset");
00228 }
00229 }
00230 }
00231
00232 cleanup:
00233 return cpl_error_get_code();
00234 }
00235
00236
00244
00245 cpl_error_code
00246 sinfo_print_cpl_frame(const cpl_frame *f)
00247 {
00248 if (f == NULL)
00249 {
00250 sinfo_msg("NULL");
00251 }
00252 else
00253 {
00254 sinfo_msg("%-7s %-20s '%s'",
00255 sinfo_tostring_cpl_frame_group(cpl_frame_get_group(f)),
00256 cpl_frame_get_tag(f) != NULL ?
00257 cpl_frame_get_tag(f) : "Null",
00258 cpl_frame_get_filename(f));
00259
00260 sinfo_msg_debug("type \t= %s",
00261 sinfo_tostring_cpl_frame_type (cpl_frame_get_type (f)));
00262 sinfo_msg_debug("group \t= %s",
00263 sinfo_tostring_cpl_frame_group(cpl_frame_get_group(f)));
00264 sinfo_msg_debug("level \t= %s",
00265 sinfo_tostring_cpl_frame_level(cpl_frame_get_level(f)));
00266 }
00267
00268 return cpl_error_get_code();
00269 }
00270
00271
00277
00278 const char *
00279 sinfo_tostring_cpl_frame_type(cpl_frame_type ft)
00280 {
00281 switch(ft)
00282 {
00283 case CPL_FRAME_TYPE_NONE: return "NONE"; break;
00284 case CPL_FRAME_TYPE_IMAGE: return "IMAGE"; break;
00285 case CPL_FRAME_TYPE_MATRIX: return "MATRIX"; break;
00286 case CPL_FRAME_TYPE_TABLE: return "TABLE"; break;
00287 default: return "unrecognized frame type";
00288 }
00289 }
00290
00291
00297
00298 const char *
00299 sinfo_tostring_cpl_frame_group(cpl_frame_group fg)
00300 {
00301 switch(fg)
00302 {
00303 case CPL_FRAME_GROUP_NONE: return "NONE"; break;
00304 case CPL_FRAME_GROUP_RAW: return CPL_FRAME_GROUP_RAW_ID; break;
00305 case CPL_FRAME_GROUP_CALIB: return CPL_FRAME_GROUP_CALIB_ID; break;
00306 case CPL_FRAME_GROUP_PRODUCT: return CPL_FRAME_GROUP_PRODUCT_ID;break;
00307 default:
00308 return "unrecognized frame group";
00309 }
00310 }
00311
00312
00318
00319 const char *
00320 sinfo_tostring_cpl_frame_level(cpl_frame_level fl)
00321 {
00322
00323 switch(fl)
00324 {
00325 case CPL_FRAME_LEVEL_NONE: return "NONE"; break;
00326 case CPL_FRAME_LEVEL_TEMPORARY: return "TEMPORARY"; break;
00327 case CPL_FRAME_LEVEL_INTERMEDIATE:return "INTERMEDIATE";break;
00328 case CPL_FRAME_LEVEL_FINAL: return "FINAL"; break;
00329 default: return "unrecognized frame level";
00330 }
00331 }
00332
00333
00334
00340
00341 const char *
00342 sinfo_tostring_cpl_type(cpl_type t)
00343 {
00344
00345
00346
00347
00348 if (!(t & CPL_TYPE_FLAG_ARRAY))
00349 switch(t & (~CPL_TYPE_FLAG_ARRAY))
00350 {
00351 case CPL_TYPE_CHAR: return "char"; break;
00352 case CPL_TYPE_UCHAR: return "uchar"; break;
00353 case CPL_TYPE_BOOL: return "boolean"; break;
00354 case CPL_TYPE_INT: return "int"; break;
00355 case CPL_TYPE_UINT: return "uint"; break;
00356 case CPL_TYPE_LONG: return "long"; break;
00357 case CPL_TYPE_ULONG: return "ulong"; break;
00358 case CPL_TYPE_FLOAT: return "float"; break;
00359 case CPL_TYPE_DOUBLE: return "double"; break;
00360 case CPL_TYPE_POINTER: return "pointer"; break;
00361
00362 case CPL_TYPE_INVALID: return "invalid"; break;
00363 default:
00364 return "unrecognized type";
00365 }
00366 else
00367 switch(t & (~CPL_TYPE_FLAG_ARRAY))
00368 {
00369 case CPL_TYPE_CHAR: return "string (char array)"; break;
00370 case CPL_TYPE_UCHAR: return "uchar array"; break;
00371 case CPL_TYPE_BOOL: return "boolean array"; break;
00372 case CPL_TYPE_INT: return "int array"; break;
00373 case CPL_TYPE_UINT: return "uint array"; break;
00374 case CPL_TYPE_LONG: return "long array"; break;
00375 case CPL_TYPE_ULONG: return "ulong array"; break;
00376 case CPL_TYPE_FLOAT: return "float array"; break;
00377 case CPL_TYPE_DOUBLE: return "double array"; break;
00378 case CPL_TYPE_POINTER: return "pointer array"; break;
00379
00380 case CPL_TYPE_INVALID: return "invalid (array)"; break;
00381 default:
00382 return "unrecognized type";
00383 }
00384 }