--- slookup-1.2.old/slookup.c +++ slookup-1.2/slookup.c @@ -19,11 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ + // Original author +#define AUTHOR "Heikki Hannikainen" +#define LICENSE "GPL license" // License info string + // Release ID string +#define VERSION "1.2-mod-060427" - -#define VERSION "1.2" -#define VERSTR "slookup version " VERSION " by Heikki Hannikainen 1998, 2004\n\tThis is free software, redistributable under the GNU GPL v2.\n" -#define HELPS "Usage: slookup [-v] [-f ] [-p] [-t A|PTR|MX]|NS\n\t-v\tVerbose\n\t-f\tNumber of children to Fork for Fast parallel lookups\n\t-p\tUse persistent TCP connection(s) to DNS server\n\t-t\tSpecify query type\n" #define MAXLEN 8192 #define MAXCHILDREN 128 @@ -105,6 +106,38 @@ } } +//-------------------------------------------------------------------- + +void usage (void) +{ + printf ("slookup %s by %s 1998, 2004 - %s\n", + VERSION, AUTHOR, LICENSE); + + puts (""); + puts ("Usage: slookup < list.txt or echo foo.com | slookup"); + puts (""); + puts ("For sorted output, append \"| sort\": slookup < list.txt | sort"); + puts (""); + puts ("The input file [if any] should list one or more domain names or"); + puts ("IP addresses, one per line."); + puts (""); + puts ("Options: slookup -f NUMPROCS -p -t TYPE"); + puts (""); + puts (" -v NUMPROCS - Set number of processes"); + puts (" -p - Use persistent TCP connections"); + puts (" -t TYPE - Specify DNS query type (A, PTR, MX, NS)"); + puts (""); + puts ("\"slookup\" output lines look like this:"); + puts (""); + puts (" item + response - where successful"); + puts ("or item - error message - where unsuccessful"); + puts (""); + + exit (1); +} + +//-------------------------------------------------------------------- + /* * Parse arguments */ @@ -142,7 +175,7 @@ case '?': case 'h': default : - fprintf(stderr, "%s%s", VERSTR, HELPS); + usage(); exit(1); } } @@ -279,7 +312,7 @@ u_char *p, *eom; int ancount, qdcount, nmx, n; int maxmx = 30; - u_short type, class, dlen, pref; + u_short type, class, dlen, pref = 0; uint32_t ttl; if ((reslen = res_query(s, C_IN, qtype, (u_char *)&res, sizeof(res))) < 0) { @@ -409,7 +442,8 @@ char s[MAXLEN]; char *p; int robin = -1; - + + if (isatty (fileno (stdin))) usage(); parse_args(argc, argv); /* if we want to fork, then fork */