00001 #include "drms.h"
00002 #include <printk.h>
00003 #ifdef __linux__
00004 #include <sched.h>
00005 #endif
00006
00007 ModuleArgs_t module_args[] =
00008 {
00009 {ARG_INTS, "sunum", NULL , "SU number", ""},
00010 {ARG_INT, "retention", NULL, "Retention in days", ""},
00011 {ARG_END}
00012 };
00013
00014 ModuleArgs_t *gModArgs = module_args;
00015 CmdParams_t cmdparams;
00016
00017 int main(int argc, char *argv[])
00018 {
00019
00020 int sunumvals = 0;
00021 long long *sunum;
00022 char key[4000];
00023 int retention = 0;
00024 int i = 0;
00025
00026 char *sudir=(char *) NULL;
00027 SUM_t *sum=NULL;
00028 uint64_t *dsixpt;
00029 int status = 0;
00030
00031 if ((status = cmdparams_parse(&cmdparams, argc, argv)) < CMDPARAMS_SUCCESS)
00032 {
00033 fprintf(stderr,"Error: Command line parsing failed. Aborting. [%d]\n", status);
00034 return -1;
00035 }
00036
00037
00038
00039 if ((sum = SUM_open(NULL, NULL, printkerr)) == NULL)
00040 {
00041 fprintf(stderr,"ERROR: drms_open: Failed to connect to SUMS.\n");
00042 fflush(stdout);
00043 return -2;
00044 }
00045
00046 sum->mode = TEMP + TOUCH;
00047 sum->tdays=retention;
00048 dsixpt = sum->dsix_ptr;
00049
00050 fprintf (stdout, "sunumvals = %d\n", sunumvals = cmdparams_get_int64 (&cmdparams, "sunum_nvals",NULL));
00051 sum->reqcnt=sunumvals;
00052 sunum = (long long *)malloc (sunumvals * sizeof (long long));
00053 for (i = 0; i < sunumvals; i++) {
00054 sprintf (key, "sunum_%d_value", i);
00055 sunum[i] = cmdparams_get_int64 (&cmdparams, key,NULL);
00056 dsixpt[i] = sunum[i];
00057 printf ("sunum[%d] = %llu\n", i, sunum[i]);
00058 }
00059
00060 retention = cmdparams_get_int64(&cmdparams, "retention", NULL);
00061
00062
00063 if ((status = SUM_get(sum, printkerr)))
00064 {
00065 fprintf(stderr,"ERROR: SUM_getdo RPC call failed with "
00066 "error code %d\n", status);
00067
00068 if (sum)
00069 {
00070 SUM_close(sum, printkerr);
00071 }
00072
00073 return -3;
00074 }
00075
00076 for (i =0; i< sunumvals; i++) {
00077 sudir = strdup(sum->wd[i]);
00078 fprintf(stdout, "sunum:%llu;sudir:%s\n",sunum[i],sudir);
00079 }
00080
00081 SUM_close(sum, printkerr);
00082
00083 free(sum->wd[0]);
00084
00085 return 0;
00086 }
00087