Example #1
0
int *davar_readmultiple_test_cb_1(RVALLIST *vals, CLIENT *clnt)
{
    static int result;

    TESTNAMELIST *argp;
    thNameNode *next,*this;
    int i;

    if(pending_arg) argp = pending_arg;
    else {
        pending_flag = 0;
        return(&result);		/* What error code ?? */
    }

    callback_result = 0;
    if(argp->NAMELISTP->NAMELIST_len == vals->RVALLIST_len) {
        for(i=0; (i<argp->NAMELISTP->NAMELIST_len); i++) {
            /*      printf("%s\n",this->name);*/
            if(vals->RVALLIST_val[i].valtype != DAVARERROR_RPC) {
                if(daVarWriteVar(argp->NAMELISTP->NAMELIST_val[i]
                                 ,&(vals->RVALLIST_val[i])) != S_SUCCESS)
                    callback_result++;
            } else {
                callback_result++;
            }
        }
    } else if (vals->RVALLIST_len>0) {
        printf("Lengths: %d %d",argp->NAMELISTP->NAMELIST_len,vals->RVALLIST_len);
        callback_result = -1;
    } else {
        callback_result = -2;       /* Server send timeout signal */
    }
    pending_flag = 0;
    return(&result);
}
Example #2
0
int thPutList(int handle, CLIENT *clnt)
#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;
    WVALLIST vals;
    int nerrors;
#ifdef BIT64
    CLIENT *clnt;

    clnt = clnt_list[client-1];
#endif

    /* Create the write structure */
#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;
        }
    }
    nerrors = 0;
    if(vals = davar_readmultiple_1(&(list->rpc),clnt)) {
        this = list->namehead;
        /*    printf("list->rpc.NAMELIST_len=%d\n",list->rpc.NAMELIST_len);*/
        for(i=0; (i<list->rpc.NAMELIST_len && this); i++) {
            /*      printf("%s\n",this->name);*/
            if(vals->RVALLIST_val[i].valtype != DAVARERROR_RPC) {
                if(daVarWriteVar(this->name,&(vals->RVALLIST_val[i])) != S_SUCCESS)
                    nerrors++;
            } else {
                nerrors++;
            }
            this = this->next;
        }
    } else {
        nerrors = -1;
    }
    return(nerrors);
}
Example #3
0
ERRLIST *davar_writemultiple_1(WVALLIST *argp, CLIENT *clnt)
{
    static ERRLIST result;
    int i;

    xdr_free(xdr_ERRLIST, (void *) &result);

    result.ERRLIST_len = argp->WVALLIST_len;
    result.ERRLIST_val = (int *) malloc(result.ERRLIST_len*sizeof(any));

    for(i=0; i<argp->WVALLIST_len; i++) {
        result.ERRLIST_val[i] =
            daVarWriteVar(argp->WVALLIST_val[i].name,argp->WVALLIST_val[i].val);
    }
    return(&result);
}
Example #4
0
int thImportVars(char *pattern, CLIENT *clnt)
#endif
/* Returns 0 for total success, -1 for total failure, a positive number
for the number of variables that didn't work */
{
    WVALLIST *vals;
    int count;

    thNameList *list;
    thNameNode *next,*this;
    int i;
    int nerrors;
#ifdef BIT64
    CLIENT *clnt;

    clnt = clnt_list[client-1];
#endif

    /* need to initialize the hash tables */

    if(!(vals = davar_readpatternmatch_1(&pattern,clnt))) {
        return(-1);			/* Failed */
    }

    count = vals->WVALLIST_len;
    /*printf("daVarImportVars got %d variables matching %s\n",count,pattern);*/
    nerrors = 0;
    for(i=0; i<count; i++) {
        char *name;
        int valtype;
        daVarStruct var;

        name = vals->WVALLIST_val[i].name;
        /*printf("%d: %s\n",i,name);*/
        /* Don't do anything if it already exists */
        if(daVarWriteVar(name,vals->WVALLIST_val[i].val) == S_SUCCESS) continue;
        var.type = vals->WVALLIST_val[i].val->valtype;
        if(var.type == DAVARERROR_RPC) {
            printf("Error getting %s\n",name);
            nerrors++;
            continue;
        }
        var.name = name;
        /*printf("Vartype = %d\n",var.type);*/
        switch(var.type)
        {
        case DAVARINT_RPC:
            var.size = vals->WVALLIST_val[i].val->any_u.i.i_len;
            /*printf("size=%d\n",var.size);*/
            var.varptr = (void *) malloc(var.size*sizeof(DAINT));
            break;
        case DAVARFLOAT_RPC:
            var.size = vals->WVALLIST_val[i].val->any_u.r.r_len;
            /*printf("size=%d\n",var.size);*/
            var.varptr = (void *) malloc(var.size*sizeof(DAFLOAT));
            break;
        case DAVARDOUBLE_RPC:
            var.size = vals->WVALLIST_val[i].val->any_u.d.d_len;
            /*printf("size=%d\n",var.size);*/
            var.varptr = (void *) malloc(var.size*sizeof(DADOUBLE));
            break;
        case DAVARSTRING_RPC:
            var.size = strlen(vals->WVALLIST_val[i].val->any_u.s) + 1;
            /*printf("size=%d\n",var.size);*/
            var.varptr = malloc(var.size);
            break;
        }
        var.opaque = 0;
        var.rhook = 0;
        var.whook = 0;
        var.flag = DAVAR_REPOINTOK | DAVAR_DYNAMIC_PAR;
        var.flag = DAVAR_REPOINTOK | DAVAR_DYNAMIC_PAR;
        var.title = 0;
        daVarRegister((int) 0, &var);
        /*    free(var.name);*/
        if(daVarWriteVar(name,vals->WVALLIST_val[i].val) != S_SUCCESS) {
            printf("daVarWriteVar of %s should have worked\n",name);
            nerrors++;
        }
    }
    return(nerrors);
}