예제 #1
0
int thGetList_test(int handle, CLIENT *clnt, char *test_condition,
                   int max_time_wait, int max_event_wait)
#endif
/* Returns 0 for total success, -1 for total failure, a positive number
for the number of variables that didn't work */
{
    thNameList *list;
    thNameNode *next,*this;
    int i;
    int *status;
    TESTNAMELIST *arg;
    int servret;
#ifdef BIT64
    CLIENT *clnt;

    clnt = clnt_list[client-1];
#endif

    /* Can return some kind of error if pending_arg is not zero */
#ifdef BIT64
    list = (thNameList *) handle_list[handle-1];
#else
    list = (thNameList *) handle;
#endif
    /*  printf("list->nnames=%d\n",list->nnames);*/
    if(!list->rpc_made) {
        if(list->rpc.NAMELIST_len == 0) {
            list->rpc.NAMELIST_len = list->nnames;
            list->rpc.NAMELIST_val = (char **) malloc(list->rpc.NAMELIST_len
                                     *sizeof(char *));
        } else if (list->rpc.NAMELIST_len != list->nnames) {
            list->rpc.NAMELIST_len = list->nnames;
            list->rpc.NAMELIST_val = (char **)
                                     realloc(list->rpc.NAMELIST_val,list->rpc.NAMELIST_len*sizeof(char *));
        }
        this = list->namehead;
        for(i=0; (i<list->nnames && this); i++) {
            list->rpc.NAMELIST_val[i] = this->name;
            this = this->next;
        }
    }
    arg = (TESTNAMELIST *) malloc(sizeof(TESTNAMELIST));
    arg->test_condition = (char *) malloc(strlen(test_condition)+1);
    strcpy(arg->test_condition,test_condition);
    arg->max_time_wait = max_time_wait;
    arg->max_event_wait = max_event_wait;
    arg->prog = DAVARSVR;
    arg->vers = DAVARVERS+1;
    arg->NAMELISTP = &list->rpc;
    pending_arg = arg;
    pending_flag = 1;

    if(!(status = davar_readmultiple_test_1(arg,clnt)))
        return(-1);

    /* Now wait for the incoming network call */

    servret = 1;
    while(pending_flag && servret > 0) /* Wait for timeout, completion or failur*/
        servret = daVarServOnce(arg->max_time_wait+10); /* Will wait double?? */
    if(servret == 0) callback_result = -2;	/* Timeout */
    else if(servret == -1) callback_result = -3;

    free(arg->test_condition);
    free(arg);
    pending_arg = 0;

    return(callback_result);
}
예제 #2
0
int *davar_readmultiple_test_1_svc(TESTNAMELIST *argp, struct svc_req *svc)
{
    CLIENT *clnt;
    return(davar_readmultiple_test_1(argp,clnt));
}