Im using getopt borrowed from netcat....as well as some netcat source...
Code:
if ( argc == 1 )//this only allows for 4 options why????
{
if ( (file = fopen("c:\\wnc9.txt", "r")) == NULL )
{
exit(1);
}
else
{
if ( fgets( buf, BUFSIZ, file ) != NULL )
{
position = strtok( buf, " " );
arg = malloc( sizeof( arg ) );
*arg = position;
while ( (position = strtok( NULL, " " )) != NULL )
{
argc++;
arg = realloc ( arg, argc );
arg[argc - 1] = malloc( sizeof( arg ) );
arg[argc - 1] = position;
}
argv = malloc ( argc );
for ( i = 0; i < argc; i++ )
{
argv[i] = malloc( strlen( arg[i] ) + 1 );
strcpy( argv[i], arg[i] );
}
}
}
}
while ((x = getopt (argc, argv, "ade:g:G:hi:lLno:p:rs:tuvw:zHbBP:R:S:c")) != EOF) {
/* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */
switch (x) {
case 'a':
This is how I've been learning, taking apart code. Just now to the point where I can start analyzing one of my favorite tools