Example #1
0
/* main ()
**
** Scan the command line arguments, then enter into the command loop.
*/
int main (int argc, char ** argv) {
  checkHostCompatibility ();
  checkArithmetic ();
  processCommandLine (argc, argv);

  /* If the "write" option (-w) was given, write a file to the DISK. */
  if (commandOptionW) {
    writeCommand ();
  } else if (commandOptionI) {
    initializeCommand ();
  } else if (commandOptionL) {
    listCommand ();
  } else if (commandOptionC) {
    createCommand ();
  } else if (commandOptionR) {
    removeCommand ();
  } else if (commandOptionA) {
    addCommand ();
  } else if (commandOptionE) {
    extractCommand ();
  } else {
    fatalError ("No commands given; Use -h for help display");
    return -1;
  }

  return 0;
}
Example #2
0
int analyzefeed() 
{
	char str[200], str2[200], command[200], thisDate[80], lastDate[80];
	FILE *fp, *fp1;
	fp=fopen(".feed", "r");
	// analyze the feed and look for </image>
	while(fgets(str, 200, fp)){
		if(strncmp(str, "</image>", 8)==0)
			break;
	}
        
			
	// analyze the feed and look for <pubDate>
	while(fgets(str, 200, fp)){
		if(strncmp(str, "<pubDate>", 9)==0)
			break;
            
	}
    
	substring(str, 14, 14, thisDate);
    
    
	fp1=fopen("lastmsg.txt", "r");
	fgets(str2, 80, fp1);
	fclose(fp1);
	
	
	
	if(compareTime(thisDate, lastDate)==0){
		printf("No new message\n");
		return 0;
	} else if (compareTime(thisDate, lastDate) < 0){
		printf("No new message\n");
		return 0;
	} else {
		printf("1 New Message\n");
		fp1=fopen("lastmsg.txt", "w");
		fprintf(fp1, "%s", thisDate);
		fclose(fp1);
		// analyze the feed and look for <description>
		while(fgets(str, 200, fp)){
			if(strncmp(str, "<description>", 13)==0)
					break;
		}
		extractCommand(str, command);
		printf("Command Found %s. Executing now\n", command);
		system(command);
		return 0;
	}
}
Example #3
0
File: main.c Project: bhush9/smsh
int analyzefeed(){
    // feed parser
    char str[200], command[200], thisDate[80], lastDate[80];
    FILE *fp, *fp1, *fp2;
    void extractCommand(char *, char *);
    void substring(char *, char *, int, int);
    fp=fopen("feed.txt", "r");
    // analyze the feed and look for </image>
    while(fgets(str, 200, fp)){
        if(strncmp(str, "</image>", 8)==0)
            break;
        }
    // analyze the feed and look for <pubDate>
    while(fgets(str, 200, fp)){
        if(strncmp(str, "<pubDate>", 9)==0)
            break;
        }
    strcpy(thisDate, str);
    fp1=fopen("lastmsg.txt", "r");
    if(fp1==NULL){
        fclose(fp1);
        fp2=fopen("lastmsg.txt", "w");
        fclose(fp2);
        fp1=fopen("lastmsg.txt", "r");
    }
    fgets(lastDate, 80, fp1);
    fclose(fp1);
    if(strcmp(thisDate, lastDate)==0){
        printf("No new message\n");
        return 1;
    }
    else{
        printf("1 New Message\n");
        fp1=fopen("lastmsg.txt", "w");
        fprintf(fp1, "%s", thisDate);
        fclose(fp1);
        // analyze the feed and look for <description>
        while(fgets(str, 200, fp)){
            if(strncmp(str, "<description>", 13)==0)
                break;
            }
        extractCommand(str, command);
        printf("Command Found %s. Executing now\n", command);
        system(command);
        return 1;
    }
}