#include #include #define Browser "firefox" //Set browser here. #define MaxUrlLength 2084 //This is the maximum size of an url in IE plus a "\0". #define MaxLineLength 65536 //This defines the maximum size of a line in a url file. int main(int argc, char *argv[]) { if(argc > 1) { char Line[MaxLineLength]; //Will contain lines read from url file. FILE *UrlFile = fopen(argv[1],"r"); //Open the url file for reading. //Read UrlFile line by line until a line which begins with "URL=" is found. do { fgets(Line,MaxLineLength,UrlFile); }while(strncmp("URL=",Line,4)!=0); fclose(UrlFile); //Close the url file. char Url[MaxUrlLength]; //Will contain url strcpy(Url,&Line[4]); //Since line begins with "URL=", Url will begin at 5th character. Url[strlen(Url)-2] = '\0'; //Remove Windows newline from Url //Make the command line using the browser and url. //It takes the form: firefox "http://www.google.com" & char Command[MaxUrlLength + strlen(Browser) + 5] = Browser; strcat(Command," \""); strcat(Command,Url); strcat(Command,"\" &"); system(Command); //Execute command } return 0; }