00001
00002
00003
00004
00005
00006
00007 #include "rodsClient.h"
00008 #include "rdaHighLevelRoutines.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 rodsEnv myEnv;
00021
00022
00023 int
00024 main(int argc, char **argv) {
00025 int status;
00026 rsComm_t *Comm;
00027 rodsArguments_t myRodsArgs;
00028 char *mySubName;
00029 char *myName;
00030 int didOne;
00031
00032 Comm = (rsComm_t*)malloc (sizeof (rsComm_t));
00033 memset (Comm, 0, sizeof (rsComm_t));
00034
00035 parseCmdLineOpt(argc, argv, "", 0, &myRodsArgs);
00036
00037 rodsLogLevel(LOG_NOTICE);
00038
00039 rodsLogSqlReq(1);
00040
00041 if (argc < 4) {
00042 printf("Usage: test_rda username pw testName [args...]\n");
00043 exit(3);
00044 }
00045
00046 status = getRodsEnv (&myEnv);
00047 if (status < 0) {
00048 rodsLog (LOG_ERROR, "main: getRodsEnv error. status = %d",
00049 status);
00050 exit (1);
00051 }
00052
00053 if (strstr(myEnv.rodsDebug, "RDA") != NULL) {
00054 rdaDebug(myEnv.rodsDebug);
00055 }
00056
00057 status = rdaOpen(argv[1]);
00058 if (status != 0) {
00059 rodsLog (LOG_SYS_FATAL,
00060 "test_rda: rdaopen Error. Status = %d",
00061 status);
00062 free( Comm );
00063 return (status);
00064 }
00065
00066 didOne=0;
00067
00068 if (strcmp(argv[2],"sql")==0) {
00069 char *parms[50];
00070 int i, nParms;
00071 for (i=4;i<argc;i++) {
00072 parms[i-4]=argv[i];
00073 }
00074 nParms = i-4;
00075 status = rdaSqlNoResults(argv[3], parms, nParms);
00076 didOne=1;
00077 }
00078
00079 if (strcmp(argv[2],"sqlr")==0) {
00080 char *parms[50];
00081 int i, nParms;
00082 char *outBuf;
00083 for (i=4;i<argc;i++) {
00084 parms[i-4]=argv[i];
00085 }
00086 nParms = i-4;
00087 status = rdaSqlWithResults(argv[3], parms, nParms, &outBuf);
00088 if (status) {
00089 printf("error %d\n", status);
00090 }
00091 else {
00092 printf("%s",outBuf);
00093 }
00094 didOne=1;
00095 }
00096
00097 if (status != 0) {
00098 myName = rodsErrorName(status, &mySubName);
00099 rodsLog (LOG_ERROR, "%s failed with error %d %s %s", argv[1],
00100 status, myName, mySubName);
00101 }
00102 else {
00103 status = rdaClose();
00104 if (status) {
00105 printf("rdaClose error %d\n",status);
00106 }
00107 else {
00108 if (didOne) printf("Completed successfully\n");
00109 }
00110 }
00111
00112 if (didOne==0) {
00113 printf("Unknown test type: %s\n", argv[3]);
00114 }
00115
00116 exit(status);
00117 }