1 /* include px_ipc_name */ 2 #include "unpipc.h" 3 4 char * 5 px_ipc_name(const char *name) 6 { 7 8 char *dir, *dst, *slash; 9 10 if ( (dst = malloc(PATH_MAX)) == NULL) 11 return(NULL); 12 13 /* 4can override default directory with environment variable */ 14 if ( (dir = getenv("PX_IPC_NAME")) == NULL) { 15 16 #ifdef POSIX_IPC_PREFIX 17 dir = POSIX_IPC_PREFIX; /* from "config.h" */ 18 #else 19 dir = "/tmp/"; /* default */ 20 #endif 21 22 } 23 /* 4dir must end in a slash */ 24 slash = (dir[strlen(dir) - 1] == '/') ? "" : "/"; 25 snprintf(dst, PATH_MAX, "%s%s%s", dir, slash, name); 26 27 return(dst); /* caller can free() this pointer */ 28 29 } 30 /* end px_ipc_name */ 31 32 char * 33 Px_ipc_name(const char *name) 34 { 35 36 char *ptr; 37 38 if ( (ptr = px_ipc_name(name)) == NULL) 39 err_sys("px_ipc_name error for %s", name); 40 return(ptr); 41 42 }