This is Unofficial EPICS BASE Doxygen Site
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
osdgetexec.c
Go to the documentation of this file.
1
2
#include <string.h>
3
#include <stdlib.h>
4
#include <windows.h>
5
6
#include <
osiFileName.h
>
7
8
char
*
epicsGetExecName
(
void
)
9
{
10
size_t
max
= 128;
11
char
*ret =
NULL
;
12
DWORD n;
13
14
while
(1) {
15
char
*temp = realloc(ret, max);
16
if
(!temp) {
17
/* we treat alloc failure as terminal */
18
free(ret);
19
ret =
NULL
;
20
break
;
21
}
22
ret = temp;
23
24
n = GetModuleFileName(
NULL
, ret, max);
25
if
(n == 0) {
26
free(ret);
27
ret =
NULL
;
28
break
;
29
}
else
if
(n < max) {
30
ret[n] =
'\0'
;
31
break
;
32
}
33
34
max += 64;
35
}
36
37
return
ret;
38
}
39
40
char
*
epicsGetExecDir
(
void
)
41
{
42
char
*ret =
epicsGetExecName
();
43
if
(ret) {
44
char
*sep = strrchr(ret,
'\\'
);
45
if
(sep) {
46
/* nil the charactor after the / */
47
sep[1] =
'\0'
;
48
}
49
}
50
return
ret;
51
}
max
#define max(x, y)
Definition:
flexdef.h:81
osiFileName.h
NULL
#define NULL
Definition:
catime.c:38
epicsGetExecName
char * epicsGetExecName(void)
Definition:
osdgetexec.c:9
epicsGetExecDir
char * epicsGetExecDir(void)
Definition:
osdgetexec.c:38
modules
libcom
src
osi
os
WIN32
osdgetexec.c
Generated by
1.8.11