📄 dsd_access.c
字号:
ctx->segment_DSD_ptr = /* Get segment DSD pointer */ find_std_segment_dsd(ctx->segment_ptr->type, ctx->segment_ptr->subtype);if (ctx->segment_DSD_ptr == DD$UNKNOWN_SEGMENT) return DD$UNKNOWN_SEGMENT;ctx->segment_VALID_code = DD$VALID; /* Get segment validity code */ctx->item_DSD_ptr = &std_items[std_seg_items[ctx->segment_DSD_ptr->SEG_ITEM_IX].ITEM_IX];ctx->item_ptr = (DD$BYTE *)ctx->segment_ptr + /* data_item ptr */ DD$HEADER_BYTES + DD$VALID_BYTES(DD$ELEMENT_COUNT);ctx->item_ptr = fld_align(ctx->item_ptr, ctx->item_DSD_ptr->TYPE);ctx->item_VALID_code = get_validity_code(ctx); /* data-item validity code */ /* Initialize the register information */if (ctx->item_DSD_ptr->TYPE == DT_SHORT_REGISTER || ctx->item_DSD_ptr->TYPE == DT_REGISTER) { if (ctx->item_DSD_ptr->COUNT != 0) { ctx->curr_field = 1; /* Initialize the current field */ ctx->field_position = 0; ctx->field_DSD_ptr = &std_regs[ctx->item_DSD_ptr->INDEX]; if (ctx->field_DSD_ptr->TYPE == DC_CODED && ctx->field_DSD_ptr->COUNT != 0) ctx->code_DSD_ptr = &std_codes[ctx->field_DSD_ptr->CODE_IX]; } } /* Initialize the coded information */if (ctx->item_DSD_ptr->TYPE == DT_TINY_INDEX || ctx->item_DSD_ptr->TYPE == DT_SHORT_INDEX || ctx->item_DSD_ptr->TYPE == DT_INDEXED) if (ctx->item_DSD_ptr->COUNT != 0) ctx->code_DSD_ptr = &std_codes[ctx->item_DSD_ptr->INDEX];return DD$SUCCESS;}/***********************************************************************++** get_next_item_dsd**** o Description**** This function updates the data-item fields of the CTX with the** definition of the next element in the data-segment.**** o Return values**** DD$SUCCESS - Function completed successfully.** DD$END_OF_SEGMENT - No more elements in the data-segment.** DD$UNKNOWN_ITEM - Can not find the definition for an item!** Indicates that the DSD tables are corrupted!**** o Synopses**** #include "generic_dsd.h"** #include "std_dsd.h"**** long get_next_item_dsd (ctx)** DD$STD_DSD_CTX *ctx;**** o Remarks**** A call must have been made to "get_std_segment_dsd" to initialize** CTX before using this function.**** o Example****--*/long get_next_item_dsd (ctx)DD$STD_DSD_CTX *ctx;{ /* Update the data-item pointer */ /* depending on old data-type */ctx->item_ptr += get_item_size (ctx->item_DSD_ptr->TYPE, ctx->item_DSD_ptr->COUNT); /* Check for end of segment */if (ctx->curr_item >= ctx->segment_DSD_ptr->COUNT) return DD$END_OF_SEGMENT; /* Update the CTX for next item */ /* Get the new item_DSD_ptr */ctx->item_DSD_ptr = &std_items[std_seg_items[ctx->segment_DSD_ptr->SEG_ITEM_IX + ctx->curr_item++].ITEM_IX];ctx->item_ptr = fld_align(ctx->item_ptr, ctx->item_DSD_ptr->TYPE); /* Get data-item validity code */ctx->item_VALID_code = get_validity_code(ctx); /* Initialize the register information */if (ctx->item_DSD_ptr->TYPE == DT_SHORT_REGISTER || ctx->item_DSD_ptr->TYPE == DT_REGISTER) { if (ctx->item_DSD_ptr->COUNT != 0) { ctx->curr_field = 1; /* Initialize the current field */ ctx->field_position = 0; ctx->field_DSD_ptr = &std_regs[ctx->item_DSD_ptr->INDEX]; if (ctx->field_DSD_ptr->TYPE == DC_CODED && ctx->field_DSD_ptr->COUNT != 0) ctx->code_DSD_ptr = &std_codes[ctx->field_DSD_ptr->CODE_IX]; } } /* Initialize the coded information */if (ctx->item_DSD_ptr->TYPE == DT_TINY_INDEX || ctx->item_DSD_ptr->TYPE == DT_SHORT_INDEX || ctx->item_DSD_ptr->TYPE == DT_INDEXED) if (ctx->item_DSD_ptr->COUNT != 0) ctx->code_DSD_ptr = &std_codes[ctx->item_DSD_ptr->INDEX];return DD$SUCCESS;}/***********************************************************************++** get_next_field_dsd**** o Description**** This function updates the register field information in the CTX** with the definition of the next field in the register currently** pointed to by the CTX.**** o Return_values**** DD$SUCCESS - Function completed successfully.** DD$END_OF_REGISTER - No more fields in the register.** DD$NOT_A_REGISTER - The CTX doesn't currently point to a** data-item having a REGISTER or** SHORT_REGISTER data_type.**** o Synopses**** #include "generic_dsd.h"** #include "std_dsd.h"**** long get_next_field_dsd (ctx)** DD$STD_DSD_CTX *ctx;**** o Remarks**** o Example****--*/long get_next_field_dsd (ctx)DD$STD_DSD_CTX_PTR ctx;{ /* Check that item is a register */if (ctx->item_DSD_ptr->TYPE != DT_SHORT_REGISTER && ctx->item_DSD_ptr->TYPE != DT_REGISTER) { printf("\n\"get_next_field_dsd\" called with non-register item!\n"); return DD$NOT_A_REGISTER; };if (ctx->curr_field >= ctx->item_DSD_ptr->COUNT) return DD$END_OF_REGISTER; /* Update the CTX for next field */ctx->field_position += ctx->field_DSD_ptr->SIZE; /* Get the new field DSD */ctx->field_DSD_ptr = &std_regs[ctx->item_DSD_ptr->INDEX + ctx->curr_field++]; /* Initialize the coded information */if (ctx->field_DSD_ptr->TYPE == DC_CODED) ctx->code_DSD_ptr = &std_codes[ctx->field_DSD_ptr->CODE_IX];return DD$SUCCESS;}/***********************************************************************++** decode_std_item** ** o Description** ** Returns a pointer to the text string corresponding to the** standard code for the data-item currently pointed at by the** context block.**** Returns DD$UNKNOWN_CODE if the code isn't valid for the item.** ** o Synopses** ** #include "generic_dsd.h"** #include "std_dsd.h"** ** char *decode_std_item (ctx, item_code)** DD$STD_DSD_CTX *ctx;** short item_code;** ** o Remarks** ** o Example****--*/char *decode_std_item (ctx, item_code)DD$STD_DSD_CTX_PTR ctx;long item_code;{long i;for (i=0; i < ctx->item_DSD_ptr->COUNT; i++) { if (ctx->code_DSD_ptr[i].CODE == item_code) return dsd_get_label(ctx->code_DSD_ptr[i].LABEL_IX); }return DD$UNKNOWN_CODE;}/***********************************************************************++** decode_register_field** ** o Description** ** Returns a pointer to the text string corresponding to the** code for the register field currently pointed at by the** context block.**** Returns DD$NO_TRANSLATION if the code isn't to be translated.** ** o Synopses** ** #include "generic_dsd.h"** #include "std_dsd.h"** ** char *decode_register_field (ctx, field_code)** DD$STD_DSD_CTX *ctx;** long field_code;** ** o Remarks** ** o Example****--*/char *decode_register_field (ctx, field_code)DD$STD_DSD_CTX *ctx;long field_code;{long i;for (i=0; i < ctx->field_DSD_ptr->COUNT; i++) { if (ctx->code_DSD_ptr[i].CODE == field_code) return dsd_get_label(ctx->code_DSD_ptr[i].LABEL_IX); };return DD$NO_TRANSLATION;}/***********************************************************************++** get_reg_fld_code** ** o Description** ** Returns a pointer to the text string corresponding to the** input code for the requested register field of teh requested** item.**** Returns DD$NO_TRANSLATION if the code isn't to be translated.** ** o Synopses** ** #include "generic_dsd.h"** #include "std_dsd.h"** ** char *get_reg_fld_code (item_id, fld_ix, fld_code)** long item_id;** long fld_ix** long fld_code;** ** o Remarks** ** o Example****--*/char *get_reg_fld_code(item_id, fld_ix, fld_code)long item_id;long fld_ix;long fld_code;{DD$STD_CODES_DSD_PTR code_dsd;DD$STD_REGS_DSD_PTR reg_dsd;DD$STD_ITEMS_DSD_PTR item_dsd;long i;if ((item_dsd = find_std_item_dsd(item_id)) == DD$UNKNOWN_ITEM) return DD$NO_TRANSLATION;if (item_dsd->COUNT < fld_ix) return DD$NO_TRANSLATION;reg_dsd = get_reg_dsd(item_dsd->INDEX + fld_ix);if (reg_dsd->TYPE != DC_CODED) return DD$NO_TRANSLATION;for (i = 0; i < reg_dsd->COUNT; i++) { code_dsd = get_code_dsd(reg_dsd->CODE_IX + i); if (code_dsd->CODE == fld_code) return dsd_get_label(code_dsd->LABEL_IX); };return DD$NO_TRANSLATION;}/***++** get_code_std_item** ** o Description** ** Returns the code that corresponds to the text string passed** as an argument. This function is called when the text** string of a coded field is know and the acutual code value** is desired.**** Returns DD$UNKNOWN_ITEM if the data-item id is not found in** the DSD table.** ** Returns DD$UNKNOWN_CODE if the code isn't valid for the item.**** o Synopses** ** #include "generic_dsd.h"** #include "std_dsd.h"** ** short get_code_std_item (item_id, code_str)** short item_id;** char *code_str;** ** o Remarks** ** This call does not use the data-item currently pointed to by** the context block. The item-id must be supplied.**** o Example****--*/long get_code_std_item (item_id, code_str)short item_id;char *code_str;{long i;long j;long match;long length_1;char string_1[MAX_STRING];char *string_2;DD$STD_ITEMS_DSD_PTR item_dsd_ptr;DD$STD_CODES_DSD_PTR code_dsd_ptr;item_dsd_ptr = find_std_item_dsd(item_id);if (item_dsd_ptr == DD$UNKNOWN_ITEM) return(DD$UNKNOWN_ITEM);length_1 = strlen(code_str);for (j=0; j <= length_1; j++) string_1[j] = tolower(code_str[j]);for (i=0; i < item_dsd_ptr->COUNT; i++) { if ((code_dsd_ptr = find_std_code_dsd(item_dsd_ptr, i)) == DD$UNKNOWN_CODE) return(DD$UNKNOWN_ITEM); string_2 = dsd_get_label(code_dsd_ptr->LABEL_IX); if (length_1 != strlen(string_2)) continue; /* Try the next code */ match = TRUE; /* Assume match */ for (j=0; j < length_1; j++) { if (string_1[j] != tolower(string_2[j])) { match = FALSE; break; /* Stop on mismatch */ } } if (match == TRUE) return (code_dsd_ptr->CODE); }return DD$UNKNOWN_CODE;}/***********************************************************************++** decode_os_item** ** o Description** ** Returns the standard code corresponding to an O/S code for the** os_data_item id passed to the functionid passed to the function**** ** o Synopses** ** #include "generic_dsd.h"** ** short decode_os_item (item_id, item_code)** long item_id;** long item_code;** ** o Remarks** ** o Example****--*/long decode_os_item (item_id, item_code)long item_id;long item_code;{long i;DD$OS_ITEMS_DSD_PTR os_item_ptr;if ((os_item_ptr = find_os_item_dsd(item_id)) ==DD$UNKNOWN_ITEM) return DD$UNKNOWN_CODE;for (i=0; i < os_item_ptr->COUNT; i++) { if (os_codes[os_item_ptr->CODE_IX + i].OS_CODE == item_code) return os_codes[os_item_ptr->CODE_IX + i].STD_CODE; };return DD$UNKNOWN_CODE;}/***********************************************************************++** dsd_get_label** ** o Description** ** Returns a pointer to the label string for the LABEL_IX**** ** o Synopses** ** ** char *dsd_get_label (label_index)** short label_index;** ** o Remarks** ** o Example****--*/char *dsd_get_label (label_index)short label_index;{return &strings_area[labels[label_index].STRINGS_IX];}/***++** find_std_segment_dsd**** o Description**** Searches the STD-SEGMENT-LIST for the requested segment DSD.**** Returns a pointer to the segment DSD, or DD$UNKNOWN_SEGMENT if** the segment_type and segment_subtype are not in the DSD tables.**** o Synopses
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -