/ Extract the filename from connect string and return it. */ This used for Multiple(1) tables. Also prepare a connect string */ with a place holder to be used by SetFile. */ /
| 232 | /* with a place holder to be used by SetFile. */ |
| 233 | /***********************************************************************/ |
| 234 | PCSZ TDBODBC::GetFile(PGLOBAL g) |
| 235 | { |
| 236 | if (Connect) { |
| 237 | char *p1, *p2; |
| 238 | int i; |
| 239 | size_t n; |
| 240 | |
| 241 | if (!(p1 = strstr(Connect, "DBQ="))) { |
| 242 | char *p, *lc = strlwr(PlugDup(g, Connect)); |
| 243 | |
| 244 | if ((p = strstr(lc, "database="))) |
| 245 | p1 = Connect + (p - lc); |
| 246 | |
| 247 | i = 9; |
| 248 | } else |
| 249 | i = 4; |
| 250 | |
| 251 | if (p1) { |
| 252 | p1 += i; // Beginning of file name |
| 253 | p2 = strchr(p1, ';'); // End of file path/name |
| 254 | |
| 255 | // Make the File path/name from the connect string |
| 256 | n = (p2) ? p2 - p1 : strlen(p1); |
| 257 | DBQ = (PSZ)PlugSubAlloc(g, NULL, n + 1); |
| 258 | memcpy(DBQ, p1, n); |
| 259 | DBQ[n] = '\0'; |
| 260 | |
| 261 | // Make the Format used to re-generate Connect (3 = "%s" + 1) |
| 262 | MulConn = (char*)PlugSubAlloc(g, NULL, strlen(Connect) - n + 3); |
| 263 | memcpy(MulConn, Connect, p1 - Connect); |
| 264 | MulConn[p1 - Connect] = '\0'; |
| 265 | strcat(strcat(MulConn, "%s"), (p2) ? p2 : ";"); |
| 266 | } // endif p1 |
| 267 | |
| 268 | } // endif Connect |
| 269 | |
| 270 | return (DBQ) ? DBQ : (PSZ)"???"; |
| 271 | } // end of GetFile |
| 272 | |
| 273 | /***********************************************************************/ |
| 274 | /* Set DBQ and get the new file name into the connect string. */ |
no test coverage detected