00001
00002
00003 #include <SUM.h>
00004 #include <soi_key.h>
00005 #include <sys/time.h>
00006 #include <sys/errno.h>
00007 #include <rpc/rpc.h>
00008 #include <sum_rpc.h>
00009 #include <soi_error.h>
00010
00011 extern int errno;
00012
00013
00014
00015
00016
00017 KEY *rlist;
00018 FILE *logfp;
00019 SUM_t *sum;
00020 SUMID_t uid;
00021
00022 int soi_errno = NO_ERROR;
00023 int bytes, msgtag, petid, req_num, status, cnt, i, j, k, inum;
00024 char **cptr;
00025 float ftmp;
00026 uint64_t *dsixpt;
00027 uint64_t alloc_index;
00028 char alloc_wd[64];
00029 char cmd[128];
00030 char mod_name[] = "sum_rpc";
00031 char dsname[] = "hmi_lev1_fd_V";
00032 char hcomment[] = "this is a dummy history comment that is greater than 80 chars long to check out the code";
00033
00034 static struct timeval first[8], second[8];
00035
00036 void StartTimer(int n)
00037 {
00038 gettimeofday (&first[n], NULL);
00039 }
00040
00041 float StopTimer(int n)
00042 {
00043 gettimeofday (&second[n], NULL);
00044 if (first[n].tv_usec > second[n].tv_usec) {
00045 second[n].tv_usec += 1000000;
00046 second[n].tv_sec--;
00047 }
00048 return (float) (second[n].tv_sec-first[n].tv_sec) +
00049 (float) (second[n].tv_usec-first[n].tv_usec)/1000000.0;
00050 }
00051
00052
00053
00054
00055
00056 int main(int argc, char *argv[])
00057 {
00058
00059
00060 if(argc != 2) {
00061 printf("Usage: sumget ds_index\n");
00062 return 0;
00063 }
00064
00065
00066 if((sum = SUM_open(NULL, NULL, printf)) == 0) {
00067 printf("Failed on SUM_open()\n");
00068 exit(1);
00069 }
00070 uid = sum->uid;
00071
00072
00073 sum->username = "production";
00074
00075 printf("Opened with sumid = %d\n", uid);
00076
00077
00078
00079 sum->mode = RETRIEVE + TOUCH;
00080 sum->tdays = 10;
00081 sum->reqcnt = 1;
00082 dsixpt = sum->dsix_ptr;
00083 *dsixpt = atol(argv[1]);
00084
00085 StartTimer(1);
00086 status = SUM_get(sum, printf);
00087 ftmp = StopTimer(1);
00088 printf("Time SUM_get = %fsec\n", ftmp);
00089 switch(status) {
00090 case 0:
00091 cnt = sum->reqcnt;
00092 cptr = sum->wd;
00093
00094 for(i = 0; i < cnt; i++) {
00095 printf("wd = %s\n", *cptr++);
00096 }
00097 break;
00098 case 1:
00099 printf("Failed on SUM_get()\n");
00100 break;
00101 case RESULT_PEND:
00102 printf("SUM_get() call RESULT_PEND...\n");
00103
00104 while(1) {
00105 if(!SUM_poll(sum)) break;
00106 }
00107
00108 if(status = sum->status) {
00109 printf("***Error on SUM_get() call. tape_svc may have died or\n");
00110 printf("check /usr/local/logs/SUM/ logs for possible tape errs\n\n");
00111 break;
00112 }
00113 cnt = sum->reqcnt;
00114 cptr = sum->wd;
00115 printf("The wd's found from the SUM_get() call are:\n");
00116 for(i = 0; i < cnt; i++) {
00117 printf("wd = %s\n", *cptr++);
00118 }
00119 break;
00120 default:
00121 printf("Error: unknown status from SUM_get()\n");
00122 break;
00123 }
00124
00125 SUM_close(sum, printf);
00126 if(status) printf("Error exit\n");
00127 else printf("Normal exit\n");
00128 }