Standalone source code of gethostbyname function for linux [closed] - c++

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Where i can get source code of gethostbyname which can be used without linking other libs(just sockets) for linux?
I found this:
https://github.com/gnif/ARMT/blob/master/common/CDNS.cc
But this doesn't work, error when resolving
Thanks!

"A non-blocking DNS resolver library in a single .c file. Supports both stub and recursive modes."
http://25thandclement.com/~william/projects/dns.c.html

DNS resolution is complicated. Why not use a library? I use c-ares when I need one.
If you don't want to use it as a library you can stuff all its source code files directly into your project although that would be weird.

gethostbyname is anything but simple, as it has to find out what the currently configured source for such data is (local files, NIS, NIS+, DNS, perhaps others), in which order to search there, what to do if the lookup for each one fails (nsswitch.conf(5) et al), and do the looking up and miscelaneous bookkeeping and caching.

Related

Logging framework for C++ [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I apologize to take a topic which is widely discussed before - but I find none of the discussions clearly tell which one to use ultimately. My requirements for a logging framework in my C++ project are
Thread safe.
Should support multiple targets.
Log rotation possible.
A way to identify module's implicitly.
I have been using boost log for some time in a small c++ project and it worked well. But when I took to a large C++ project - I found supporting multiple targets(I mean multiple files for the same project) is a nightmare, No way to implicitly mention which module is logging and above all the compile time has increased at-least 40%.
Now I am looking at alternate framework and think log4cplus and logog seems fill all my requirements. Wanted to get an expert opinion on which would suit the above criteria rather than getting in a soup again after using the library for some time.

C++ Logger Performance and Portability [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm writing a C++ application, that I have to deploy to a server in the future (maybe as a node.js C++ module).
I really need a logging library that help me during the development process.
Now I'm using log4cxx, but I need the code to be portable, so I prefer to have a source file to include in the project. I also need a performing C++ logger, that does not slow down the application in both case with logging turned on and off. Can anyone help me with this choice? My options are:
Log4cplus: simple and easy to use and extend. But performance?
Google-Glog: easiest to use and very very fast. But I need to compile it and it use system flag, I wonder if it is a problem when I use it with node.js.
As far as I know the log4cxx uses Apache runtime as its base so ,portability is not an issue with log4cxx. Also it provides macros for optimized logging. Is there anyother reason you want to shift from log4cxx?

Is there any Linux alternative for Windows Path API? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In Windows API there are a big set of methods for manipulating of paths and URLs at Shell Path Handling Functions. The functions include helpers like PathAddBackslash, PathCanonicalize, PathCombine, and PathIsDirectory.
The question is: are there any Posix provided functionality or Linux-based library that gives analogous functionality? That is, simplifies paths combination, canonicalization, parsing, as well as URLs parsing?
I know that it is possible to write such functions with C++ (not small but not complex job), but my question is: are there any ready "official" libraries on Linux that already have similar functionality?
I am quite happy with boost_filesystem. Best part of it is that it is cross-platform, so it also works on Windows.
Another possibility is leveraging the capabilities of Qt or GLIB (GTK+).
Finally, most path-mangling operations are already in the POSIX standard and available out-of-the-box. For an example see the manpage of basename(3), dirname(3):
http://www.kernel.org/doc/man-pages/online/pages/man3/dirname.3.html
You could also use POCO C++ libraries, take a look here:
http://pocoproject.org/features.html
And here you could find more on filesystem api:
http://pocoproject.org/slides/080-Files.pdf

Linux C++ Application Setting Configured by XML file [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am working with a C++ project whose application setting is a simple text file. Now i want to replace the file with XML based configuration. So which xml parser should i use?
Look at TinyXML or TinyXML++, it's small and easy.
You can also use the boost::property_tree, as someone already mentioned.
Here is a nice tutorial for using it to read/write xml.
Plenty of choice. Selecting a parser with XPATH support is often very handy in this circumstance. libxml+ with libXml2 does the job nicely - and libxml2 is included in just about any Linux distro.
Look at libconfig, it may be good replace for xml.

when do not use open source code? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Are there some cases where it may not be a good idea to use the code of an open source project even though your company might allow you to do so?
Some cases that I think might be valid are:
The code may be implemented in a different languages.
It is not portable
It may need some other close-source libraries
What might be some other reasons?
Yes, some open-source licenses may require you to expose your source code, e.g GPL.
http://encodable.com/tech/blog/2006/02/25/Why_the_GPL_is_Incompatible_with_Commercial_Software
When security is involved and you do not have access to the actual code so you never (truly) know what you are using.
Beta code may not be appropriate in a production system.
if the library has a web page and there hasn't been any activity on it for a long long time. Either the code is perfect or no one is looking at the code anymore and no bug fixes are being applied.