355 int n;
356
357 s = strerror(errno);
358 n = (int)strlen(s);
359 if (n >= len) {
360 n = len - 1;
361 }
362 (void)strncpy(buf, s, n);
363 buf[n] = '\0';
364 return n;
365 }
366
367 return 0;
368 }
369
370 static void dll_build_name(char* buffer, size_t buflen,
371 const char* pname, const char* fname) {
372 // Loosley based on os_windows.cpp
373
374 char *pathname = (char *)pname;
375 while (strlen(pathname) > 0) {
376 char *p = strchr(pathname, ';');
377 if (p == NULL) {
378 p = pathname + strlen(pathname);
379 }
380 /* check for NULL path */
381 if (p == pathname) {
382 continue;
383 }
384 if (*(p-1) == ':' || *(p-1) == '\\') {
385 (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname),
386 pathname, fname);
387 } else {
388 (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname),
389 pathname, fname);
390 }
391 if (_access(buffer, 0) == 0) {
392 break;
393 }
394 pathname = p + 1;
395 *buffer = '\0';
396 }
397 }
398
399 /* Build a machine dependent library name out of a path and file name. */
400 void
401 md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
402 {
403 int pnamelen;
404
405 pnamelen = pname ? (int)strlen(pname) : 0;
406
407 *holder = '\0';
408 /* Quietly truncates on buffer overflow. Should be an error. */
409 if (pnamelen + strlen(fname) + 10 > (unsigned int)holderlen) {
410 return;
411 }
412
413 if (pnamelen == 0) {
414 sprintf(holder, "%s.dll", fname);
|
355 int n;
356
357 s = strerror(errno);
358 n = (int)strlen(s);
359 if (n >= len) {
360 n = len - 1;
361 }
362 (void)strncpy(buf, s, n);
363 buf[n] = '\0';
364 return n;
365 }
366
367 return 0;
368 }
369
370 static void dll_build_name(char* buffer, size_t buflen,
371 const char* pname, const char* fname) {
372 // Loosley based on os_windows.cpp
373
374 char *pathname = (char *)pname;
375 *buffer = '\0';
376 while (strlen(pathname) > 0) {
377 char *p = strchr(pathname, ';');
378 if (p == NULL) {
379 p = pathname + strlen(pathname);
380 }
381 /* check for NULL path */
382 if (p == pathname) {
383 continue;
384 }
385 if (*(p-1) == ':' || *(p-1) == '\\') {
386 (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
387 pathname, fname);
388 } else {
389 (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
390 pathname, fname);
391 }
392 if (_access(buffer, 0) == 0) {
393 break;
394 }
395 if (*p == '\0') {
396 pathname = p;
397 } else {
398 pathname = p + 1;
399 }
400 *buffer = '\0';
401 }
402 }
403
404 /* Build a machine dependent library name out of a path and file name. */
405 void
406 md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
407 {
408 int pnamelen;
409
410 pnamelen = pname ? (int)strlen(pname) : 0;
411
412 *holder = '\0';
413 /* Quietly truncates on buffer overflow. Should be an error. */
414 if (pnamelen + strlen(fname) + 10 > (unsigned int)holderlen) {
415 return;
416 }
417
418 if (pnamelen == 0) {
419 sprintf(holder, "%s.dll", fname);
|