Sponsored Content
Full Discussion: getprotobyname replacement?
Top Forums UNIX for Advanced & Expert Users getprotobyname replacement? Post 302164667 by jim mcnamara on Tuesday 5th of February 2008 01:42:28 PM
Old 02-05-2008
AFAIK getprotobyname_r and it's other related _r friends are obsolescent.

getprotobyname is not. SUSv3 (POSIX) lists it as a required function. Use getprotobyname in threaded applications instead.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Regarding Replacement

I have two files: file1: somedata <html> <head> This is sample statement ...... ...... </head> </html> somedata file2: olga 81 91 B A rene 82 92 B A zack 83 93 Expextd Result: (2 Replies)
Discussion started by: rajx
2 Replies

2. Shell Programming and Scripting

Character replacement

Hi, I am working on a command that replaces some occurrences of quotation marks in file. The quotation mark cannot be the first or the last character in line and cannot be preceded or followed by a comma. I am not an expert in regular expressions, but I managed to create the following... (2 Replies)
Discussion started by: piooooter
2 Replies

3. Shell Programming and Scripting

Need Replacement for sed

Hi Can anyone provide me the replacement of sed with xargs perl syntax for the below sed -e :a -e '/;$/!N;s/\n//; ta' -e 's/;$//' This should be without looping has to take minimal time for search (0 Replies)
Discussion started by: dbsurf
0 Replies

4. UNIX for Dummies Questions & Answers

Pattern Replacement

There is a requirement that i need to replaced a pattern by another pattern in all the files in my entire file system. there are 1000s of file in the system. let the pattern is "calcuta". i have to replace this pattern by "kolkata" in all those files which contain "calcuta". I am only able to... (12 Replies)
Discussion started by: palash2k
12 Replies

5. Shell Programming and Scripting

String replacement

Hi All, I have below file which has data in below format. #$ | AB_100 | AB_300 ()| AB_4 @*(% | AB-789 i want o/p as below format. | AB_100 | AB_300 | AB_4 | AB-789 So here there is no standard format. How we can achieve the same in unix ? Regards, (3 Replies)
Discussion started by: gander_ss
3 Replies

6. Shell Programming and Scripting

Help with sed replacement

This seems like it should be an easy problem, but I'm a noob and I can't figure it out. I'm trying to use sed, but would be happy to use anything that does the job. I am trying to trim off a fixed number of unknown characters from 2 different : delimited fields while keeping the intervening... (4 Replies)
Discussion started by: helix_w
4 Replies

7. Shell Programming and Scripting

help me :replacement

Hi pls help me for below; i have a file .content is : =================== uid,pcsPricingPlan,refPcsQosProfName 821910002022,smartlimit,SGSNQOS1 i have to replace the value of uid and pricingplan by a unix script. may be the value would be next line or any where in the file. pls... (9 Replies)
Discussion started by: Aditya.Gurgaon
9 Replies

8. UNIX for Dummies Questions & Answers

replacement

my filename.txt looks like this: 2079951061790 SCK0000891539000000000000021600R 2079951061790 SCK0000901487000000000000028900R 2079951061790 SCK0000903092000000000000021300R 2079951074758 ... (9 Replies)
Discussion started by: tjmannonline
9 Replies

9. HP-UX

Terminal replacement

I recently picked up an HP9000 server running HPUX. I would like to replace the CRT terminal console with something I can use a flat panel monitor. Any suggestions would be greatly appreciated. (1 Reply)
Discussion started by: Stevebei
1 Replies

10. Solaris

Is this MB, which needs replacement ?

Hello, I am getting below error in fmadm output. This server is not in support, so can't reach them. Is it showing that motherboard is faulty and should be replaced ? It was rebooted a week back and then, there were no errors # fmadm faulty --------------- ------------------------------------ ... (1 Reply)
Discussion started by: solaris_1977
1 Replies
getprotobyname(3SOCKET) 				     Sockets Library Functions					   getprotobyname(3SOCKET)

NAME
getprotobyname, getprotobyname_r, getprotobynumber, getprotobynumber_r, getprotoent, getprotoent_r, setprotoent, endprotoent - get protocol entry SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ] #include <netdb.h> struct protoent *getprotobyname(const char *name); struct protoent *getprotobyname_r(const char *name, struct protoent *result, char *buffer, int buflen); struct protoent *getprotobynumber(int proto); struct protoent *getprotobynumber_r(int proto, struct protoent *result, char *buffer, int buflen); struct protoent *getprotoent(void); struct protoent *getprotoent_r(struct protoent *result, char *buffer, int buflen); int setprotoent(int stayopen); int endprotoent(void); DESCRIPTION
These functions return a protocol entry. Two types of interfaces are supported: reentrant (getprotobyname_r(), getprotobynumber_r(), and getprotoent_r()) and non-reentrant (getprotobyname(), getprotobynumber(), and getprotoent()). The reentrant functions can be used in sin- gle-threaded applications and are safe for multithreaded applications, making them the preferred interfaces. The reentrant routines require additional parameters which are used to return results data. result is a pointer to a struct protoent struc- ture and will be where the returned results will be stored. buffer is used as storage space for elements of the returned results. buflen is the size of buffer and should be large enough to contain all returned data. buflen must be at least 1024 bytes. getprotobyname_r(), getprotobynumber_r(), and getprotoent_r() each return a protocol entry. The entry may come from one of the following sources: the protocols file (see protocols(4)), the NIS maps ``protocols.byname'' and ``proto- cols.bynumber'', and the NIS+ table ``protocols''. The sources and their lookup order are specified in the /etc/nsswitch.conf file (see nsswitch.conf(4) for details). Some name services such as NIS will return only one name for a host, whereas others such as NIS+ or DNS will return all aliases. The getprotobyname_r() and getprotobynumber_r() functions sequentially search from the beginning of the file until a matching protocol name or protocol number is found, or until an EOF is encountered. getprotobyname() and getprotobynumber() have the same functionality as getprotobyname_r() and getprotobynumber_r() except that a static buffer is used to store returned results. These functions are Unsafe in a multithreaded application. getprotoent_r() enumerates protocol entries: successive calls to getprotoent_r() will return either successive protocol entries or NULL. Enumeration might not be supported by some sources. If multiple threads call getprotoent_r(), each will retrieve a subset of the protocol database. getprotent() has the same functionality as getprotent_r() except that a static buffer is used to store returned results. This routine is unsafe in a multithreaded application. setprotoent() "rewinds" to the beginning of the enumeration of protocol entries. If the stayopen flag is non-zero, resources such as open file descriptors are not deallocated after each call to getprotobynumber_r() and getprotobyname_r(). Calls to getprotobyname_r() , The get- protobyname(), getprotobynumber_r(), and getprotobynumber() functions might leave the enumeration in an indeterminate state, so setpro- toent() should be called before the first call to getprotoent_r() or getprotoent(). The setprotoent() function has process-wide scope, and ``rewinds'' the protocol entries for all threads calling getprotoent_r() as well as main-thread calls to getprotoent(). The endprotoent() function can be called to indicate that protocol processing is complete; the system may then close any open protocols file, deallocate storage, and so forth. It is legitimate, but possibly less efficient, to call more protocol functions after endpro- toent(). The internal representation of a protocol entry is a protoent structure defined in <netdb.h> with the following members: char *p_name; char **p_aliases; int p_proto; RETURN VALUES
The getprotobyname_r(), getprotobyname(), getprotobynumber_r(), and getprotobynumber() functions return a pointer to a struct protoent if they successfully locate the requested entry; otherwise they return NULL. The getprotoent_r() and getprotoent() functions return a pointer to a struct protoent if they successfully enumerate an entry; otherwise they return NULL, indicating the end of the enumeration. ERRORS
The getprotobyname_r(), getprotobynumber_r(), and getprotoent_r() functions will fail if: ERANGE The length of the buffer supplied by the caller is not large enough to store the result. FILES
/etc/protocols /etc/nsswitch.conf ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |See NOTES below. | +-----------------------------+-----------------------------+ SEE ALSO
Intro(3), nsswitch.conf(4), protocols(4), attributes(5), netdb.h(3HEAD) NOTES
Although getprotobyname_r(), getprotobynumber_r(), and getprotoent_r() are not mentioned by POSIX 1003.1:2001, they were added to complete the functionality provided by similar thread-safe functions. When compiling multithreaded applications, see Intro(3), Notes On Multithread Applications, for information about the use of the _REEN- TRANT flag. The getprotobyname_r(), getprotobynumber_r(), and getprotoent_r() functions are reentrant and multithread safe. The reentrant interfaces can be used in single-threaded as well as multithreaded applications and are therefore the preferred interfaces. The getprotobyname(), getprotobyaddr(), and getprotoent() functions use static storage, so returned data must be copied if it is to be saved. Because of their use of static storage for returned data, these functions are not safe for multithreaded applications. The setprotoent() and endprotoent() functions have process-wide scope, and are therefore not safe in multi-threaded applications. Use of getprotoent_r() and getprotoent() is discouraged; enumeration is well-defined for the protocols file and is supported (albeit inef- ficiently) for NIS and NIS+, but in general may not be well-defined. The semantics of enumeration are discussed in nsswitch.conf(4). BUGS
Only the Internet protocols are currently understood. SunOS 5.11 5 Apr 2004 getprotobyname(3SOCKET)
All times are GMT -4. The time now is 12:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy