Thread: Draft code for your approval.

  1. #1
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

    Draft code for your approval.

    I have created a raw dns resolver (ie. it creates and decodes the raw datagrams) that resolves several different types of dns records (MX,CNAME,SOA,RP,etc). It is my first attempt at truly portable code and I was wondering if anyone would be kind enough to compile it on another compiler/system (I'm using lcc-win) to see if it is indeed portable.

    The only change needed ( I hope!) before compiling is to alter the DNS_SERVER constant at the top of nslook.c to the ip address of your dns server.

    Any comments on the code would also be welcome.

    Thanks a lot in advance.

    SEE CODE ATTACHED TWO MESSAGES DOWN
    Last edited by anonytmouse; 12-21-2002 at 11:26 AM.

  2. #2
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    mingw with gcc 3.2

    Code:
    D:\dnsresol>gcc -c nslook.c -o nslook.o -Wall
    nslook.c: In function `main':
    nslook.c:225: warning: int format, long unsigned int arg (arg 2)
    nslook.c:226: warning: int format, long unsigned int arg (arg 2)
    nslook.c:227: warning: int format, long unsigned int arg (arg 2)
    nslook.c:228: warning: int format, long unsigned int arg (arg 2)
    nslook.c:229: warning: int format, long unsigned int arg (arg 2)
    nslook.c:65: warning: unused variable `x'
    i believe you should use %li. %i expects an int, and on systems where ints are only 16 bits, it won't work right.

    other than that, usage of argv[0] in your little help screen should be discouraged, because it can possibly contain nothing depending on system.

    i skimmed through the code very quickly, overall seems ok.

    btw this is how i compiled it:
    Code:
    gcc -c nslook.c -o nslook.o -Wall
    gcc -c dnsResolv.c -o dnsResolv.o -Wall
    gcc -mconsole -Wall -s nslook.o dnsResolv.o -o nslook.exe -lwsock32
    hello, internet!

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Thanks!

    I have dealt with the issues you raised and have attached the updated archive to this message. Editing the code on the first post proved too difficult.

    If anyone has a non-windows system I would be very interested with the results on that.

    Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fixing the Indentation draft
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 02-23-2008, 11:17 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM