Problem in "porting" a function on windows to linu

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
jeremy28
Newbie
Newbie
Posts: 1
Joined: Sat Jun 26, 2010 1:54 am

Problem in "porting" a function on windows to linu

Post by jeremy28 »

Hi all!

I use ubuntu 9.04;
I have a function called "isLogEnabled" in my project on windows, I wanna port it to linux.
I know that I should have a "config.h" file in linux to get log from a specific Shared object and ..., but because I'm new to linux,
I don't know how this should be done, this is my function:

Code: Select all

//This function return True if log policy is set in registry and False otherwise
   int isLogEnabled()
   {
     HKEY hKey;
     LONG lRes;
     DWORD dwType, dwSize = 0;
     int retVal = 0;
 
     if((RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\MyCorp", 0, KEY_ALL_ACCESS, &hKey)) == ERROR_SUCCESS)
     {
        lRes = RegQueryValueEx(hKey, "SpecialMode", 0, &dwType, NULL, &dwSize );
 
        if(lRes == ERROR_SUCCESS)
           retVal = 1;
        RegCloseKey(hKey);
     }
     return retVal;
  }
Since I think we don't have registry concept in linux and this function uses registry APIs, I'm confused to change it to be compatible
with linux;

Could you help me with this please?!

TIA.
Martin Gregorie

Problem in "porting" a function on windows to linu

Post by Martin Gregorie »

On Sat, 2010-06-26 at 02:56 -0500, jeremy28 wrote:
Hi all!

I use ubuntu 9.04;
I have a function called "isLogEnabled" in my project on windows, I wanna port it to linux.
Are you intending to use Linux system logs?

If so, you need to modify your logging interface to use the openlog(),
syslog() and closelog() functions, which are defined in syslog.h - see
"man 3 syslog" for details and, since the logging system is always
available, your isLogEnabled() function would become:

Code:

//This function return True if log policy is set in registry and False otherwise
int isLogEnabled()
{
return 1;
}


Martin
Locked