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 #if defined(sccs)
00033 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATStatus.c,v 1.29 2004/05/12 18:56:01 hartmutkaiser Exp $";
00034 #endif
00035
00036 #include <assert.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039 #include <stdio.h>
00040
00041 #include "GATInternal.h"
00042 #include "GATType.h"
00043 #include "GATErrors.h"
00044 #include "GATObject.h"
00045 #include "GATContext.h"
00046 #include "GATStatus.h"
00047 #include "GATXdsWrapper.h"
00048 #include "GATList.h"
00049 #include "GATSelf.h"
00050
00051
00052
00053
00054 GATLIST_IMPLEMENT(extern, GATStatus, GATList_GATStatus, GATType_GATStatus)
00055
00056
00057
00058
00059 GATOBJECT_DEFINE_VTABLE(GATStatus);
00060 GATSERIALISABLE_DEFINE_VTABLE(GATStatus);
00061
00062
00063
00064
00065 GATOBJECT_DEFINE_CONVERTERS(GATStatus);
00066 GATOBJECT_DEFINE_CONVERTERS_QUALIFIED(extern, GATList_GATStatus,
00067 GATType_GATList);
00068
00069
00070
00071
00072
00073 struct GATStatus_S {
00074 GATStatus_vtable *GATObject__vtable;
00075 GATStatus_ISerialisable_vtable *GATSerialisable__vtable;
00076
00077 GATBool isdirty;
00078 GATResult statuscode;
00079 char filename[FILENAME_MAX];
00080 GATuint32 linenumber;
00081 GATList_String messages;
00082 GATStatus_const parent;
00083 GATList_GATStatus children;
00084 };
00085
00086
00087 static GATResult
00088 GATStatus_DeSerialise_Create(GATContext context, GATObject stream,
00089 GATResult code, GATList_String messages, GATList_GATStatus children,
00090 char const *filename, GATuint32 lineno, GATStatus *new_object);
00091
00092 static GATResult
00093 GATStatus_SetParent(GATStatus status, GATStatus_const parent);
00094
00095 static void
00096 GATStatus_TraceLevel(FILE *fp, GATStatus_const status, int level);
00097
00098
00099 static GATStatus_vtable GATStatus__vtable = {
00100 GATStatus_GetType,
00101 GATStatus_Destroy,
00102 GATStatus_Equals,
00103 GATStatus_Clone,
00104 GATStatus_GetInterface
00105 };
00106
00107 static GATStatus_ISerialisable_vtable
00108 GATStatus_ISerialisable__vtable =
00109 {
00110 GATStatus_Serialise,
00111 GATStatus_DeSerialise,
00112 GATStatus_GetIsDirty,
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 GATResult GATStatus_Register_GATSerialisable(void)
00124 {
00125 return GATObject_Register_GATSerialisable(GATType_GATStatus,
00126 &GATStatus_ISerialisable__vtable);
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 GATResult
00148 GATCreateStatus(char const *name, GATStatus *status, GATResult result_code,
00149 GATContext context, char const *filename, GATuint32 lineno)
00150 {
00151 GATResult retval = GAT_SUCCESS;
00152 if (GAT_FAILED(result_code))
00153 {
00154 if (NULL != name && NULL != status)
00155 {
00156 if (NULL == *status)
00157 {
00158 *status = GATStatus_Create(name, filename, lineno);
00159 }
00160
00161 if (NULL != *status)
00162 {
00163 GATStatus new_status = NULL;
00164 if (GAT_SUCCESS != GATContext_GetCurrentStatus(context, &new_status) ||
00165 NULL == new_status)
00166 {
00167 new_status = GATStatus_Create_Code(result_code, filename, lineno);
00168 if (NULL == new_status)
00169 {
00170 retval = GAT_MEMORYFAILURE;
00171 }
00172 }
00173
00174 if (NULL != new_status)
00175 {
00176 retval = GATStatus_AddChild(*status, new_status);
00177 if (GAT_SUCCESS == retval)
00178 {
00179 retval = result_code;
00180 }
00181 GATStatus_Destroy(&new_status);
00182 }
00183 }
00184 else
00185 {
00186 retval = GAT_MEMORYFAILURE;
00187 }
00188 }
00189 else
00190 {
00191 retval = GAT_INVALID_PARAMETER;
00192 }
00193 }
00194 else
00195 {
00196 retval = result_code;
00197 }
00198 return retval;
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 GATResult
00218 GATPropagateStatus(char const *name, GATStatus *status, GATResult result_code,
00219 GATContext context)
00220 {
00221
00222
00223 return GATCreateStatus(name, status, result_code, context, NULL, 0);
00224 }
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 GATStatus
00242 GATStatus_Create(char const *message, char const *filename, GATuint32 lineno)
00243 {
00244 GATStatus status = (GATStatus) malloc(sizeof(struct GATStatus_S));
00245 if (NULL != status)
00246 {
00247 status->GATObject__vtable = &GATStatus__vtable;
00248 status->GATSerialisable__vtable = &GATStatus_ISerialisable__vtable;
00249
00250 status->isdirty = GATFalse;
00251 status->statuscode = GAT_SUCCESS;
00252 status->parent = NULL;
00253 status->children = NULL;
00254 if (NULL != filename)
00255 {
00256 strncpy(status->filename, filename, FILENAME_MAX);
00257 status->filename[FILENAME_MAX-1] = '\0';
00258 }
00259 else
00260 {
00261 status->filename[0] = '\0';
00262 }
00263 status->linenumber = lineno;
00264 status->messages = GATList_String_Create();
00265 if (NULL != status->messages)
00266 {
00267 GATList_String_Iterator end = GATList_String_End(status->messages);
00268 GATList_String_Iterator new_msg =
00269 GATList_String_Insert(status->messages, end, message);
00270
00271 if (NULL == new_msg)
00272 {
00273 GATList_String_Destroy(&status->messages);
00274 free(status);
00275 status = NULL;
00276 }
00277 }
00278 }
00279 return status;
00280 }
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 GATStatus GATStatus_Create_Code(GATResult code, char const *filename,
00295 GATuint32 lineno)
00296 {
00297 GATStatus status = (GATStatus) malloc(sizeof(struct GATStatus_S));
00298 if (NULL != status)
00299 {
00300 status->GATObject__vtable = &GATStatus__vtable;
00301 status->GATSerialisable__vtable = &GATStatus_ISerialisable__vtable;
00302
00303 status->isdirty = GATFalse;
00304 status->statuscode = code;
00305 status->parent = NULL;
00306 status->children = NULL;
00307 if (NULL != filename)
00308 {
00309 strncpy(status->filename, filename, FILENAME_MAX);
00310 status->filename[FILENAME_MAX-1] = '\0';
00311 }
00312 else
00313 {
00314 status->filename[0] = '\0';
00315 }
00316 status->linenumber = lineno;
00317 status->messages = GATList_String_Create();
00318
00319 if (NULL == status->messages)
00320 {
00321 GATStatus_Destroy(&status);
00322 }
00323 }
00324 return status;
00325 }
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 void
00338 GATStatus_Destroy(GATStatus *status)
00339 {
00340 if (NULL != status && NULL != *status)
00341 {
00342 GATList_String_Destroy(&(*status)->messages);
00343 GATList_GATStatus_Destroy(&(*status)->children);
00344 free(*status);
00345 *status = NULL;
00346 }
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 GATType GATStatus_GetType(GATStatus_const status)
00359 {
00360 GAT_UNUSED_PARAMETER(status);
00361 return GATType_GATStatus;
00362 }
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 GATResult GATStatus_Clone(GATStatus_const status, GATStatus *new_object)
00377 {
00378 GATResult retval = GAT_INVALID_PARAMETER;
00379 if (NULL != status && NULL != new_object)
00380 {
00381 GATStatus new_status = (GATStatus) malloc(sizeof(struct GATStatus_S));
00382 if (NULL == new_status)
00383 {
00384 retval = GAT_MEMORYFAILURE;
00385 }
00386 else
00387 {
00388 new_status->GATObject__vtable = &GATStatus__vtable;
00389 new_status->GATSerialisable__vtable = &GATStatus_ISerialisable__vtable;
00390
00391 new_status->isdirty = status->isdirty;
00392 new_status->statuscode = status->statuscode;
00393 new_status->parent = status->parent;
00394 new_status->children = NULL;
00395 new_status->messages = NULL;
00396 strcpy(new_status->filename, status->filename);
00397 new_status->linenumber = status->linenumber;
00398
00399 retval = GATList_String_Clone(status->messages, &new_status->messages);
00400 if (GAT_SUCCESS == retval && NULL != status->children)
00401 {
00402 GATList_GATStatus_Iterator it = GATList_GATStatus_Begin(status->children);
00403 GATList_GATStatus_Iterator end = GATList_GATStatus_End(status->children);
00404 for (; it != end; it = GATList_GATStatus_Next(it))
00405 {
00406 retval = GATStatus_AddChild(new_status, *GATList_GATStatus_Get(it));
00407 if (GAT_SUCCESS != retval)
00408 {
00409 break;
00410 }
00411 }
00412 }
00413 }
00414
00415 if (GAT_SUCCESS != retval)
00416 {
00417 GATStatus_Destroy(&new_status);
00418 }
00419
00420 *new_object = new_status;
00421 }
00422 return retval;
00423 }
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438 GATResult GATStatus_Equals(GATStatus_const lhs, GATStatus_const rhs,
00439 GATBool *isequal)
00440 {
00441 GATResult retval = GAT_INVALID_PARAMETER;
00442 if (NULL != lhs && NULL != rhs && NULL != isequal)
00443 {
00444 *isequal = GATTrue;
00445 if (lhs->statuscode != rhs->statuscode ||
00446 strcmp(lhs->filename, rhs->filename) ||
00447 lhs->linenumber != rhs->linenumber)
00448 {
00449 *isequal = GATFalse;
00450 }
00451 else
00452 {
00453 retval = GATList_String_Equals(lhs->messages, rhs->messages, isequal);
00454 if (GAT_SUCCESS == retval && GATTrue == *isequal)
00455 {
00456 if (NULL != lhs->children && NULL != rhs->children)
00457 {
00458 retval = GATList_GATStatus_Equals(lhs->children, rhs->children,
00459 isequal);
00460 }
00461 else if (NULL == lhs->children && NULL == rhs->children)
00462 {
00463 *isequal = GATTrue;
00464 retval = GAT_SUCCESS;
00465 }
00466 else
00467 {
00468 *isequal = GATFalse;
00469 retval = GAT_SUCCESS;
00470 }
00471 }
00472 }
00473 }
00474 return retval;
00475 }
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 GATResult
00490 GATStatus_GetInterface(GATStatus_const object, GATInterface iftype,
00491 void const **ifp)
00492 {
00493 GATResult retval = GAT_INVALID_PARAMETER;
00494
00495 if (NULL != ifp)
00496 {
00497 *ifp = NULL;
00498 if (GATInterface_ISerialisable == iftype)
00499 {
00500 *ifp = (void const *) &object->GATSerialisable__vtable;
00501 retval = GAT_SUCCESS;
00502 }
00503 else
00504 {
00505 retval = GAT_NO_INTERFACE;
00506 }
00507 }
00508 return retval;
00509 }
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 GATResult
00527 GATStatus_Serialise(GATStatus object, GATObject stream, GATBool clear_dirty)
00528 {
00529 GATResult retval = GAT_INVALID_HANDLE;
00530 if (NULL != object)
00531 {
00532 retval = GATXds_SerialiseObject(GATStatus_ToGATObject(object), stream,
00533 clear_dirty, 0, "uint32 uint32 object object string uint32",
00534 GATSTATUS_VERSION1, object->statuscode,
00535 object->messages, clear_dirty, object->children, clear_dirty,
00536 object->filename, object->linenumber);
00537
00538 if (GAT_SUCCEEDED(retval) && clear_dirty)
00539 {
00540 object->isdirty = GATFalse;
00541 }
00542 }
00543 return retval;
00544 }
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560 static GATBool
00561 GATStatus_VersionCallback(GATuint32 version)
00562 {
00563 GATBool retval = GATFalse;
00564 if ((version & ~GATSTATUS_MINOR_MASK) <= GATSTATUS_LASTVERSION)
00565 {
00566 retval = GATTrue;
00567 }
00568 return retval;
00569 }
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594 static GATResult
00595 GATStatus_DeSerialiseCallback(GATContext context, GATObject stream,
00596 GATObject *new_object, GATuint32 version, va_list args)
00597 {
00598
00599
00600 GATuint32 *code = va_arg(args, GATuint32 *);
00601 GATList_String *messages = va_arg(args, GATList_String *);
00602 GATList_GATStatus *children = va_arg(args, GATList_GATStatus *);
00603 char const **filename = va_arg(args, char const **);
00604 GATuint32 *lineno = va_arg(args, GATuint32 *);
00605
00606 GATStatus object = NULL;
00607
00608
00609 GATResult retval = GATStatus_DeSerialise_Create(context, stream, *code,
00610 *messages, *children, *filename, *lineno, &object);
00611 if (GAT_SUCCESS == retval)
00612 {
00613 if (NULL != object)
00614 {
00615 *new_object = GATStatus_ToGATObject(object);
00616 }
00617 else
00618 {
00619 GATStatus_Destroy(&object);
00620 retval = GAT_INVALID_PARAMETER;
00621 }
00622 }
00623 return retval;
00624 }
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640 GATStatus
00641 GATStatus_DeSerialise(GATContext context, GATObject stream, GATResult *result)
00642 {
00643 GAT_USES_STATUS(context, "GATStatus_DeSerialise");
00644 GATObject object = NULL;
00645
00646
00647
00648 GATuint32 version = 0;
00649
00650 GATResult code = 0;
00651 GATList_String messages = NULL;
00652 GATList_GATStatus children = NULL;
00653 char *filename = NULL;
00654 GATuint32 lineno = 0;
00655
00656
00657 GAT_CREATE_STATUS(GATXds_DeSerialiseObject(context, stream,
00658 GATStatus_DeSerialiseCallback, GATStatus_VersionCallback, &object,
00659 "uint32 uint32 object object string uint32", &version, &code, &messages,
00660 &children, &filename, &lineno));
00661
00662 free(filename);
00663 GATList_String_Destroy(&messages);
00664 GATList_GATStatus_Destroy(&children);
00665
00666 if (NULL != result)
00667 {
00668 *result = GAT_RETURN_STATUS();
00669 }
00670 else
00671 {
00672 GAT_STORE_STATUS();
00673 }
00674 return GATObject_ToGATStatus(object);
00675 }
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687 GATResult GATStatus_GetIsDirty(GATStatus_const object, GATBool *isdirty)
00688 {
00689 GATResult retval = GAT_INVALID_HANDLE;
00690 if (NULL != object)
00691 {
00692 if (NULL != isdirty)
00693 {
00694 *isdirty = object->isdirty;
00695 retval = GAT_SUCCESS;
00696 }
00697 else
00698 {
00699 retval = GAT_INVALID_PARAMETER;
00700 }
00701 }
00702 return retval;
00703 }
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724 GATResult
00725 GATStatus_SetStatusCode(GATStatus status, int code)
00726 {
00727 GATResult result = GAT_INVALID_HANDLE;
00728 if (NULL != status)
00729 {
00730 status->statuscode = code;
00731 result = GAT_SUCCESS;
00732 }
00733 return result;
00734 }
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750 GATResult
00751 GATStatus_GetStatusCode(GATStatus_const status)
00752 {
00753 GATResult result = GAT_INVALID_HANDLE;
00754 if (NULL != status)
00755 {
00756 result = status->statuscode;
00757 }
00758 return result;
00759 }
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 GATResult
00778 GATStatus_AddChild(GATStatus status, GATStatus child)
00779 {
00780 GATResult result = GAT_INVALID_HANDLE;
00781 if (NULL != status && NULL != child)
00782 {
00783 if (NULL == status->children)
00784 {
00785
00786 status->children = GATList_GATStatus_Create();
00787 if (NULL == status->children)
00788 {
00789 result = GAT_MEMORYFAILURE;
00790 }
00791 }
00792
00793
00794
00795 if (NULL != status->children)
00796 {
00797
00798 GATList_GATStatus_Iterator end = GATList_GATStatus_End(status->children);
00799 GATList_GATStatus_Iterator item =
00800 GATList_GATStatus_Insert(status->children, end, child);
00801
00802 if (NULL != item)
00803 {
00804
00805 GATStatus new_child = *GATList_GATStatus_Get(item);
00806 new_child->parent = status;
00807 result = GAT_SUCCESS;
00808 }
00809 }
00810 }
00811 return result;
00812 }
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828 GATList_GATStatus_const
00829 GATStatus_GetChildren(GATStatus_const status)
00830 {
00831 GATList_GATStatus result = NULL;
00832 if (NULL != status)
00833 {
00834 result = status->children;
00835 }
00836 return result;
00837 }
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856 GATResult
00857 GATStatus_AddMessage(GATStatus status, char const *message)
00858 {
00859 GATResult result = GAT_INVALID_HANDLE;
00860 if (NULL != status)
00861 {
00862 GATList_String_Iterator item = GATList_String_Insert(
00863 status->messages, GATList_String_End(status->messages), message);
00864
00865 result = (NULL == item) ? GAT_MEMORYFAILURE : GAT_SUCCESS;
00866 }
00867 return result;
00868 }
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883 GATList_String_const
00884 GATStatus_GetMessages(GATStatus_const status)
00885 {
00886 GATList_String result = NULL;
00887 if (NULL != status)
00888 {
00889 result = status->messages;
00890 }
00891 return result;
00892 }
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908 GATStatus_const
00909 GATStatus_GetParent(GATStatus_const status)
00910 {
00911 GATStatus_const result = NULL;
00912 if (NULL != status)
00913 {
00914 result = status->parent;
00915 }
00916 return result;
00917 }
00918
00919
00920
00921
00922
00923
00924
00925
00926 void
00927 GATStatus_Trace(GATStatus_const status)
00928 {
00929 if (NULL != status)
00930 {
00931 fprintf(stderr, "GAT error backtrace:\n");
00932 GATStatus_TraceLevel(stderr, status, 0);
00933 fprintf(stderr, "\n");
00934 fflush(stderr);
00935 }
00936 }
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957 static GATResult
00958 GATStatus_DeSerialise_Create(GATContext context, GATObject stream,
00959 GATResult code, GATList_String messages, GATList_GATStatus children,
00960 char const *filename, GATuint32 lineno, GATStatus *object)
00961 {
00962 GAT_USES_STATUS(context, "GATStatus_DeSerialise_Create");
00963
00964 GATStatus new_object = (GATStatus) malloc(sizeof(struct GATStatus_S));
00965 if(NULL != new_object)
00966 {
00967 memset(new_object, 0, sizeof(struct GATStatus_S));
00968 new_object->GATObject__vtable = &GATStatus__vtable;
00969 new_object->GATSerialisable__vtable = &GATStatus_ISerialisable__vtable;
00970
00971 new_object->isdirty = GATFalse;
00972 new_object->statuscode = code;
00973
00974 strcpy(new_object->filename, filename);
00975 new_object->linenumber = lineno;
00976
00977 GAT_CREATE_STATUS(GATList_String_Clone(messages, &new_object->messages));
00978
00979
00980 if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()) && NULL != children)
00981 {
00982 GAT_CREATE_STATUS(GATList_GATStatus_Clone(children, &new_object->children));
00983
00984 if (NULL != new_object->children)
00985 {
00986 GATList_GATStatus_Iterator it = GATList_GATStatus_Begin(new_object->children);
00987 GATList_GATStatus_Iterator end = GATList_GATStatus_End(new_object->children);
00988
00989 for (; it != end && GAT_SUCCEEDED(GAT_CURRENT_STATUS());
00990 it = GATList_GATStatus_Next(it))
00991 {
00992 GATStatus *child = GATList_GATStatus_Get(it);
00993 GAT_CREATE_STATUS_IF(NULL == child, GAT_FAIL);
00994 GAT_CREATE_STATUS(GATStatus_SetParent(new_object, *child));
00995 }
00996 }
00997 }
00998 }
00999 else
01000 {
01001 GAT_CREATE_STATUS(GAT_MEMORYFAILURE);
01002 }
01003
01004 if (GAT_SUCCEEDED(GAT_CURRENT_STATUS()))
01005 {
01006 if (NULL != new_object)
01007 {
01008 *object = new_object;
01009 }
01010 else
01011 {
01012 GATStatus_Destroy(&new_object);
01013 GAT_CREATE_STATUS(GAT_INVALID_PARAMETER);
01014 }
01015 }
01016 else
01017 {
01018 GATStatus_Destroy(&new_object);
01019 }
01020 return GAT_RETURN_STATUS();
01021 }
01022
01023
01024
01025
01026
01027 static GATResult
01028 GATStatus_SetParent(GATStatus status, GATStatus_const parent)
01029 {
01030 GATResult retval = GAT_INVALID_HANDLE;
01031 if (NULL != status)
01032 {
01033 status->parent = parent;
01034 retval = GAT_SUCCESS;
01035 }
01036 return retval;
01037 }
01038
01039
01040
01041
01042 static void
01043 GATStatus_TraceLevel(FILE *fp, GATStatus_const status, int level)
01044 {
01045 int code = GATStatus_GetStatusCode(status);
01046 char fmt[32];
01047 char buffer[4096];
01048 GATuint32 written = 0;
01049 GATResult retval = GAT_SUCCESS;
01050
01051 if (GAT_SUCCESS != code)
01052 {
01053 retval = GATSelf_ResolveErrorMessage(code, buffer, sizeof(buffer), &written);
01054 }
01055
01056
01057 memset(fmt, 0, sizeof(fmt));
01058 sprintf(fmt, "%%%d.%ds", level, level);
01059
01060
01061 if (GAT_SUCCESS != code)
01062 {
01063 fprintf(fp, fmt, "");
01064 if (strlen(status->filename) > 0)
01065 {
01066 fprintf(fp, "Statuscode: 0x%x (%s) at (%s): %d\n", code,
01067 GAT_SUCCEEDED(retval) ? buffer : "unknown status code",
01068 status->filename, status->linenumber);
01069 }
01070 else
01071 {
01072 fprintf(fp, "Statuscode: 0x%x (%s)\n", code,
01073 GAT_SUCCEEDED(retval) ? buffer : "unknown status code");
01074 }
01075 }
01076
01077
01078 {
01079 GATList_String_const messages = GATStatus_GetMessages(status);
01080 GATList_String_Iterator msg = GATList_String_Begin(messages);
01081 GATList_String_Iterator msg_end = GATList_String_End(messages);
01082 int i;
01083 GATBool first = GATTrue;
01084
01085 for (i = 0; msg != msg_end; msg = GATList_String_Next(msg), ++i)
01086 {
01087 fprintf(fp, fmt, "");
01088 if (GAT_SUCCESS == code && GATTrue == first)
01089 {
01090
01091 fprintf(fp, "Routine: %s\n", GATList_String_Get(msg));
01092 first = GATFalse;
01093 }
01094 else
01095 {
01096 fprintf(fp, " %s\n", GATList_String_Get(msg));
01097 }
01098 }
01099 }
01100
01101
01102 {
01103 GATList_GATStatus_const children = GATStatus_GetChildren(status);
01104 if (NULL != children)
01105 {
01106 GATList_GATStatus_Iterator it = GATList_GATStatus_Begin(children);
01107 GATList_GATStatus_Iterator end = GATList_GATStatus_End(children);
01108 int j;
01109
01110 for (j = 0; it != end; it = GATList_GATStatus_Next(it), ++j)
01111 {
01112 GATStatus child = *GATList_GATStatus_Get(it);
01113
01114
01115 assert(GATStatus_GetParent(child) == status);
01116
01117
01118 GATStatus_TraceLevel(fp, child, level + 1);
01119 }
01120 }
01121 }
01122 }
01123