Last change
on this file was 367, checked in by Herwig Bauernfeind, 16 years ago |
_divers os2_getExePath applied to BINDIR, SBINDIR and SWATDIR in 3.0.x
|
File size:
1.2 KB
|
Rev | Line | |
---|
[366] | 1 | /* This file contains helper functions for OS/2 - don't try and compile on other platforms */
|
---|
| 2 |
|
---|
| 3 | #ifdef __OS2__
|
---|
| 4 |
|
---|
| 5 | #define INCL_DOSPROCESS
|
---|
| 6 | #define INCL_DOSERRORS
|
---|
| 7 | #define INCL_DOSMODULEMGR
|
---|
| 8 | #include <os2.h>
|
---|
| 9 | #include <stdlib.h>
|
---|
| 10 | #include <stdio.h>
|
---|
| 11 | #include <string.h>
|
---|
| 12 |
|
---|
[367] | 13 | // Samba DEBUG() needs the following includes and defines
|
---|
[366] | 14 | #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
|
---|
| 15 | #include "pstring.h"
|
---|
| 16 | #include "local.h"
|
---|
| 17 | #include "xfile.h"
|
---|
| 18 | #include "debug.h"
|
---|
| 19 |
|
---|
| 20 | // we search the path of the .exe and return it
|
---|
| 21 | int os2_GetExePath(char *buff)
|
---|
| 22 | {
|
---|
[367] | 23 | APIRET rc = NO_ERROR;
|
---|
| 24 | PPIB ppib = NULL;
|
---|
| 25 | char sExePath [_MAX_PATH];
|
---|
| 26 | char sDrive [_MAX_PATH], sDir [_MAX_DIR];
|
---|
[366] | 27 |
|
---|
| 28 | // we search for the infoblock to get the module name
|
---|
[367] | 29 | rc = DosGetInfoBlocks(NULL, &ppib);
|
---|
[366] | 30 | if (rc != NO_ERROR)
|
---|
| 31 | {
|
---|
| 32 | return -1;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
[367] | 35 | // with the module name we get the path (including the exe name)
|
---|
| 36 | rc = DosQueryModuleName(ppib->pib_hmte, sizeof(sExePath), sExePath);
|
---|
| 37 | if (rc != NO_ERROR)
|
---|
| 38 | {
|
---|
| 39 | return -1;
|
---|
| 40 | }
|
---|
[366] | 41 |
|
---|
[367] | 42 | // we split to the different values
|
---|
| 43 | _splitpath(sExePath, sDrive, sDir, NULL, NULL);
|
---|
| 44 | // strcat(sDrive, sDir);
|
---|
| 45 | strncat(sDrive, sDir, strlen(sDir) -1);
|
---|
| 46 | strcpy(buff, sDrive);
|
---|
[366] | 47 |
|
---|
| 48 | return 0;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.