source: trunk/server/source3/lib/os2path.c@ 456

Last change on this file since 456 was 454, checked in by Silvan Scherrer, 15 years ago

Samba Server 3.5: merged changes from 3.3

File size: 1.2 KB
Line 
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
13// Samba DEBUG() needs the following includes and defines
14#include <stdbool.h>
15#include "../lib/replace/replace.h"
16#include "local.h"
17#include "../lib/util/attr.h"
18#include "../lib/util/xfile.h"
19#include "debug.h"
20
21// we search the path of the .exe and return it
22int os2_GetExePath(char *buff)
23{
24 APIRET rc = NO_ERROR;
25 PPIB ppib = NULL;
26 char sExePath [_MAX_PATH];
27 char sDrive [_MAX_PATH], sDir [_MAX_DIR];
28
29 // we search for the infoblock to get the module name
30 rc = DosGetInfoBlocks(NULL, &ppib);
31 if (rc != NO_ERROR)
32 {
33 return -1;
34 }
35
36 // with the module name we get the path (including the exe name)
37 rc = DosQueryModuleName(ppib->pib_hmte, sizeof(sExePath), sExePath);
38 if (rc != NO_ERROR)
39 {
40 return -1;
41 }
42
43 // we split to the different values
44 _splitpath(sExePath, sDrive, sDir, NULL, NULL);
45 // strcat(sDrive, sDir);
46 strncat(sDrive, sDir, strlen(sDir) -1);
47 strcpy(buff, sDrive);
48
49 return 0;
50}
51
52#endif
Note: See TracBrowser for help on using the repository browser.