This is Unofficial EPICS BASE Doxygen Site
osdgetexec.c File Reference
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <osiFileName.h>
+ Include dependency graph for osdgetexec.c:

Go to the source code of this file.

Functions

char * epicsGetExecName (void)
 
char * epicsGetExecDir (void)
 

Function Documentation

char* epicsGetExecDir ( void  )

Return the absolute path of the directory containing the current executable.

Returns
NULL or the path. Caller must free()

Definition at line 40 of file osdgetexec.c.

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 }
char * epicsGetExecName(void)
Definition: osdgetexec.c:9
char* epicsGetExecName ( void  )

Return the absolute path of the current executable.

Returns
NULL or the path. Caller must free()

Definition at line 8 of file osdgetexec.c.

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 }
#define max(x, y)
Definition: flexdef.h:81
#define NULL
Definition: catime.c:38