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

📄 cms_aup.cc

📁 CNC 的开放码,EMC2 V2.2.8版
💻 CC
📖 第 1 页 / 共 2 页
字号:
    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(unsigned short) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}/* Int  functions */CMS_STATUS CMS_ASCII_UPDATER::update(int &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(int))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	if (x > 9999999 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: int %d is too large. (Use type long.)\n",		x);	}	end_current_string[7] = 0;	sprintf(end_current_string, "%-6d", x);	if (end_current_string[7] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) int with value %-6d caused an overflow.\n",		x);	}	end_current_string[7] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 8)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	long number = strtol(end_current_string, (char **) NULL, 10);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld: occured during strtol of (%s).\n",		errno, strerror(errno), end_current_string);	    return (status = CMS_UPDATE_ERROR);	}	if ((number < ((long) INT_MIN)) || (((long) INT_MAX) < number)	    && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) Number %ld out of range for int(%ld,%ld)\n",		number, INT_MIN, INT_MAX);	}	x = (int) number;    }    end_current_string += 8;    length_current_string += 8;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(int *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(int) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(unsigned int))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	if (x > 9999999 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: unsigned int %d is too large. (Use type long.)\n",		x);	}	end_current_string[7] = 0;	sprintf(end_current_string, "%-6d", x);	if (end_current_string[7] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning)unsigned int with value %-6d caused an overflow.\n",		x);	}	end_current_string[7] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 8)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	unsigned long	    number = strtoul(end_current_string, (char **) NULL, 10);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld:%s occured during strtoul of (%s).\n",		errno, strerror(errno), end_current_string);	    return (status = CMS_UPDATE_ERROR);	}	if (UINT_MAX < number && warning_count < warning_count_max) {	    rcs_print_error		("CMS_ASCII_UPDATER: Number %d out of range for unsigned int (0,%d)\n",		number, UINT_MAX);	}	x = (unsigned int) number;    }    end_current_string += 8;    length_current_string += 8;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(unsigned int) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}/* Long functions */CMS_STATUS CMS_ASCII_UPDATER::update(long int &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(long))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	end_current_string[15] = 0;	sprintf(end_current_string, "%-14ld", x);	if (end_current_string[15] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) long with value %-14ld caused an overflow\n",		x);	}	end_current_string[15] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 16)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	long number = strtol(end_current_string, (char **) NULL, 10);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld occured during strtol.\n",		errno);	    return (status = CMS_UPDATE_ERROR);	}	x = number;    }    end_current_string += 16;    length_current_string += 16;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(long *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(long) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(unsigned long int &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(unsigned long))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	end_current_string[15] = 0;	sprintf(end_current_string, "%-14ld", x);	if (end_current_string[15] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) unsigned long with value %-14ld caused an overflow\n",		x);	}	end_current_string[15] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 16)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	unsigned long	    number = strtoul(end_current_string, (char **) NULL, 10);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld:%s occured during strtoul of(%s).\n",		errno, strerror(errno), end_current_string);	    return (status = CMS_UPDATE_ERROR);	}	x = number;    }    end_current_string += 16;    length_current_string += 16;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(unsigned long *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(unsigned long) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}/* Float functions */CMS_STATUS CMS_ASCII_UPDATER::update(float &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(float))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	end_current_string[15] = 0;	sprintf(end_current_string, "%-13.7e", x);	if (end_current_string[15] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) float with value %-13.7e caused an overflow\n",		x);	}	end_current_string[15] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 16)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	double number = strtod(end_current_string, (char **) NULL);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld occured during strtol.\n",		errno);	    return (status = CMS_UPDATE_ERROR);	}	if ((number < -FLT_MAX || FLT_MAX < number) &&	    warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) Number %lf out of range for float(%f,%f)\n",		number, -FLT_MAX, FLT_MAX);	}	x = (float) number;    }    end_current_string += 16;    length_current_string += 16;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(float *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(float) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}/* Double functions */CMS_STATUS CMS_ASCII_UPDATER::update(double &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(double))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	end_current_string[15] = 0;	sprintf(end_current_string, "%-13.7e", x);	if (end_current_string[15] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) double with value %-13.7e caused an overflow\n",		x);	}	end_current_string[15] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 16)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	double number = strtod(end_current_string, (char **) NULL);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld occured during strtol.\n",		errno);	    return (status = CMS_UPDATE_ERROR);	}	x = number;    }    end_current_string += 16;    length_current_string += 16;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(double *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(double) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}/* long double functions */CMS_STATUS CMS_ASCII_UPDATER::update(long double &x){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) &x, sizeof(long double))) {	return (status = CMS_UPDATE_ERROR);    }    if (encoding) {	end_current_string[15] = 0;	sprintf(end_current_string, "%-13.7e", (double) x);	if (end_current_string[15] != 0 && warning_count < warning_count_max) {	    warning_count++;	    rcs_print_error		("CMS_ASCII_UPDATER: (warning) long double with value %-13.7e caused an overflow\n",		x);	}	end_current_string[15] = 0;    } else {	if (-1 == safe_strlen(end_current_string, 16)) {	    rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");	    return (status = CMS_UPDATE_ERROR);	}	errno = 0;	double number = strtod(end_current_string, (char **) NULL);	if (errno != 0) {	    rcs_print_error		("CMS_ASCII_UPDATER: Error %ld occured during strtol.\n",		errno);	    return (status = CMS_UPDATE_ERROR);	}	x = (long double) number;    }    end_current_string += 16;    length_current_string += 16;    return (status);}CMS_STATUS CMS_ASCII_UPDATER::update(long double *x, unsigned int len){    /* Check to see if the pointers are in the proper range. */    if (-1 == check_pointer((char *) x, sizeof(long double) * len)) {	return (status = CMS_UPDATE_ERROR);    }    for (unsigned int i = 0; i < len; i++) {	if (CMS_UPDATE_ERROR == update(x[i])) {	    return (status = CMS_UPDATE_ERROR);	}    }    return (status);}

⌨️ 快捷键说明

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