| Revision 945,
1.1 KB
checked in by aj, 5 years ago
(diff) |
|
fix more compiler warnings.
|
| Line | |
|---|
| 1 | /* |
|---|
| 2 | * Path handling routines |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2006, Andreas Jellinghaus <aj@dungeon.inka.de> |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | #ifdef HAVE_CONFIG_H |
|---|
| 8 | #include <config.h> |
|---|
| 9 | #endif |
|---|
| 10 | #include <stdio.h> |
|---|
| 11 | #include <limits.h> |
|---|
| 12 | #include <stdlib.h> |
|---|
| 13 | #include <openct/path.h> |
|---|
| 14 | |
|---|
| 15 | /* |
|---|
| 16 | * Format path |
|---|
| 17 | */ |
|---|
| 18 | int ct_format_path(char *path, const size_t pathlen, const char *file) |
|---|
| 19 | { |
|---|
| 20 | int rc; |
|---|
| 21 | |
|---|
| 22 | if (!file) |
|---|
| 23 | return 0; |
|---|
| 24 | |
|---|
| 25 | #if defined (sunray) || defined (sunrayclient) |
|---|
| 26 | { |
|---|
| 27 | if (getenv("UTDEVROOT")) |
|---|
| 28 | rc = snprintf(path, pathlen, |
|---|
| 29 | "%s/openct/%s", getenv("UTDEVROOT"), |
|---|
| 30 | file); |
|---|
| 31 | else if (getenv("OPENCT_SOCKETDIR")) |
|---|
| 32 | rc = snprintf(path, pathlen, |
|---|
| 33 | "%s/%s", getenv("OPENCT_SOCKETDIR"), |
|---|
| 34 | file); |
|---|
| 35 | else |
|---|
| 36 | rc = snprintf(path, pathlen, |
|---|
| 37 | "%s/%s", OPENCT_SOCKET_PATH, file); |
|---|
| 38 | } |
|---|
| 39 | #else |
|---|
| 40 | if (getenv("OPENCT_SOCKETDIR")) { |
|---|
| 41 | rc = snprintf(path, pathlen, |
|---|
| 42 | "%s/%s", getenv("OPENCT_SOCKETDIR"), file); |
|---|
| 43 | } else { |
|---|
| 44 | rc = snprintf(path, pathlen, "%s/%s", OPENCT_SOCKET_PATH, file); |
|---|
| 45 | } |
|---|
| 46 | #endif |
|---|
| 47 | if (rc < 0) { |
|---|
| 48 | /* hmm. error handling? */ |
|---|
| 49 | return 0; |
|---|
| 50 | |
|---|
| 51 | } |
|---|
| 52 | if (rc >= pathlen) { |
|---|
| 53 | /* truncated */ |
|---|
| 54 | return 0; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | return 1; |
|---|
| 58 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.