LinuxQuestions.org
Help answer threads with 0 replies.
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 11-29-2005, 07:05 AM   #1
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Rep: Reputation: 15
Registry api's in linux ????


Hello all,

Iam working on a client server application written in windows , which i have to port to linux and there is one specific layer which consists of the registry accessing api's in windows like RegCreateKeyEx , RegOpenKeyEx , RegCloseKey etc and i have to get the corresponding api's in linux . I tried a lot of searching but really i found no success in google . I dont get exactly wat am looking for. If anyone has worked on these registry level system calls in linux or know anything that could point me to the correct place please let me know.

Regards,

S.Suresh Stephen
 
Old 11-29-2005, 07:11 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Did not know that Linux had a registry.
 
Old 11-29-2005, 07:14 AM   #3
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
im pretty sure linux doesn't have a registry like windows so you could just take them out. What functionalilty are you trying to achieve? You probably have to look for something in the kernel or an api that gives an interface to the kernel. Im not one hundred percent positive so someone can verify me on that. It's probably because i don't know about window's at the registry level. sorry.
 
Old 11-29-2005, 08:27 AM   #4
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
There is no registry in Linux. The registry associates file types to the type of image file needed to open it, etc.

The chances are most of the "registry" stuff is not needed at all. A lot of intermediate stuff like that is handled by creating a shell script to execute your program.
 
Old 11-29-2005, 12:59 PM   #5
markelo
Member
 
Registered: Mar 2004
Distribution: Red hat 9 -> 64bit fedora
Posts: 190

Rep: Reputation: 30
Warning. There isn't registry in Linux as it is in windows but you better understand what is in this link

http://www.gnome.org/projects/gconf/

This is obly for Gnome desktop environment. Something similar is for KDE. You can make your code without using things mentioned in hose links but I would still use them. It will make maintaining easier.
 
Old 11-29-2005, 01:32 PM   #6
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
The registry in Windows is used for much more than file associations.

Many applications will use the registery to store stuff like preferences, etc. You'll have to determine what exactly is being read/written to the registery. If it is application level information, you could substitute config files for the registry calls.
 
Old 11-29-2005, 11:30 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
deissum (and the previous posters) are all absolutely correct.

Linux has no "registry" per se, so there's probably no need to port the specific calls "RegCreateKeyEx()" , "RegOpenKeyEx()", et al.

However, it sounds like your client/server app is using the registry to store ... and retrieve ... some kind of information.

You need to figure out what your app is doing with the Windows registry, then invent a corresponding "registry" on Linux. It might be as simple as an .ini file, or it might be a full-fledged database. You're going to need to understand the app in order to design and implement the best solution.

'Hope that helps .. PSM
 
Old 11-30-2005, 04:27 AM   #8
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hi all,
Thanks for ur reply . Thanks for informing me that there is no registry in linux. My application needs to store some preferences like deiussum had predicted. The application must store these preferences and also retreive these preferences when needed. As per deiussum if i have to make use of config files then do i have to create those files and write the preferences i had mentioned above into it. In that case wat is the difference between writing it to an ordinary text file or onto a config file. Iam really confused . Please tell me if iam right or wrong.

Regards,
S.Suresh Stephen
 
Old 11-30-2005, 04:58 AM   #9
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hello all,
However maybe u can tell me one thing . Whenever u install a new application in windows u have a path called software/applicationame into which this registry file will be stored this can be found when we run regedit in windows. If anyone knows where a similar entry will be made in linux whenever a new application is installed into linux , might kinda help.

Regards,
S.Suresh Stephen
 
Old 11-30-2005, 07:19 AM   #10
mr_demilord
Member
 
Registered: Sep 2005
Posts: 244

Rep: Reputation: 30
Quote:
Originally posted by stephenwalter
Hello all,
However maybe u can tell me one thing . Whenever u install a new application in windows u have a path called software/applicationame into which this registry file will be stored this can be found when we run regedit in windows. If anyone knows where a similar entry will be made in linux whenever a new application is installed into linux , might kinda help.

Regards,
S.Suresh Stephen
Linux stores personal settings in the $HOME/.applicationame there are xml or .conf files which stores it's settings in.

Hope this helps.
 
Old 11-30-2005, 11:23 AM   #11
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, stephenwalter -

1. In answer to your first question: there's effectively no difference between "ordinary text file" and "a config file".
Essentially, you're inventing your own config file - you can make it whatever you want it to be.

2. In answer to you're "where's the standard place": there are lots of "standard conventions", but there is no rigid "you
must do this specific thing".

This is equally true of Windows. Windows 3.x used a bunch of .ini files; Win9x/NT tried to encourage everybody to use the registry (which had lots of subtle incompatibilities between Win9x and NT versions). And now, with .NET, the Microsoft pendulum has swung the other way and people are being DISCOURAGED from "dumping stuff" in the central registry.

But we digress ;-)

3. I'd suggest at least considering an XML file. But 99% of the time, it makes sense to just use a simple text file.

4. I'd suggest saving this file globally, in your installation directory (e.g. "/opt/my_app").

5. I'd suggest allowing users to override the default install directory (e.g. install to "/userdir/my_app" instead of "/opt/my_app", if they want) and have them point to the altnerate install directory with a symbolic link or (better!) and environment variable (e.g. "$MY_APPDIR").

6. Here's a good summary of standard *nix directories:
http://www.pathname.com/fhs/pub/fhs-2.3.html
... or ...
http://www.redhat.com/docs/manuals/l...ystem-fhs.html

7.
'Hope that helps .. PSM
 
Old 11-30-2005, 11:37 AM   #12
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
stephenwalter>

There is no registry in Linux. If you are writing a SYSTEM administration application you may want to read up on "sysconfig" and learn how its configuration files are structured.

If this is to store application settings - global (system-wide/all user) settings should be stored in /etc/{appdirectory}/{filename.conf} and user-specific settings should reside in either ~/.{appdirectory}/{filename.conf} or if it's KDE, ~/.kde/share/apps/{appname}/{filename}

If it's a gnome/Gtk app, the settings structure is fairly similar.

If it's custom widgets or less/motif, then go the .{appdirectory}/{filename} route.

That is if you want to adhere to ANY semblance of standards.

Forget what you know about Windows. *nix is all about:
- security
- configurability
- stability

If everything were crammed into a binary database, it would be too prone to corruption (no need for System Restore points!) and sysadmins would be cursing the folks who designed the disorganized system. Why should something be shoved under some cryptic /HKLM/CLASSID/{GUID}/{crypticandpoorlythoughtoutkeyname} and consist of yet more cryptic name-value pairs and have to be accessed through pain in the ass registry APIs when instead it can be accessed from a config file or two?

There comes in the stability portion - when you make a change to your config file, you avoid the possibility of bad code or (heaven forbid) a mismatched shared system library (DLL) wiping out an entire branch of the registry when you just wanted to delete a single name-value pair for a particular setting, or remove a classid when you are removing a single feature from an installed app? By accessing your config file and relying on *nix's built-in security you're removed from having to manage a lot of crap you need to worry about in the Windows world.

Sure the registry does have its advantages (it fixed the problem of everything having been shoved into win.ini) but it has a lot of inherent major disadvantages. Support, deployment, and debugging problems out in the field (sans debugger) is just a small portion of what is wrong with the registry - another is slack size. As you create and delete keys, just as with other monolithic databases, a lot of slack space is introduced, and the file just grows and grows, and with no to minimal maintenance utilities built into Windows for maintaining/repairing the registry, as it grows systems tend to slow WAY down and become unstable in some situations. Reading from a database is almost always slower than reading a short config file.

Oh and one more thing:
For config files, human readability is absolutely critical, especially when it comes to support. With all due respect to the previous poster, I'd like to mention that XML is a poor choice for configuration files in most cases. In fact when it was suggested that Apache should go to XML like IIS is going to be, it created quite an uproar. It would certainly help improve GUI administration tools like webmin, etc. but it will make most sysadmins' lives hell when apache needs to be tweaked beyond what webmin, etc. can offer.

Use XML for sending data between processes or systems, but not a simple configuration file you need to support in the field. Don't forget that when you go XML, you may need to introduce a safe mode or recovery mode for your application so that in the event that the config file gets totally broken, you can still start the application and create a new .xml file with the default settings. XML contains a lot of meta-data for describing the actual data - you generally don't need that at ALL with any sort of intelligently-designed configuration file.

Last edited by KimVette; 11-30-2005 at 11:42 AM.
 
Old 11-30-2005, 12:08 PM   #13
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, KimVette -

1. I totally agree that XML is overkill 99% of the time.

If (and pretty much only if) you need some kind of hierarchy (like, for example - the Windows registry), then XML becomes an excellent candidate.

But if one goes the XML route, then there should also be a nice GUI for the administrator to edit it. And a backup/recovery tool.

Just so there are no questions later, stephenwalter should:
a) explicitly *consider* XML (in his requirements or design documentation)
b) document *why* a simple text file is probably the preferred solution
c) go with the simple text file (and don't look back ;-))

2. I disagree with littering /etc (for precisely the same reason the registry can be a poor choice).

In general, I think global configuration is best placed in the installation directory (writable only by the installation group).

3. One point I didn't mention (and I agree with you completely, KimVette) is that it's often nice to have personal settings (in addition to any global settings). And, if they exist, they should go in $HOME/.{appdirectory}/.

Bottom line: simpler is generally better. I've got a strong hunch that stephenwalter can get by with one, simple, global .conf or .ini file, and I'd suggest he put it in the install directory.

Last edited by paulsm4; 11-30-2005 at 12:11 PM.
 
Old 11-30-2005, 12:45 PM   #14
dr_zayus69
Member
 
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
just out of curiousity what type of application are you porting? And no offense meant but for someone with the job of porting a program to a platform you don't seem to have much familarity with that platform. Is this a personal project? Or is it for a job? What license is the application under? Unless your doing it for the personal learning experience and the license permits you could make a site for your application with the source code and submit it to sourceforge. If someone in the linux community really wants to use it they will tweak the code to work on linux and you can get better feedback as to what you'd need to do to port it if people can play with the code. Just an idea. Good luck any route you take.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Linux API's hazzyb Programming 1 07-23-2005 10:50 AM
How to get Linux API's poda Linux - Newbie 4 07-19-2005 04:05 AM
how to edit the C api's in linux help SOS gauravsahni Programming 2 09-28-2004 12:34 PM
Speech Recognition API's provided by Linux Paltform bose Linux - Newbie 1 03-24-2004 04:55 AM
Registry in Linux saxophobe Linux - Newbie 8 10-09-2003 07:37 PM

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

All times are GMT -5. The time now is 05:18 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration