LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   pls convert this windows code into linux code (http://www.linuxquestions.org/questions/programming-9/pls-convert-this-windows-code-into-linux-code-640486/)

nagendrar 05-07-2008 04:56 AM

pls convert this windows code into linux code
 
Here we have enum structure with CleanType name.
This CleanType enum structure is initialiased in _ThrdHandle.(windows thread handle) and created object "ThrdHandle" to this thread handle "_ThrdHandle".

In thread function *DelFolderThrd ,created the obj of type ThrdHandle for the arg *element and assigned element to CleanType enum.
This *DelFolderThrd is created in CleanupOlderFiles().


enum CleanType{
NOCLEAN, FREPORTS, FDRILLDROWNS, PREPORTS
};
typedef struct _ThrdHandle
{
CleanType cType;
}ThrdHandle;

void *DelFolderThrd(void* element)
{
CleanType clnType = NOCLEAN;
ThrdHandle * handler = (ThrdHandle*)element;
if(element)
clnType = handler->cType;
}
void CleanupOlderFiles(bool bFirstTime = false)
{
unsigned delFDrillthreadId;
ThrdHandle * stFDrillmsg = new ThrdHandle;
memset(stFDrillmsg, 0, sizeof(ThrdHandle));
stFDrillmsg->cType = FDRILLDROWNS;
stFDrillmsg->hThread =(HANDLE) _beginthreadex(NULL, 0,&DelFolderThrd, stFDrillmsg, 0, &delFDrillthreadId);
}

Please convert this windows code into linux.

Thankq,
NAG.

unSpawn 05-07-2008 05:12 AM

Hello and welcome to LQ. Work or homework, if you need to convert something you do that yourself. You are free to ask specific questions, but telling the LQ community to do this for you without properly introducing yourself and without even trying to explain what and why you need it is not how we like to see things here. I suggest you edit your post and try a more respectful approach.

pixellany 05-07-2008 07:11 AM

I am not a programmer, but I'll bet that the conversion goes something like this:

1. Set up a Linux development environment with all the appropriate headers and libraries.
2. Copy and paste the code
3. Compile and debug as required

When posting homework questions, it's always better to tell us what the class is, and what you have already learned.

vadkutya 05-07-2008 09:53 AM

nothing easier than that :D. seriously, it is impossible just to convert code by looking at a snippet. copying the source won't do either because if the code does have windows api system calls you need to translate them into proper POSIX (i.e. linux system calls). we can't do your work for you, buddy, we might assist but you have to figure it out for your self.

btw: what do you need it for?

vadkutya

Tinkster 05-08-2008 01:37 PM

Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.

nagendrar 06-03-2008 06:42 AM

Quote:

Originally Posted by vadkutya (Post 3145739)
nothing easier than that :D. seriously, it is impossible just to convert code by looking at a snippet. copying the source won't do either because if the code does have windows api system calls you need to translate them into proper POSIX (i.e. linux system calls). we can't do your work for you, buddy, we might assist but you have to figure it out for your self.

btw: what do you need it for?

vadkutya


enum CleanType{
NOCLEAN, FREPORTS, FDRILLDROWNS, PREPORTS
};
typedef struct _ThrdHandle
{
CleanType cType;
}ThrdHandle;

void *DelFolderThrd(void* element)
{
CleanType clnType = NOCLEAN;
ThrdHandle * handler = (ThrdHandle*)element;
if(element)
clnType = handler->cType;
}
void CleanupOlderFiles(bool bFirstTime = false)
{
unsigned delFDrillthreadId;
ThrdHandle * stmsg = new ThrdHandle;
memset(stmsg,0, sizeof(ThrdHandle));
pthread_t hThread;
stmsg->cType = FDRILLDOWNS;
pthread_create(&hThread,NULL,DelFolderThrd,(void *)stmsg);
}

pixellany 06-03-2008 07:00 AM

nagendrar;

Why are you here?

All of your posts look like homework---and now you are posting a reply that makes no sense......


All times are GMT -5. The time now is 04:06 AM.