Ejemplo n.º 1
0
/*--------------------------------------------------------------
	Shot number identifier converted to string.
*/
int				Tdi3Shotname(
struct descriptor		*in_ptr,
struct descriptor_xd	*out_ptr)
{
struct descriptor *dummy = in_ptr;
int	value;
int	retlen, status;
struct dbi_itm lst[] = {{sizeof(value),DbiSHOTID,0,0},{0,DbiEND_OF_LIST,0}};
DESCRIPTOR(dmodel, "MODEL");
char	string[15];
        lst[0].pointer = (unsigned char *)&value;
        lst[0].return_length_address = &retlen;
	status = TreeGetDbi(lst);
	if (value != -1) {
		sprintf(string, "%ld", value);
		dmodel.pointer = string;
		dmodel.length = (unsigned short)strlen(string);
	}
	if (status & 1) status = MdsCopyDxXd((struct descriptor *)&dmodel, out_ptr);
	return status;
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------
	Shot number identifier.
*/
int				Tdi3Shot(
struct descriptor		*in_ptr,
struct descriptor_xd	*out_ptr)
{
struct descriptor *dummy = in_ptr;
int	value;
int	retlen, status;
STATIC_CONSTANT unsigned char dtype = (unsigned char)DTYPE_L;
struct dbi_itm lst[] = {{sizeof(value),DbiSHOTID,0,0},{0,DbiEND_OF_LIST,0}};
unsigned short len;
        lst[0].pointer = (unsigned char *)&value;
        lst[0].return_length_address = &retlen;
	status = TreeGetDbi(lst);
	if (status & 1)
        {
          len = (unsigned short)retlen;
          status = MdsGet1DxS(&len, &dtype, out_ptr);
	}
        if (status & 1) *(int *)out_ptr->pointer->pointer = value;
	return status;
}
Ejemplo n.º 3
0
/*--------------------------------------------------------------
	Experiment name.
*/
int				Tdi3Expt(
struct descriptor		*in_ptr,
struct descriptor_xd	*out_ptr)
{
struct descriptor *dummy = in_ptr;
char	value[39-7];
int	retlen, status;
STATIC_CONSTANT unsigned char dtype = (unsigned char)DTYPE_T;
struct dbi_itm lst[] = {{sizeof(value),DbiNAME,0,0},{0,DbiEND_OF_LIST,0}};
unsigned short len;
        lst[0].pointer = (unsigned char *)value;
        lst[0].return_length_address = &retlen;
	status = TreeGetDbi(lst);
	if (status & 1)
        {
          len = (unsigned short)retlen;
          status = MdsGet1DxS(&len, &dtype, out_ptr);
        }
	if (status & 1) memcpy(out_ptr->pointer->pointer, value, len);
	return status;
}
Ejemplo n.º 4
0
int Tdi1GetDbi(int opcode, int narg, struct descriptor *list[],
               struct descriptor_xd *out_ptr)
{
    int status = 1;
    struct descriptor_d string = { 0, DTYPE_T, CLASS_D, 0 };
    struct descriptor_xd tmp = EMPTY_XD;
    struct item *key_ptr = 0;
    int index;
    DBI_ITM lst[] = { {sizeof(index), DbiINDEX, 0, 0}
    , EOL, EOL };
    lst[0].pointer = (unsigned char *)&index;
        /**********************
        String of item to find.
        **********************/
    status = TdiData(list[0], &tmp MDS_END_ARG);
    if (status & 1)
        status = TdiUpcase(&tmp, &string MDS_END_ARG);
    if (status & 1) {
        key_ptr =
            (struct item *)bsearch(&string, table, numtab, siztab,
                                   (int (*)(const void *, const void *))
                                   compare);
        if (key_ptr == 0)
            status = TdiBAD_INDEX;
    }
    StrFree1Dx(&string);
    MdsFree1Dx(&tmp, NULL);
        /**********************************
        Somebody might want others in pool.
        **********************************/
    if (status & 1 && narg > 1)
        status = TdiGetLong(list[1], &index);
    else
        index = 0;
        /***********************
        Get the item asked for.
        Fixed length or varying.
        ***********************/
    if (status & 1) {
        lst[1].code = key_ptr->item_code;
        if ((lst[1].buffer_length = key_ptr->item_length) != 0) {
            status =
                MdsGet1DxS((unsigned short *)&lst[1].buffer_length,
                           &key_ptr->item_dtype, out_ptr);
            if (status & 1) {
                lst[1].pointer = (unsigned char *)out_ptr->pointer->pointer;
                status = TreeGetDbi(lst);
            }
        } else {
            lst[1].buffer_length = 0;
            lst[1].pointer = NULL;
            status = TreeGetDbi(lst);
            if (status & 1) {
                struct descriptor ans = { 0, DTYPE_T, CLASS_S, 0 };
                if (lst[1].pointer) {
                    ans.length = strlen((char *)lst[1].pointer);
                    ans.pointer = (char *)lst[1].pointer;
                }
                status = MdsCopyDxXd(&ans, out_ptr);
                if (ans.pointer)
                    TreeFree(ans.pointer);
            }
        }
    }
    return status;
}
Ejemplo n.º 5
0
int Tdi1Using(int opcode, int narg, struct descriptor *list[],
              struct descriptor_xd *out_ptr)
{
    int status = 1;
    void *ctx;
    int reset_ctx = 0;
    int nid, shot, stat1;
    struct descriptor def = { 0, DTYPE_T, CLASS_D, 0 }, expt = def;
    unsigned char omits[] = { DTYPE_PATH, 0 };

        /**********************
        Evaluate with current.
        Use current if omitted.
        Must get expt if shot.
        **********************/
    if (narg > 1 && status & 1) {
        if (list[1]) {
            struct descriptor_xd xd = EMPTY_XD;
            status = TdiGetData(omits, list[1], &xd);
            if (status & 1 && xd.pointer)
                switch (xd.pointer->dtype) {
                case DTYPE_T:
                case DTYPE_PATH:
                    status = StrCopyDx(&def, xd.pointer);
                    break;
                default:
                    status = TdiINVDTYDSC;
                    break;
                }
            MdsFree1Dx(&xd, NULL);
        }
        if (!list[1] || def.length == 0) {
            DBI_ITM def_itm[] = { {0, DbiDEFAULT, 0, 0}
            , EOL };
            status = TreeGetDbi(def_itm);
            if (def_itm[0].pointer == NULL) {
                STATIC_CONSTANT DESCRIPTOR(top, "\\TOP");
                StrCopyDx(&def, &top);
                status = 1;
            } else {
                unsigned short len =
                    (unsigned short)strlen((char *)def_itm[0].pointer);
                StrCopyR(&def, &len, def_itm[0].pointer);
                TreeFree(def_itm[0].pointer);
            }
            if (status & 1) {
                stat1 = StrPosition(&def, &coloncolon, 0) + 1;
                status = StrRight(&def, &def, &stat1);
            }
            if (status & 1)
                *def.pointer = '\\';
        }
    }
    if ((narg > 2) && ((list[2] != 0) || ((narg > 3) && (list[3] != 0)))
        && ((status & 1) != 0)) {
        if (list[2])
            status = TdiGetLong(list[2], &shot);
        else {
            DBI_ITM shot_itm[] = { {sizeof(shot), DbiSHOTID, 0, 0}
            , EOL };
            shot_itm[0].pointer = (unsigned char *)&shot;
            status = TreeGetDbi(shot_itm);
        }

        if (status & 1) {
            if (narg > 3 && list[3])
                status = TdiData(list[3], &expt MDS_END_ARG);
            else {
                DBI_ITM expt_itm[] = { {0, DbiNAME, 0, 0}
                , EOL };
                status = TreeGetDbi(expt_itm);
                if (expt_itm[0].pointer) {
                    unsigned short len =
                        (unsigned short)strlen((char *)expt_itm[0].pointer);
                    StrCopyR(&expt, &len, expt_itm[0].pointer);
                    TreeFree(expt_itm[0].pointer);
                }
            }
        }
                /*********************
                Set new tree and path.
                Allow some rel paths.
                *********************/
        if (status & 1) {
            char *tree = MdsDescrToCstring(&expt);
            ctx = TreeSwitchDbid(0);
            reset_ctx = 1;
            status = TreeOpen(tree, shot, 1);
            MdsFree(tree);
        }
    }
    if (narg > 1) {
        char *path = MdsDescrToCstring(&def);
        if (status & 1)
            status = TreeSetDefault(path, &nid);
        MdsFree(path);
        if (narg > 2)
            StrFree1Dx(&expt);
        StrFree1Dx(&def);
    }
        /***********************
        Evaluate with temporary.
        ***********************/
    if (status & 1) {
        struct descriptor_xd tmp = EMPTY_XD;
        status = TdiEvaluate(list[0], &tmp MDS_END_ARG);
        if (status & 1)
            status = MdsCopyDxXdZ((struct descriptor *)&tmp, out_ptr, NULL,
                                  fixup_nid, NULL, fixup_path, NULL);
        MdsFree1Dx(&tmp, NULL);
    }
    if (reset_ctx) {
        while (TreeClose(0, 0) & 1) ;
        TreeFreeDbid(TreeSwitchDbid(ctx));

    }
    return status;
}