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

📄 cstrlibs.c

📁 一个LINUX下的服务器的小程序.可供学习.
💻 C
字号:
#include<string.h>
#include<stdio.h>
#include<ctype.h>
 #include<stdlib.h>
#include "symbol_table.h"
#include "cstrlibs.h"

int checkblankstr(const char *src, char *errbuf) {

	if(src == NULL){
		snprintf(errbuf,ERRBUF_SIZE,"the first parm's value is NULL.") ;
		return -1 ;
	}else if(strlen(src) == 0){
		snprintf(errbuf,ERRBUF_SIZE,"the first parm's length is ZERO.");
		return -2 ;
	}else if(strlen(src) == strspn(src," ")){
		return 0 ;
	}else {
		snprintf(errbuf,ERRBUF_SIZE,"the first parm is NOT blank string.") ;
		return 1 ;
	}
}


int trimstr(char * src, char * dest){
	if((src == NULL) | (dest == NULL))
		return -1 ;

	char *save = dest ;
	char *tail = src+strlen(src)-1 ;

	//get the first non_space pointer from head
	while(isspace((unsigned char)*src))
		src++ ;

	//get the last non_space pointer from tail
	while(isspace((unsigned char)*tail))
		tail-- ;

	//copy the str from head to tail.
	for(; src<=tail; *save=*src,++save,++src);
	*save = '\0' ;

	if(strlen(dest) ==0)
		return -1 ;
	
	return 0 ;
	
}


/**
**/
 int strtoinum(const char *src) {
	int value = ERROR_NUM ;
	int len = 0 ;
	
	if(src!=NULL && (len = strlen(src))!=0){
		value = atoi(src) ;
	}else{
		return ERROR_NUM ;
	}

	if(value == ZERO_NUM){
		if(len != 1)
			return ERROR_NUM ;
	}else if(value > ZERO_NUM){
		int num = 0 ;
		int value_t = value ;
		while(value_t%10){
			num++ ;
			value_t = value_t/10 ;
		}

		if(len != num)
			return ERROR_NUM ;
	}else{
		return ERROR_NUM ;
	}

	return value ;
	
}





⌨️ 快捷键说明

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