All pastes #29312 Raw Edit

Miscellany

public text v1 · immutable
#29312 ·published 2005-11-19 19:02 UTC
rendered paste body
//This is a work in progress!
//The irctranslate program will serve to translate any speech from IRC to google's translator
//Then this new language will be displaid in the program's window
//Released under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 licence
//Comments are welcome! drzigman@bellsouth.net
//Shouts to the Stankdawg, LogosX, tehbizz, rmpants, and all the members of the DDP
//-Dr^ZigMan
#include <stdio.h>
#include <pcap.h>
#include <unistd.h>
#define SIZE 512

void command_line(int argc,char argv[],char **device, char **logfile);

int main(int argc, char *argv[])
{
	//Declare variables
	//pcap related variables
	char device[10];			//Holds the name of the device I'm using
	
	//IRC related variables
	char logfile[SIZE];			//Hold the name of the logfile for output
	
	//Google related variables

	//Program display related variables

	//handles command line arguments
	command_line(argc,argv,&device,&logfile);
	printf("%s\n%s\n",device, logfile);

	//open device for sniffing

	//filter out all but the IRC traffic

	//Actual sniffing

	//parse out string to translate

	//send to google for translation

	//get back from google's translation

	//display to the user
}

void command_line(int argc,char argv[],char **device,char **logfile)
{
	char usage[]=	"Usage: irctranslate -i <interface> -l <log file>\n\n";

	int c;
	int errflag = 0;			//Hold if I need to print usage

	printf("\n");
	//handles the options using getopt()
	do
	{
		c = getopt(argc, argv, ":hi:l:");

		switch (c)
		{
			case 'h' :	errflag++;
					break;
	
			case 'i' :	device = optarg;
					printf("Sniffing for IRC traffic on %s...\n",device);
					break;

			case 'l' :	logfile = optarg;
					printf("Using log file: %s\n",logfile);
					break;
			
					case ':' :	printf("Option -%c requires an argument\n",optopt);
							errflag++;
							break;

			case '?' :	printf("Invaild option: -%c\n",optopt);
					errflag++;
					break;

			//default :	errflag++;
		}
	} while (c != -1);

	if (errflag)
	{
		printf(usage);
		exit(0);
	}
}