⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsd_access.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
****      #include "generic_dsd.h"**      #include "std_dsd.h"****	DD$STD_SEGMENT_DSD_PTR**      find_std_segment_dsd (segment_type, segment_subtype)**	DD$STD_HEADER.type segment_type;**	DD$STD_HEADER.subtype segment_subtype;****  o Remarks******  o Example****--*/DD$STD_SEGS_DSD_PTR find_std_segment_dsd(seg_type, seg_subtype)short seg_type;short seg_subtype;{long i;for (i=0; i < std_segs_count; i++)    {    if (std_segs[i].TYPE    == seg_type &&	std_segs[i].SUBTYPE == seg_subtype)	return &std_segs[i];    };return DD$UNKNOWN_SEGMENT;}/***++**  get_item_offset****  o Description****      Searches the STD-SEG_ITEMS for the requested item id.****	Returns a pointer to the seg_items_dsd, or DD$UNKNOWN_ITEM if**	the item_id is not in the DSD tables.****  o Synopses****      #include "generic_dsd.h"**      #include "std_dsd.h"****      short get_item_offset (segment_ptr, item_id)**	DD$STD_SEGMENT_DSD_PTR segment_ptr;**	short item_id;****  o Remarks******  o Example****--*/short get_item_offset (segment_ptr, item_id)DD$STD_SEGS_DSD_PTR segment_ptr;short item_id;{long i;for (i=0; i < segment_ptr->COUNT; i++)    {    if (std_items[std_seg_items		  [segment_ptr->SEG_ITEM_IX + i		  ].ITEM_IX		 ].ID == item_id)	return std_seg_items[segment_ptr->SEG_ITEM_IX + i ].ITEM_OFFSET;    };return DD$UNKNOWN_ITEM;}/***++**  get_seg_item_dsd****  o Description****      Offsets into the STD-SEG_ITEMS for the given index****	Returns a pointer to the seg_items_dsd****  o Synopses****      #include "generic_dsd.h"**      #include "std_dsd.h"****	DD$STD_SEG_ITEMS_DSD_PTR get_seg_item_dsd (index)**	long  index;****  o Remarks******  o Example****--*/DD$STD_SEG_ITEMS_DSD_PTR get_seg_item_dsd (index)long  index;{return &std_seg_items[index];}/***++**  get_code_dsd****  o Description****      Offsets into the STD-CODES for the given index****	Returns a pointer to the codes_dsd****  o Synopses****      #include "generic_dsd.h"**      #include "std_dsd.h"****	DD$STD_CODES_DSD_PTR get_code_dsd(index)**	long  index;****  o Remarks******  o Example****--*/DD$STD_CODES_DSD_PTR get_code_dsd(index)long  index;{return &std_codes[index];}/***++**  get_reg_dsd****  o Description****      Offsets into the STD-REGS for the given index****	Returns a pointer to the regs_dsd****  o Synopses****      #include "generic_dsd.h"**      #include "std_dsd.h"****	DD$STD_REGS_DSD_PTR get_reg_dsd (index)**	long  index;****  o Remarks******  o Example****--*/DD$STD_REGS_DSD_PTR get_reg_dsd (index)long  index;{return &std_regs[index];}/***++**  get_item_dsd****  o Description****      offsets into the STD-ITEMS for the given index****	Returns a pointer to the seg_items_dsd****  o Synopses****      #include "generic_dsd.h"**      #include "std_dsd.h"****      DD$STD_ITEMS_DSD_PTR get_item_dsd(index)**	long index;****  o Remarks******  o Example****--*/DD$STD_ITEMS_DSD_PTR get_item_dsd(index)long index;{return &std_items[index];}/***********************************************************************++**  find_std_item_dsd****  o Description****      Searches the STD-ITEM-LIST for the requested data-item id.****	Returns a pointer to the data-item DSD, or DD$UNKNOWN_ITEM if**	the data-item id is not found in the DSD table.****  o Synopses****      #include "generic_dsd.h"**      #include "std_dsd.h"****	DD$STD_ITEM_DSD_PTR**      find_std_item_dsd (item_id)**	short item_id;****  o Remarks****	Should only be used when information about a data-item is required**	out of the normal data-segment context.****  o Example****--*/DD$STD_ITEMS_DSD_PTR find_std_item_dsd (item_id)short item_id;{long i;for (i=0; i < std_items_count; i++)    {    if (std_items[i].ID == item_id)	return &std_items[i];    };return DD$UNKNOWN_ITEM;}/***********************************************************************++**  find_std_code_dsd**  **  o Description**  **      Returns the corresponding STD_CODES_DSD structure for the**      specified input ( item_dsd_ptr and code index)****  **  o Synopses**  **      #include "generic_dsd.h"**  **      DD$STD_CODES_DSD_PTR find_std_code_dsd (item_dsd_ptr, code_index)**      short item_dsd_ptr;**      short code_index;**  **  o Remarks**  **  o Example****--*/DD$STD_CODES_DSD_PTR find_std_code_dsd (item_dsd_ptr, code_index)DD$STD_ITEMS_DSD_PTR item_dsd_ptr;short code_index;{if (item_dsd_ptr->TYPE == DT_TINY_INDEX ||    item_dsd_ptr->TYPE == DT_SHORT_INDEX ||    item_dsd_ptr->TYPE == DT_INDEXED)    {    if (item_dsd_ptr->COUNT < code_index)	return DD$UNKNOWN_CODE;    return &std_codes[item_dsd_ptr->INDEX + code_index];    };return DD$UNKNOWN_CODE;}/***********************************************************************++**  find_reg_code_dsd**  **  o Description**  **      Returns the corresponding STD_CODES_DSD structure for the**      specified input ( reg_dsd_ptr and code index)****  **  o Synopses**  **      #include "generic_dsd.h"**  **      DD$STD_CODES_DSD_PTR find_reg_code_dsd (reg_dsd_ptr, code_index)**      short reg_dsd_ptr;**      short code_index;**  **  o Remarks**  **  o Example****--*/DD$STD_CODES_DSD_PTR find_reg_code_dsd (reg_dsd_ptr, code_index)DD$STD_REGS_DSD_PTR reg_dsd_ptr;short code_index;{if (reg_dsd_ptr->TYPE == DC_CODED)    {    if (reg_dsd_ptr->COUNT < code_index)	return DD$UNKNOWN_CODE;    return &std_codes[reg_dsd_ptr->CODE_IX + code_index];    };return DD$UNKNOWN_CODE;}/***********************************************************************++**  find_os_item_dsd****  o Description****      Searches the OS-ITEM-LIST for the requested data-item id.****	Returns a pointer to the data-item DSD, or DD$UNKNOWN_ITEM if**	the data-item id is not found in the DSD table.****  o Synopses****      #include "generic_dsd.h"****	DD$OS_ITEM_DSD_PTR**      find_os_item_dsd (item_id)**	DD$OS_ITEM_DSD.ID item_id;****  o Remarks****  o Example****--****/DD$OS_ITEMS_DSD_PTR find_os_item_dsd (item_id)short item_id;{long i;for (i=0; i <= os_items_count; i++)    {    if (os_items[i].ID == item_id)        return &os_items[i];    }return DD$UNKNOWN_ITEM;}/***********************************************************************++**  find_label_dsd  ****  o Description****      returns the indicated DSP_LABEL_PRT as requested by the LABEL_INDEX******  o Synopses****      #include "generic_dsd.h"****	DD$DSP_LABELS_PTR find_label_dsd(label_index)**	short label_index;****  o Remarks****  o Example****--****/DD$DSP_LABELS_PTR find_label_dsd(label_index)short label_index;{return &labels[label_index];}/***********************************************************************++**  Set Validity codes**  **  o Description**  **      This function is only available to ERIT.  It sets the item validity**      code in the standard data-segment for the current item.**  **  o Synopses**  **      #include "generic_dsd.h"**  **      int set_validity_code (seg_ptr, item_seq, item_validity_code)**      DD$STD_HEADER_PTR seg_ptr;**      short item_seq;**      short item_validity_code;**  **  o Remarks**  **      The "item_validity_code" must be one of the following:**  **  	DD$VALID	The data is valid and available.**  **  	DD$N_A		The data does not exist in this context.**  **  	DD$N_V		The data is invalid, and the bad value is in**  			the item. (i.e. The data does not meet the**  			RANGE or LIST validity checks in the item's**  			DSD)**  **  	DD$N_V$N_A	The data is invalid and not available. (i.e.**  			The data does not meet the RANGE or LIST**  			validity checks in the item's DSD, and the**  			bad value could not be stored in the item.)**  			(e.g. ASCII number ==> short  -- and the string**  			recieved contains non-numeric characters.)**  			**  o Example****--*/static unsigned int LBIT[4] = { 1,4,16,64 };static unsigned int HBIT[4] = { 2,8,32,128};static unsigned int ORMASK[4] = {0,1,2,3};static unsigned int LEFTSHIFT[4] = {0,2,4,6};/************************** SETNURDLE () *****************************/setnurdle(nur,nn,nv)unsigned char nur;short nn;short nv;{					/* first turn off both bits */nur &= ~(LBIT[nn-1] | HBIT[nn-1]);nur = nur | (ORMASK[nv] << LEFTSHIFT[nn-1]);return(nur);}/************************** GETBITS ()  ******************************/getbits(x,p,n)unsigned x,p,n;{return((x >> (p+1-n)) & ~(~0 << n));}/***********************  SET_VALIDITY_CODE () ***********************/int set_validity_code (seg_ptr, item_seq, item_validity_code)DD$STD_HEADER_PTR seg_ptr;short item_seq;short item_validity_code;{short wbyte,wnurdle;unsigned char thebyte,newbyte;wbyte = (item_seq / 4) ;wnurdle = (item_seq % 4) + 1;thebyte = seg_ptr->VALID_byte[wbyte];newbyte = setnurdle(thebyte,wnurdle,item_validity_code);    seg_ptr->VALID_byte[wbyte] = newbyte;}/************************  GET_VALIDITY_CODE ()  *********************/intget_validity_code (ctx)DD$STD_DSD_CTX *ctx;{short wbyte,wnurdle;unsigned char thebyte;wbyte = (ctx->curr_item / 4) ;wnurdle = (ctx->curr_item % 4) + 1;thebyte = ctx->segment_ptr->VALID_byte[wbyte];return(getbits(thebyte,(wnurdle*2)-1,2));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -