LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-07-2013, 12:09 PM   #1
guna_pmk
Member
 
Registered: Sep 2008
Posts: 220

Rep: Reputation: 5
Service discovery and RPM manipulation in C++


Hi,

I know it is pretty simple to work out the services in the Linux box using a shell script (chkconfig --list) and easy to work out what package provides a service (rpm -qf /etc/init.d/servicename).

However, I am developing a C++ api to provide various attributes of a service and rpm packages.

For example, I have to provide information on the run levels a service starts, the services (facilities) that a service depend on and so on.

Similarly, I have to provide information on an installed rpm, almost all the information you get when you issue rpm -qi.

Is there a standard C++ way to do this? Or should it be done using the standard chkconfig and rpm -q?

Please let me know of the question is vague or you need more information in this regard.

Thanks
 
Old 08-07-2013, 12:22 PM   #2
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
think twice about if it is useful and a good idea to re-invent the wheel and implement existing functionality that you can easy script (and possible call via system and process the result)

rpm has a C api
http://docs.fedoraproject.org/en-US/...ramming-c.html

http://www.rpm.org/wiki/Docs#RPMLang...sDocumentation

chkconfig is a perl script, so you can simple rewrite it in C(++) if you want.
by doing this you can see the calls it does and look what are the underlying c components for this.

ps:
it seems very distibution specific what you are going to do, so not general Linux
 
1 members found this post helpful.
Old 08-08-2013, 05:14 PM   #3
guna_pmk
Member
 
Registered: Sep 2008
Posts: 220

Original Poster
Rep: Reputation: 5
Thanks a4z. I was going to do this through parsing the results of the output. I just wanted to check whether there is a more standard way.

I understand that this is distro specific (obviously rpm). I am intending it to use it only on one distro. So it's fine.

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rpm installation error: service mysasd doenot support chkconfig umaparvahty Linux - Software 1 08-17-2010 09:32 AM
[SOLVED] rpm spec file to overwrite my service script yaplej Programming 3 05-06-2010 11:52 AM
Xubuntu 9.04 and "network service discovery disabled" message uskomaton Ubuntu 2 05-10-2009 02:07 PM
ip discovery teknofreak Linux - Networking 2 05-31-2005 09:23 AM
What's in Discovery that's not in Download 10? craigl Mandriva 2 04-27-2004 04:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration