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
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifdef HAVE_CONFIG_H
00065 # include <config.h>
00066 #endif
00067
00070
00077
00078
00079
00080 #include <sinfo_dump.h>
00081 #include <sinfo_utils.h>
00082 #include <sinfo_error.h>
00083 #include <sinfo_msg.h>
00084 #include <cpl.h>
00085
00086
00098
00099 cpl_error_code
00100 sinfo_print_cpl_propertylist(const cpl_propertylist *pl, long low, long high)
00101 {
00102 cpl_property *prop;
00103 long i = 0;
00104
00105 assure (0 <= low && high <= cpl_propertylist_get_size(pl) && low <= high,
00106 CPL_ERROR_ILLEGAL_INPUT, "Illegal range");
00107
00108
00109 if (pl == NULL){
00110 sinfo_msg("NULL");
00111 }
00112 else if (cpl_propertylist_is_empty(pl)) {
00113 sinfo_msg("[Empty property list]");
00114 }
00115 else
00116 for (i = low; i < high; i++)
00117 {
00118
00119
00120 prop = cpl_propertylist_get((cpl_propertylist *)pl, i);
00121 check (sinfo_print_cpl_property(prop),
00122 "Error printing property");
00123 }
00124
00125 cleanup:
00126 return cpl_error_get_code();
00127 }
00128
00136
00137
00138 cpl_error_code
00139 sinfo_print_cpl_property(const cpl_property *prop)
00140 {
00141 cpl_type t;
00142
00143 if (prop == NULL)
00144 {
00145 sinfo_msg("NULL");
00146 }
00147 else
00148 {
00149
00150
00151
00152
00153
00154
00155
00156
00157 sinfo_msg("%s =", cpl_property_get_name(prop));
00158
00159
00160
00161 check( t = cpl_property_get_type(prop),
00162 "Could not read property type");
00163
00164 switch(t & (~CPL_TYPE_FLAG_ARRAY))
00165 {
00166 case CPL_TYPE_CHAR:
00167 if (t & CPL_TYPE_FLAG_ARRAY)
00168 {
00169 sinfo_msg(" '%s'", cpl_property_get_string(prop));
00170 }
00171 else
00172 {
00173 sinfo_msg(" %c", cpl_property_get_char(prop));
00174 }
00175 break;
00176 case CPL_TYPE_BOOL: if (cpl_property_get_bool(prop))
00177 {sinfo_msg(" true");}
00178 else
00179 {sinfo_msg(" false");}
00180 break;
00181 case CPL_TYPE_UCHAR:
00182 sinfo_msg("%c",cpl_property_get_char(prop));
00183 break;
00184 case CPL_TYPE_INT:
00185 sinfo_msg("%d",cpl_property_get_int(prop));
00186 break;
00187 case CPL_TYPE_UINT:
00188 sinfo_msg("%d",cpl_property_get_int(prop));
00189 break;
00190 case CPL_TYPE_LONG:
00191 sinfo_msg("%ld",cpl_property_get_long(prop));
00192 break;
00193 case CPL_TYPE_ULONG:
00194 sinfo_msg("%ld",cpl_property_get_long(prop));
00195 break;
00196 case CPL_TYPE_FLOAT:
00197 sinfo_msg("%f",cpl_property_get_float(prop));
00198 break;
00199 case CPL_TYPE_DOUBLE:
00200 sinfo_msg("%f",cpl_property_get_double(prop));
00201 break;
00202 case CPL_TYPE_POINTER:
00203 sinfo_msg("POINTER");
00204 break;
00205 case CPL_TYPE_INVALID:
00206 sinfo_msg("INVALID");
00207 break;
00208 default:
00209 sinfo_msg(" unrecognized property");
00210 break;
00211 }
00212
00213
00214 if (t & CPL_TYPE_FLAG_ARRAY){
00215 cpl_msg_info(cpl_func," (array size = %" CPL_SIZE_FORMAT " )",
00216 cpl_property_get_size(prop));
00217 }
00218
00219
00220 if (cpl_property_get_comment(prop) != NULL){
00221 sinfo_msg(" %s", cpl_property_get_comment(prop));
00222 }
00223 }
00224
00225 cleanup:
00226 return cpl_error_get_code();
00227 }
00228
00229
00237
00238 cpl_error_code
00239 sinfo_print_cpl_frameset(const cpl_frameset *frames)
00240 {
00241
00242
00243 if (frames == NULL)
00244 {
00245 sinfo_msg("NULL");
00246 }
00247 else
00248 {
00249 const cpl_frame *f = NULL;
00250 check( f = cpl_frameset_get_first_const(frames),
00251 "Error reading frameset");
00252
00253 if (f == NULL)
00254 {
00255 sinfo_msg("[Empty frame set]");
00256 }
00257 else
00258 {
00259 while(f != NULL)
00260 {
00261 check( sinfo_print_cpl_frame(f),
00262 "Could not print frame");
00263 check( f = cpl_frameset_get_next_const(frames),
00264 "Error reading frameset");
00265 }
00266 }
00267 }
00268
00269 cleanup:
00270 return cpl_error_get_code();
00271 }
00272
00273
00281
00282 cpl_error_code
00283 sinfo_print_cpl_frame(const cpl_frame *f)
00284 {
00285 if (f == NULL)
00286 {
00287 sinfo_msg("NULL");
00288 }
00289 else
00290 {
00291 sinfo_msg("%-7s %-20s '%s'",
00292 sinfo_tostring_cpl_frame_group(cpl_frame_get_group(f)),
00293 cpl_frame_get_tag(f) != NULL ?
00294 cpl_frame_get_tag(f) : "Null",
00295 cpl_frame_get_filename(f));
00296
00297 sinfo_msg_debug("type \t= %s",
00298 sinfo_tostring_cpl_frame_type (cpl_frame_get_type (f)));
00299 sinfo_msg_debug("group \t= %s",
00300 sinfo_tostring_cpl_frame_group(cpl_frame_get_group(f)));
00301 sinfo_msg_debug("level \t= %s",
00302 sinfo_tostring_cpl_frame_level(cpl_frame_get_level(f)));
00303 }
00304
00305 return cpl_error_get_code();
00306 }
00307
00308
00314
00315 const char *
00316 sinfo_tostring_cpl_frame_type(cpl_frame_type ft)
00317 {
00318 switch(ft)
00319 {
00320 case CPL_FRAME_TYPE_NONE: return "NONE"; break;
00321 case CPL_FRAME_TYPE_IMAGE: return "IMAGE"; break;
00322 case CPL_FRAME_TYPE_MATRIX: return "MATRIX"; break;
00323 case CPL_FRAME_TYPE_TABLE: return "TABLE"; break;
00324 default: return "unrecognized frame type";
00325 }
00326 }
00327
00328
00334
00335 const char *
00336 sinfo_tostring_cpl_frame_group(cpl_frame_group fg)
00337 {
00338 switch(fg)
00339 {
00340 case CPL_FRAME_GROUP_NONE: return "NONE"; break;
00341 case CPL_FRAME_GROUP_RAW: return CPL_FRAME_GROUP_RAW_ID; break;
00342 case CPL_FRAME_GROUP_CALIB: return CPL_FRAME_GROUP_CALIB_ID; break;
00343 case CPL_FRAME_GROUP_PRODUCT: return CPL_FRAME_GROUP_PRODUCT_ID;break;
00344 default:
00345 return "unrecognized frame group";
00346 }
00347 }
00348
00349
00355
00356 const char *
00357 sinfo_tostring_cpl_frame_level(cpl_frame_level fl)
00358 {
00359
00360 switch(fl)
00361 {
00362 case CPL_FRAME_LEVEL_NONE: return "NONE"; break;
00363 case CPL_FRAME_LEVEL_TEMPORARY: return "TEMPORARY"; break;
00364 case CPL_FRAME_LEVEL_INTERMEDIATE:return "INTERMEDIATE";break;
00365 case CPL_FRAME_LEVEL_FINAL: return "FINAL"; break;
00366 default: return "unrecognized frame level";
00367 }
00368 }
00369
00370
00371
00377
00378 const char *
00379 sinfo_tostring_cpl_type(cpl_type t)
00380 {
00381
00382
00383
00384
00385 if (!(t & CPL_TYPE_FLAG_ARRAY))
00386 switch(t & (~CPL_TYPE_FLAG_ARRAY))
00387 {
00388 case CPL_TYPE_CHAR: return "char"; break;
00389 case CPL_TYPE_UCHAR: return "uchar"; break;
00390 case CPL_TYPE_BOOL: return "boolean"; break;
00391 case CPL_TYPE_INT: return "int"; break;
00392 case CPL_TYPE_UINT: return "uint"; break;
00393 case CPL_TYPE_LONG: return "long"; break;
00394 case CPL_TYPE_ULONG: return "ulong"; break;
00395 case CPL_TYPE_FLOAT: return "float"; break;
00396 case CPL_TYPE_DOUBLE: return "double"; break;
00397 case CPL_TYPE_POINTER: return "pointer"; break;
00398
00399 case CPL_TYPE_INVALID: return "invalid"; break;
00400 default:
00401 return "unrecognized type";
00402 }
00403 else
00404 switch(t & (~CPL_TYPE_FLAG_ARRAY))
00405 {
00406 case CPL_TYPE_CHAR: return "string (char array)"; break;
00407 case CPL_TYPE_UCHAR: return "uchar array"; break;
00408 case CPL_TYPE_BOOL: return "boolean array"; break;
00409 case CPL_TYPE_INT: return "int array"; break;
00410 case CPL_TYPE_UINT: return "uint array"; break;
00411 case CPL_TYPE_LONG: return "long array"; break;
00412 case CPL_TYPE_ULONG: return "ulong array"; break;
00413 case CPL_TYPE_FLOAT: return "float array"; break;
00414 case CPL_TYPE_DOUBLE: return "double array"; break;
00415 case CPL_TYPE_POINTER: return "pointer array"; break;
00416
00417 case CPL_TYPE_INVALID: return "invalid (array)"; break;
00418 default:
00419 return "unrecognized type";
00420 }
00421 }