Sponsored Content
Full Discussion: Deep copy of structure in C
Top Forums Programming Deep copy of structure in C Post 302906340 by breezevinay on Thursday 19th of June 2014 04:16:29 AM
Old 06-19-2014
Deep copy of structure in C

Hi ,

I have a scenario where i need to copy the iter to another local variable , where iter is of type MCC_T_SYS_ADDRINFO *iter .

Code:
struct addrinfo {
    int              ai_flags;
    int              ai_family;
    int              ai_socktype;
    int              ai_protocol;
    socklen_t        ai_addrlen;
    struct sockaddr *ai_addr;
    char            *ai_canonname;
    struct addrinfo *ai_next;
};


typedef struct addrinfo MCC_T_SYS_ADDRINFO;

MCC_T_SYS_ADDRINFO *iter = ipc->addr_ptr;

Now i need to copy the *iter to a local variable which of type MCC_T_SYS_ADDRINFO *localiter

how do i achieve it ?

Please help me in this


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data. Thanks

Last edited by vbe; 06-19-2014 at 05:22 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

any idea to copy directory structure

I want to copy the durectory structure having subdirectories in it ... would be greatful if anyone could let me know .. thanks in advance (6 Replies)
Discussion started by: myelvis
6 Replies

2. UNIX for Dummies Questions & Answers

copy files with directory structure

i have a text file as. /database/sp/NTR_Update_Imsi_List.sql /database/sp/NTR_Update_Imsi_Range_List.sql /database/sp/NTR_Vlr_Upload.sql /database/tables/StatsTables.sql /mib/ntr.mib /mib/ntr.v2.mib /scripts/operations/ntr/IMSITracer.ph /scripts/operations/ntr/IMSITracer.pl ... (3 Replies)
Discussion started by: adddy
3 Replies

3. Shell Programming and Scripting

Recursion to Copy a Directory structure

I have the below code to recurse through a given file path. I am able to go to the leaf level once recursively but traversing out is not possible as the required varaibles don't have the values on return. Both typeset and local don't work for my variable definitions. I have the o/p of the sample... (2 Replies)
Discussion started by: avrkiran
2 Replies

4. Shell Programming and Scripting

copy directory structure to a system on the network

I am trying to write a script which has to copy the directory structure from my system to another system on the network. But I dont want the files to be copied. I think I have to start with copying all subdirectories names in a directory to a system on the network. Here's the case: Source... (1 Reply)
Discussion started by: firefox211
1 Replies

5. Shell Programming and Scripting

Copy only folder structure ?

Hello, I am not sure how feasible is it, but trying to copy/create the folders from one box to another. I dont want to copy the content of folder otherwise it'd be too much of data.. The folder structure is quite complex (in deep hierarchy) and its a big effort manually .. Please... (5 Replies)
Discussion started by: navsha
5 Replies

6. Shell Programming and Scripting

Copy a file by creating folder structure in destination as in Souce

Hello, i am having a source directory which consist of multiple sub directories and my destination folder is a empty directory. if try to copy a file source->test->1.txt from source to destination test2 using the commaind. cp source/test/1.txt desti/ It will copy the 1.txt under desti... (1 Reply)
Discussion started by: tsaravanan
1 Replies

7. UNIX for Advanced & Expert Users

Copy Structure excluding some folders

Hi I want to copy the structure from one place to another. -> cd /hol/; -> find . -type d | cpio -pvdm /abc/cat; while copying the structure I want to exclude some directories like test1 and Test. I have read somewhere that this can be done with -prune option. Could anyone... (2 Replies)
Discussion started by: soumodeep123
2 Replies

8. Shell Programming and Scripting

Copy files from input file with dir structure

hi, I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE. Note that i will have other files and directories which i dont want to copy to destination. For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies

9. Shell Programming and Scripting

Need to copy a directory structure from one server to another

Hello All, I have got a dev server and a production server will call it as D server and P server. I have a dir structure in my D server and i need to create the same dir structure in P server also using a shell script. If i do a find . in my D server, i am getting an o/p like :- . ./vio... (9 Replies)
Discussion started by: Renjesh
9 Replies

10. Shell Programming and Scripting

How to copy all structure folder create last day?

HI All, please help , i got same case . i want copy folder and directory create yesterday. for sample below : drwxr-xr-x 4 apps apps 33 Nov 23 04:00 xxxxxx@gmai.com drwxr-xr-x 4 apps apps 33 Nov 23 04:00 yyyyyyy@gmail.com drwxr-xr-x 4 apps apps 33 Nov 24 04:00... (2 Replies)
Discussion started by: fajar_3t3
2 Replies
LWRES_GETADDRINFO(3)						       BIND9						      LWRES_GETADDRINFO(3)

NAME
lwres_getaddrinfo, lwres_freeaddrinfo - socket address structure to host and service name SYNOPSIS
#include <lwres/netdb.h> int lwres_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res); void lwres_freeaddrinfo(struct addrinfo *ai); If the operating system does not provide a struct addrinfo, the following structure is used: struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* PF_xxx */ int ai_socktype; /* SOCK_xxx */ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ size_t ai_addrlen; /* length of ai_addr */ char *ai_canonname; /* canonical name for hostname */ struct sockaddr *ai_addr; /* binary address */ struct addrinfo *ai_next; /* next structure in linked list */ }; DESCRIPTION
lwres_getaddrinfo() is used to get a list of IP addresses and port numbers for host hostname and service servname. The function is the lightweight resolver's implementation of getaddrinfo() as defined in RFC2133. hostname and servname are pointers to null-terminated strings or NULL. hostname is either a host name or a numeric host address string: a dotted decimal IPv4 address or an IPv6 address. servname is either a decimal port number or a service name as listed in /etc/services. hints is an optional pointer to a struct addrinfo. This structure can be used to provide hints concerning the type of socket that the caller supports or wishes to use. The caller can supply the following structure elements in *hints: ai_family The protocol family that should be used. When ai_family is set to PF_UNSPEC, it means the caller will accept any protocol family supported by the operating system. ai_socktype denotes the type of socket -- SOCK_STREAM, SOCK_DGRAM or SOCK_RAW -- that is wanted. When ai_socktype is zero the caller will accept any socket type. ai_protocol indicates which transport protocol is wanted: IPPROTO_UDP or IPPROTO_TCP. If ai_protocol is zero the caller will accept any protocol. ai_flags Flag bits. If the AI_CANONNAME bit is set, a successful call to lwres_getaddrinfo() will return a null-terminated string containing the canonical name of the specified hostname in ai_canonname of the first addrinfo structure returned. Setting the AI_PASSIVE bit indicates that the returned socket address structure is intended for used in a call to bind(2). In this case, if the hostname argument is a NULL pointer, then the IP address portion of the socket address structure will be set to INADDR_ANY for an IPv4 address or IN6ADDR_ANY_INIT for an IPv6 address. When ai_flags does not set the AI_PASSIVE bit, the returned socket address structure will be ready for use in a call to connect(2) for a connection-oriented protocol or connect(2), sendto(2), or sendmsg(2) if a connectionless protocol was chosen. The IP address portion of the socket address structure will be set to the loopback address if hostname is a NULL pointer and AI_PASSIVE is not set in ai_flags. If ai_flags is set to AI_NUMERICHOST it indicates that hostname should be treated as a numeric string defining an IPv4 or IPv6 address and no name resolution should be attempted. All other elements of the struct addrinfo passed via hints must be zero. A hints of NULL is treated as if the caller provided a struct addrinfo initialized to zero with ai_familyset to PF_UNSPEC. After a successful call to lwres_getaddrinfo(), *res is a pointer to a linked list of one or more addrinfo structures. Each struct addrinfo in this list cn be processed by following the ai_next pointer, until a NULL pointer is encountered. The three members ai_family, ai_socktype, and ai_protocol in each returned addrinfo structure contain the corresponding arguments for a call to socket(2). For each addrinfo structure in the list, the ai_addr member points to a filled-in socket address structure of length ai_addrlen. All of the information returned by lwres_getaddrinfo() is dynamically allocated: the addrinfo structures, and the socket address structures and canonical host name strings pointed to by the addrinfostructures. Memory allocated for the dynamically allocated structures created by a successful call to lwres_getaddrinfo() is released by lwres_freeaddrinfo(). ai is a pointer to a struct addrinfo created by a call to lwres_getaddrinfo(). RETURN VALUES
lwres_getaddrinfo() returns zero on success or one of the error codes listed in gai_strerror(3) if an error occurs. If both hostname and servname are NULL lwres_getaddrinfo() returns EAI_NONAME. SEE ALSO
lwres(3), lwres_getaddrinfo(3), lwres_freeaddrinfo(3), lwres_gai_strerror(3), RFC2133(), getservbyname(3), bind(2), connect(2), sendto(2), sendmsg(2), socket(2). COPYRIGHT
Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") Copyright (C) 2000, 2001, 2003 Internet Software Consortium. BIND9 Jun 30, 2000 LWRES_GETADDRINFO(3)
All times are GMT -4. The time now is 06:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy