![]() |
![]() |
The example in Figure 19 demonstrates using the API functions to retrieve data from TSM storage. The dsmBeginGetData function call appears inside a switch statement, so that different parameters can be called depending on whether a restore or retrieve operation is being performed. The dsmGetData function call is called from inside a loop that repeatedly gets data from the server until a flag is set that permits the program execution to exit the loop.
Figure 19. An Example of Receiving Data from a Server
+--------------------------------------------------------------------------------+
|/* Call dsmBeginQuery and create a linked list of objects to restore. */ |
|/* Process this list to create the proper list for the GetData calls. */ |
|/* Set up the getList structure to point to this list. */ |
|/* This example is set up to perform a partial object retrieve. To */ |
|/* retrieve only complete objects, set up: */ |
|/* getList.stVersion = dsmGetListVersion; */ |
|/* getList.partialObjData = NULL; */ |
| |
|dsmGetList getList; |
| |
|getList.stVersion = dsmGetListPORVersion; /* structure version */ |
|getList.numObjId = items; /* number of items in list */ |
|getList.objId = (ObjID *)rest_ibuff; |
| /* list of object IDs to restore */ |
|getList.partialObjData = (PartialObjData *) part_ibuff; |
| /* list of partial object data */ |
|switch(get_type) |
|{ |
| case (Restore_Get) : |
| rc = dsmBeginGetData(dsmHandle,bFalse,gtBackup,&getList); |
| break; |
| case (Retrieve_Get) : |
| rc = dsmBeginGetData(dsmHandle,bFalse,gtArchive,&getList); |
| break; |
| default : ; |
|} |
|if (rc) |
|{ |
| printf("*** dsmBeginGetData failed: "); |
| rcApiOut(dsmHandle, rc); |
| return rc; |
|} |
|/* Get each object from the list and verify whether it is on the */ |
|/* server. If so, initialize structures with object attributes for */ |
|/* data validation checks. When done, call dsmGetObj. */ |
| rc = dsmGetObj(dsmHandle,objId,&dataBlk); |
| |
| |
| |
+--------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------+
|done = bFalse; |
|while(!done) |
|{ |
| if ( (rc == DSM_RC_MORE_DATA) |
| || (rc == DSM_RC_FINISHED)) |
| { |
| if (rc == DSM_RC_MORE_DATA) |
| { |
| dataBlk.numBytes = 0; |
| rc = dsmGetData(dsmHandle,&dataBlk); |
| } |
| else |
| done = bTrue; |
| } |
| else |
| { |
| printf("*** dsmGetObj or dsmGetData failed: "); |
| rcApiOut(dsmHandle, rc); |
| done = bTrue; |
| } |
|} /* while */ |
|rc = dsmEndGetObj(dsmHandle); |
|/* check rc from dsmEndGetObj */ |
|/* check rc from dsmEndGetData */ |
|rc = dsmEndGetData(dsmHandle); |
|return 0; |
+--------------------------------------------------------------------------------+