/* This file is part of Lcrzo.
*/

int lcrzo_process_current_init(lcrzo_process *pprocess)
{
  /* parameter verification */
  if (pprocess==NULL) return(LCRZO_ERR_PANULLPTR);

#if defined LCRZODEF_SYSTEM_Unix
  pprocess->processid=getpid();
  pprocess->threadid=0;
  pprocess->threadhandle=0;
#elif defined LCRZODEF_SYSTEM_Windows
  pprocess->processid=_getpid();
  pprocess->threadid=GetCurrentThreadId();
  if ( ! DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
                         GetCurrentProcess(), &(pprocess->threadhandle),
                         0, FALSE, DUPLICATE_SAME_ACCESS) )
  { return(LCRZO_ERR_FUDUPLICATEHANDLE);
  }
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif
  pprocess->pfuncinfos=NULL;
  pprocess->hasended=LCRZO_FALSE;
  pprocess->returnedvalue=LCRZO_ERR_IEINTERNALERROR; /*default value*/

  return(LCRZO_ERR_OK);
}

