/* This file contains helper functions for OS/2 - don't try and compile on other platforms */ #ifdef __OS2__ #define INCL_DOSPROCESS #define INCL_DOSERRORS #define INCL_DOSMODULEMGR #include #include #include #include // Samba DEBUG() needs the following includes and defines #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) #include "pstring.h" #include "local.h" #include "xfile.h" #include "debug.h" // we search the path of the .exe and return it int os2_GetExePath(char *buff) { APIRET rc = NO_ERROR; PPIB ppib = NULL; char sExePath [_MAX_PATH]; char sDrive [_MAX_PATH], sDir [_MAX_DIR]; // we search for the infoblock to get the module name rc = DosGetInfoBlocks(NULL, &ppib); if (rc != NO_ERROR) { return -1; } // with the module name we get the path (including the exe name) rc = DosQueryModuleName(ppib->pib_hmte, sizeof(sExePath), sExePath); if (rc != NO_ERROR) { return -1; } // we split to the different values _splitpath(sExePath, sDrive, sDir, NULL, NULL); // strcat(sDrive, sDir); strncat(sDrive, sDir, strlen(sDir) -1); strcpy(buff, sDrive); return 0; } #endif