Creating struct from existing data

This is a discussion on Creating struct from existing data within the C Programming forums, part of the General Programming Boards category; I'm not sure how to describe this. I have the beginning of my struct: Code: struct tapData { guchar buddy[20]; ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    24

    Creating struct from existing data

    I'm not sure how to describe this. I have the beginning of my struct:

    Code:
    struct tapData {
    	guchar buddy[20];
    	char message[200];
    };
    and I need to expand it to include additional data. Right now I'm trying to add the internal and external IPs. I see what I believe the data I need in this block:

    Code:
    static const aim_tlv rendezvous_tlvs[] = {
    	{ RENDEZVOUS_TLV_CHANNEL, "Rendezvous ICBM Channel", dissect_aim_tlv_value_uint16 },
    	{ RENDEZVOUS_TLV_IP_ADDR, "Rendezvous IP", dissect_aim_tlv_value_ipv4 },
    	{ RENDEZVOUS_TLV_INT_IP, "Internal IP", dissect_aim_tlv_value_ipv4 },
    	{ RENDEZVOUS_TLV_EXT_IP, "External IP", dissect_aim_tlv_value_ipv4 },
    	...
    	{ 0, NULL, NULL },
    };
    I'm not familiar with the syntax and how I should add it to my struct, or if thats where I should be looking at all. I've attached the file that I'm working with. I get the buddy on line 368. Thanks for all the help, this forum has been wonderful.
    Attached Files Attached Files

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you want to add fields to your struct, then do so. I don't particularly care enough to determine whether "dissect_aim_tlv_value_ipv4" is an actual type name, or a #define for something; but you'll have to decide what type these IP fields should be, and what name you want to give them.

  3. #3
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    The RENDEZVOUS is a #define, the dissect_aim_tlv_value_ipv4 is a method defined in another header file. It looks like the data is eventually stored in some type of tree, though where and how to get it I have no idea.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Dest View Post
    the dissect_aim_tlv_value_ipv4 is a method defined in another header file
    It's a function? Then you want a function pointer.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Apr 2010
    Posts
    24
    Does a function pointer act like a variable? Should I treat it as one?

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I would guess you want to find the source for those functions, look at what they do, decide whether you can/want to call those functions directly yourself, or repurpose the code inside them for whatever it is you want to do, or none of these.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help assignment due tomorrow
    By wildiv in forum C Programming
    Replies: 6
    Last Post: 01-27-2010, 07:38 PM
  2. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 05:55 PM
  3. Replies: 1
    Last Post: 12-03-2008, 02:10 AM
  4. Possible Loss of data
    By silicon in forum C Programming
    Replies: 3
    Last Post: 03-24-2004, 11:25 AM
  5. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 08:40 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21