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

📄 text.cc

📁 100 病毒源碼,原始碼,無毒 ......
💻 CC
字号:
// Larbin// Sebastien Ailleret// 18-11-99 -> 25-11-99#include <unistd.h>#include <stdlib.h>#include <errno.h>#include <iostream.h>#include <string.h>#include "xutils/text.h"#include "xutils/string.h"/* lowercase a char */char lowerCase (char a) {  if (a >= 'A' && a <= 'Z') {    return a - 'A'+ 'a' ;  } else {    return a;  }}/* test if b starts with a */int startWith (char *a, char *b) {  size_t la = strlen(a);  return !strncmp(a, b, la);}/* test if b starts with a ignoring case */int startWithIgnoreCase (char *a, char *b) {  size_t la = strlen(a);  return !strncasecmp(a, b, la);}/* test if b end with a */int endWith (char *a, char *b) {  int la = strlen(a);  int lb = strlen(b);  return (la <= lb) && !strcmp(a, b+lb-la);}/* test if b end with a ignoring case */int endWithIgnoreCase (char *a, char *b) {  int la = strlen(a);  int lb = strlen(b);  return (la <= lb) && !strcasecmp(a, b+lb-la);}/* test if b contains a */int contain (char *a, char *b) {  size_t la = strlen(a);  int i = strlen(b) - la;  while (i >= 0) {	if (!strncmp(a, b+i, la)) {	  return 1;	}	i--;  }  return 0;}/* create a copy of a string */char *newString (char *arg) {  char *res = new char[strlen(arg) + 1];  strcpy(res, arg);  return res;}/* Read a line on a file descriptor * returns a string without the final \n * don't care end of file (make sure someone might eventually write !) */char *noEndReadline (int fds) {  int pos = 0;  int size = 64;  int cont = 1;  char c;  char *res = new char[size];  while(cont == 1) {    switch (read(fds, &c, 1)) {    case 1 :      if (c == '\n') {		cont = 0;      } else {		res[pos] = c;		pos++;		if (pos == size) {		  int i;		  char *tmp = new char[size * 2];		  for (i=0; i<size; i++) {			tmp[i] = res[i];		  }		  size *= 2;		  delete res;		  res = tmp;		}	  }      break;    case 0 :	  // socket closed by foreign host	  cont = -1;	  break;    case -1 : 	  if (errno != EINTR && errno != EIO) cont = -1;	  break;    }  }  if (cont == -1) {    delete res;    return NULL;  } else {    res[pos] = 0;    return res;  }}/* Read a whole file */char *readfile (int fds) {  ssize_t pos = 0;  ssize_t size = 512;  int cont = 1;  char buf[500];  ssize_t nbRead;  char *res = new char[size];  while(cont == 1) {	switch (nbRead = read(fds, &buf, 500)) {	case 0 : cont = 0; break;	case -1 : if (errno != EINTR && errno != EIO) cont = -1; break;	default :	  if (pos + nbRead >= size) {		size += nbRead;		char *tmp = new char[size];		memcpy(tmp, res, pos);		delete res;		res = tmp;	  }	  memcpy(res+pos, buf, nbRead);	  pos += nbRead;	  break;	}  }  res[++pos] = 0;  return res;}/* is this char a word separator */static int isDelim (char c) {  return (c == ' ' || c == '\t' || c == '\n' || c == '\r');}/* Are we at the end of a word */static int isNotFin (char c) {  return (c != ' ' && c != '\t' 		  && c != '\n' && c != '\r' && c != '\0');}/* next word in this string */char *nextToken (String &strin, uint *pos) {  uint deb;  while (isDelim(strin[*pos])) {	(*pos)++;  }  deb = *pos;  while (isNotFin(strin[*pos])) {	(*pos)++;  }  if (deb == *pos) {	return NULL;  } else {	char *res = new char[*pos - deb +1];	for (uint i=deb; i<*pos; i++) {	  res[i-deb] = strin[i];	}	res[*pos - deb] = '\0';	return res;  }}// end of text.cc

⌨️ 快捷键说明

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