示例#1
0
文件: main.c 项目: vikks143/atclib
int main () {

  char c;
  char line [MAXLINE] ;
  int iLine = 0;
  int found = 0;
  FILE *fr = NULL;
  FILE *fw = NULL;
  fr = fopen ("at.txt", "r");
  fw = fopen ("wt.txt", "w");
  if (fr == NULL || fw == NULL) {
    printf ("\n File can't open !");
    exit (0);
  }
  /* 
   * Program Logic based on : 
   **/
  // while (there's another line)
  //   if (the line contains the pattern)
  //        print it
  while ( iLine = getLine (line, MAXLINE, fr) > 0 ) {
    if (found = strIndex (line, pattern) >= 0) {
      printf ("\n\t $: %s\n", line);
    }
  }

   // close file 
  fclose (fr);
  fclose (fw);
  return 0;
}
示例#2
0
static int getEventEnumFromChar (char *c) {
	int ret = -1;
	const char *EVENT_CODES = "!$`<>^vohp*+-";   // '`' is placeholder for BUTTON_MARKER
	
	ret = strIndex(EVENT_CODES,*c);
	return ret;		
}
示例#3
0
int main(void)
{
	char line[MAXLINE];
	int found = 0;

	while(my_getline(line, MAXLINE) > 0)
		if(strIndex(line, pattern) >= 0)
		{	//printf("%s", line);
			color_print(line, pattern);
			found ++;
		}
	return found;
}
示例#4
0
static int getActionEnumFromChar (char *c) {
	int ret = -1;
	const char *ACTION_CODES = "~.,[)I`PCCCEEEEEMOYYYFBT(<LLLLLLDDDW*`VVVSSSS`UUUU`RGARGAHZX";  // '`' is placeholder for marker codes
	// note that E is for rEcord since R should represent Red
	// only first instance of action code is found, others are placeholders as dealt with below
	
	ret = strIndex(ACTION_CODES,*c);
	if (ret >= EOL_MARKER)
		ret = -1;
	else if (ret > LED_MARKER && *(c+1) == '-')  // LEDs
		ret += 3;
	else if (ret > USB_MARKER) {
		// =='d' keeps current ret
		if (*(c+1) == 'h')
			ret++;
		if (*(c+2) == '-')
			ret += 2;
	} 
	else if (ret > ENTER_EXIT_MARKER) { //volume or speed
		if (*(c+1) == '-')
			ret += 1;
		else if (*(c+1) == 'N') // N=normal (volume or speed)
			ret += 2;
		else if (*(c+1) == 'M') // M=max speed
			ret += 3;
	}
	else if (ret == RECORD_TITLE) {
		// == 't' keeps current ret
		if (*(c+1) == 'm')
			ret += 1;
		else if (*(c+1) == 'p')
			ret += 2;
		else if (*(c+1) == 'f')
			ret += 3;
		else if (*(c+1) == 'l')
			ret += 4;
	}
	else if (ret == JUMP_LIST) {
		if (*(c+1) == 'n')
			ret += 1;
		else if (*(c+1) == 'o')
			ret += 2;
		else if (*(c+1) == '?')
			ret += 3;
		else if (*(c+1) == 'c')
			ret += 4;
		else if (*(c+1) == '!')
			ret += 5;	
	}
	else if (ret == DELETE) {
		if (*(c+1) == 'm')
			ret += 1;
		if (*(c+1) == 't')
			ret += 2;
	}
 
	else if (ret == COPY) {
		if (*(c+1) == 'd')  //clone
			ret += 1;
		if (*(c+1) == 'l')  //COPY_LANGUAGE
			ret += 2;
	}
	else if (ret == SURVEY_TAKEN) {
		if (*(c+1) == 'a')
			ret += 1;
		else if (*(c+1) == 'u')
			ret += 2;
	}
	return ret;	
}