FreeCalypso > hg > freecalypso-reveng
comparison fluid-mnf/misc.c @ 354:f89a20e7adc7
fluid-mnf: helper files sought in proper install location
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 19:56:56 +0000 |
parents | 1cd24530c0ae |
children | 00060bb8b240 |
comparison
equal
deleted
inserted
replaced
353:3aecf9bc1bf3 | 354:f89a20e7adc7 |
---|---|
24 | 24 |
25 | 25 |
26 /****************************************************************************** | 26 /****************************************************************************** |
27 * File And Path Name Functions | 27 * File And Path Name Functions |
28 ******************************************************************************/ | 28 ******************************************************************************/ |
29 | |
30 static char helpers_install_dir[] = "/opt/freecalypso/fluid/"; | |
29 | 31 |
30 // Return the length of the directory name preceding the leafname. The | 32 // Return the length of the directory name preceding the leafname. The |
31 // terminating slash is included in the length. Length can be zero, if there | 33 // terminating slash is included in the length. Length can be zero, if there |
32 // is no dirname. | 34 // is no dirname. |
33 int dirname_len(const char *pathname) | 35 int dirname_len(const char *pathname) |
42 | 44 |
43 p = (char *) (pathname + len - 1); | 45 p = (char *) (pathname + len - 1); |
44 | 46 |
45 tr(TrUtility, "{ %d }\n", len); | 47 tr(TrUtility, "{ %d }\n", len); |
46 | 48 |
47 while (*p != '/' && *p != '\\' && len-- > 1) | 49 while (*p != '/' && len-- > 1) |
48 p--; | 50 p--; |
49 | 51 |
50 return len; | 52 return len; |
51 } | 53 } |
52 | 54 |
64 size, dirname, leafname); | 66 size, dirname, leafname); |
65 | 67 |
66 dir_len = dirname_len(dirname); | 68 dir_len = dirname_len(dirname); |
67 leaf_len = strlen(leafname); | 69 leaf_len = strlen(leafname); |
68 | 70 |
69 if (dir_len > size - leaf_len - 1) | 71 if (dir_len + leaf_len > size - 1) |
70 result = E_BUFFER; | 72 result = E_BUFFER; |
71 else { | 73 else { |
72 memcpy(buf, dirname, dir_len); | 74 memcpy(buf, dirname, dir_len); |
75 strcpy(buf + dir_len, leafname); | |
76 result = dir_len + leaf_len; | |
77 } | |
78 | |
79 tr(TrEnd|TrUtility, "} %d\n", result); | |
80 | |
81 return result; | |
82 } | |
83 | |
84 /* New version for fluid-mnf port */ | |
85 int pathname_make_instdir(char *buf, int size, const char *leafname) | |
86 { | |
87 int dir_len, leaf_len, result; | |
88 | |
89 tr(TrBegin|TrUtility, "pathname_make(*, %d, '%s', '%s') {\n", | |
90 size, helpers_install_dir, leafname); | |
91 | |
92 dir_len = strlen(helpers_install_dir); | |
93 leaf_len = strlen(leafname); | |
94 | |
95 if (dir_len + leaf_len > size - 1) | |
96 result = E_BUFFER; | |
97 else { | |
98 strcpy(buf, helpers_install_dir); | |
73 strcpy(buf + dir_len, leafname); | 99 strcpy(buf + dir_len, leafname); |
74 result = dir_len + leaf_len; | 100 result = dir_len + leaf_len; |
75 } | 101 } |
76 | 102 |
77 tr(TrEnd|TrUtility, "} %d\n", result); | 103 tr(TrEnd|TrUtility, "} %d\n", result); |