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

📄 cms.cc

📁 CNC 的开放码,EMC2 V2.2.8版
💻 CC
📖 第 1 页 / 共 3 页
字号:
void CMS::set_temp_updater(CMS_NEUTRAL_ENCODING_METHOD temp_encoding_method){    if (force_raw) {	return;    }    if (temp_updater_encoding_method != temp_encoding_method &&	NULL != temp_updater) {	delete temp_updater;	temp_updater = (CMS_UPDATER *) NULL;    }    if (NULL == temp_updater) {	switch (temp_encoding_method) {	case CMS_XDR_ENCODING:	    temp_updater = new CMS_XDR_UPDATER(this);	    break;	case CMS_ASCII_ENCODING:	    temp_updater = new CMS_ASCII_UPDATER(this);	    break;	case CMS_DISPLAY_ASCII_ENCODING:	    temp_updater = new CMS_DISPLAY_ASCII_UPDATER(this);	    break;	default:	    temp_updater = (CMS_UPDATER *) NULL;	    status = CMS_UPDATE_ERROR;	    rcs_print_error("CMS: Invalid encoding method(%d)\n",		neutral_encoding_method);	    break;	}    }    if (NULL != temp_updater) {	updater = temp_updater;	temp_updater_encoding_method = temp_encoding_method;    }}void CMS::restore_normal_updater(){    updater = normal_updater;}/* Updater Positioning Functions. */void CMS::rewind(){    if (force_raw) {	return;    }    if (NULL != updater) {	updater->rewind();    }}/* XDR routines for accessing an encoded header. */int CMS::encode_header(){    if (force_raw) {	return 0;    }    if (NULL == updater) {	return -1;    }    CMS_UPDATER_MODE original_mode;    original_mode = updater->get_mode();    format_low_ptr = (char *) &header;    format_high_ptr = ((char *) &header) + sizeof(CMS_HEADER);    updater->set_mode(CMS_ENCODE_HEADER);    updater->rewind();    updater->update(header.was_read);    updater->update(header.write_id);    updater->update(header.in_buffer_size);    if (status == CMS_UPDATE_ERROR || status == CMS_MISC_ERROR) {	return (-1);    }    encoded_header_size = updater->get_encoded_msg_size();    if (min_compatible_version <= 0.0 || min_compatible_version > 3.29) {	if (neutral_encoding_method == CMS_DISPLAY_ASCII_ENCODING) {	    encoded_header_size = 16;	}    }    updater->set_mode(original_mode);    return (encoded_header_size);}int CMS::decode_header(){    if (force_raw) {	return 0;    }    if (NULL == updater) {	return -1;    }    CMS_UPDATER_MODE original_mode = updater->get_mode();    format_low_ptr = (char *) &header;    format_high_ptr = ((char *) &header) + sizeof(CMS_HEADER);    updater->set_mode(CMS_DECODE_HEADER);    updater->rewind();    updater->update(header.was_read);    updater->update(header.write_id);    updater->update(header.in_buffer_size);    updater->set_mode(original_mode);    return ((int) (status != CMS_UPDATE_ERROR	    && status != CMS_MISC_ERROR) ? 0 : -1);}int CMS::encode_queuing_header(){    if (force_raw) {	return 0;    }    if (NULL == updater) {	return -1;    }    CMS_UPDATER_MODE original_mode = updater->get_mode();    format_low_ptr = (char *) &queuing_header;    format_high_ptr = ((char *) &queuing_header) + sizeof(CMS_QUEUING_HEADER);    updater->set_mode(CMS_ENCODE_QUEUING_HEADER);    updater->rewind();    updater->update(queuing_header.head);    updater->update(queuing_header.tail);    updater->update(queuing_header.queue_length);    updater->update(queuing_header.end_queue_space);    updater->update(queuing_header.write_id);    if (status == CMS_UPDATE_ERROR || status == CMS_MISC_ERROR) {	return (-1);    }    encoded_queuing_header_size = updater->get_encoded_msg_size();    if (min_compatible_version <= 0.0 || min_compatible_version > 3.29) {	if (neutral_encoding_method == CMS_DISPLAY_ASCII_ENCODING) {	    encoded_queuing_header_size = 24;	}    }    updater->set_mode(original_mode);    return (encoded_queuing_header_size);}int CMS::decode_queuing_header(){    if (force_raw) {	return 0;    }    if (NULL == updater) {	return -1;    }    CMS_UPDATER_MODE original_mode = updater->get_mode();    format_low_ptr = (char *) &queuing_header;    format_high_ptr = ((char *) &queuing_header) + sizeof(CMS_QUEUING_HEADER);    updater->set_mode(CMS_DECODE_QUEUING_HEADER);    updater->rewind();    updater->update(queuing_header.head);    updater->update(queuing_header.tail);    updater->update(queuing_header.queue_length);    updater->update(queuing_header.end_queue_space);    updater->update(queuing_header.write_id);    updater->set_mode(original_mode);    return ((int) (status != CMS_UPDATE_ERROR	    && status != CMS_MISC_ERROR) ? 0 : -1);}int CMS::get_encoded_msg_size(){    if (force_raw) {	return 0;    }    if (NULL == updater) {	return (-1);    }    return (header.in_buffer_size = updater->get_encoded_msg_size());}int CMS::check_pointer(char *ptr, long bytes){    if (force_raw) {	return 0;    }    if (NULL == format_low_ptr || NULL == format_high_ptr	|| pointer_check_disabled) {	return 0;    }    if (ptr < format_low_ptr || ptr > (format_high_ptr - bytes)) {	rcs_print_error("CMS: pointer %p to %d bytes out of range %p to %p\n",	    ptr, bytes, format_low_ptr, format_high_ptr);	rcs_print_error("CMS: Check buffer and message sizes.\n");	status = CMS_UPDATE_ERROR;	return -1;    }    format_size = (long) (ptr - format_low_ptr) + bytes;    return 0;}void CMS::set_cms_status(CMS_STATUS new_status){    status = new_status;}  /* Access functions for primitive C language data types */CMS_STATUS CMS::update(bool &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(char &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned char &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(short int &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned short int &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(int &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned int &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(long int &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned long int &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(float &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(double &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(long double &x){    if (NULL != updater) {	return (updater->update(x));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(char *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned char *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(short *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned short *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(int *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned int *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(long *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(unsigned long *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(float *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(double *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}CMS_STATUS CMS::update(long double *x, unsigned int len){    if (NULL != updater) {	return (updater->update(x, len));    } else {	return (status = CMS_UPDATE_ERROR);    }}const char *CMS::status_string(int status_type){    switch (status_type) {	/* ERROR conditions */    case CMS_MISC_ERROR:	return ("CMS_MISC_ERROR:   A miscellaneous  error occured.");    case CMS_UPDATE_ERROR:	return ("CMS_UPDATE_ERROR: An error occured during an update. ");    case CMS_INTERNAL_ACCESS_ERROR:	return	    ("CMS_INTERNAL_ACCESS_ERROR: An error occured during an internal access function. ");    case CMS_NO_MASTER_ERROR:	return	    ("CMS_NO_MASTER_ERROR: An error occured becouse the master was not started.");    case CMS_CONFIG_ERROR:	return ("CMS_CONFIG_ERROR: There was an error in the configuration.");    case CMS_TIMED_OUT:	return ("CMS_TIMED_OUT: operation timed out.");    case CMS_QUEUE_FULL:	return	    ("CMS_QUEUE_FULL:=  A write failed because queuing was enabled but there was no room to add to the queue. ");    case CMS_CREATE_ERROR:	return	    ("CMS_CREATE_ERROR: Something could not be created because we were out of memory or another system resource.");    case CMS_PERMISSIONS_ERROR:	return ("CMS_PERMISSIONS_ERROR: Problem with permissions.");	/* NON Error Conditions. */    case CMS_STATUS_NOT_SET:	return	    ("CMS_STATUS_NOT_SET: The status variable has not been set yet.");    case CMS_READ_OLD:	return ("CMS_READ_OLD:  Read successful, but data is old. \n");    case CMS_READ_OK:	return ("CMS_READ_OK: Read successful so far.");    case CMS_WRITE_OK:	return ("CMS_WRITE_OK:  Write successful so far. ");    case CMS_WRITE_WAS_BLOCKED:	return	    ("CMS_WRITE_WAS_BLOCKED: Write if read did not succeed, because the buffer had not been read yet.");    case CMS_CLEAR_OK:	return ("CMS_CLEAR_OK: A clear operation was successful.");    case CMS_CLOSED:	return ("CMS_CLOSED: The channel has been closed.");    case CMS_NO_SERVER_ERROR:	return	    (" CMS_NO_SERVER_ERROR: The server has not been started or could not be contacted.");    case CMS_RESOURCE_CONFLICT_ERROR:	return	    ("CMS_RESOURCE_CONFLICT_ERROR: Two or more CMS buffers are trying to use the same resource.");    case CMS_NO_IMPLEMENTATION_ERROR:	return	    ("CMS_NO_IMPLEMENTATION_ERROR: An operation was attempted which has not yet been implemented for the current platform or protocol.");    case CMS_INSUFFICIENT_SPACE_ERROR:	return	    ("CMS_INSUFFICIENT_SPACE_ERROR: The size of the buffer was insufficient for the requested operation.");    case CMS_LIBRARY_UNAVAILABLE_ERROR:	return	    ("CMS_LIBRARY_UNAVAILABLE_ERROR: A DLL or Shared Object library needed for the current protocol could not be found or initialized.");    case CMS_SERVER_SIDE_ERROR:	return ("CMS_SERVER_SIDE_ERROR: The server reported an error.");    case CMS_NO_BLOCKING_SEM_ERROR:	return	    ("CMS_NO_BLOCKING_SEM_ERROR: A blocking_read operartion was tried but no semaphore for the blocking was configured or available.");    default:	return ("UNKNOWN");    }}int CMS::set_subdivision(int _subdiv){    if (_subdiv < 0 || _subdiv > total_subdivisions) {	return -1;    }    current_subdivision = _subdiv;    subdiv_data = ((char *) data) + _subdiv * (subdiv_size);    return (0);}// This constructor declared private to prevent copying.CMS::CMS(CMS & cms){}int  CMS::get_msg_count(){    internal_access_type = CMS_GET_MSG_COUNT_ACCESS;    status = CMS_STATUS_NOT_SET;    blocking_timeout = 0;    main_access(data);    return (header.write_id);}char *cms_check_for_host_alias(char *in){    if (NULL == in) {	return NULL;    }    if (NULL == cmsHostAliases) {	return NULL;    }    CMS_HOST_ALIAS_ENTRY *entry =	(CMS_HOST_ALIAS_ENTRY *) cmsHostAliases->get_head();    while (NULL != entry) {	if (!strncmp(entry->alias, in, 64)) {	    return entry->host;	}	entry = (CMS_HOST_ALIAS_ENTRY *) cmsHostAliases->get_next();    }    return NULL;}

⌨️ 快捷键说明

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