src/solaris/demo/jvmti/hprof/hprof_md.c

Print this page
rev 6641 : [mq]: PrivateTransportTest


 368     return htonl(l);
 369 }
 370 
 371 unsigned
 372 md_ntohs(unsigned short s)
 373 {
 374     return ntohs(s);
 375 }
 376 
 377 unsigned
 378 md_ntohl(unsigned l)
 379 {
 380     return ntohl(l);
 381 }
 382 
 383 static void dll_build_name(char* buffer, size_t buflen,
 384                            const char* pname, const char* fname) {
 385     // Loosely based on os_solaris.cpp
 386 
 387       char *pathname = (char *)pname;

 388       while (strlen(pathname) > 0) {
 389           char *p = strchr(pathname, ':');
 390           if (p == NULL) {
 391               p = pathname + strlen(pathname);
 392           }
 393           /* check for NULL path */
 394           if (p == pathname) {
 395               continue;
 396           }
 397           (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX,
 398                          (p - pathname), pathname, fname);
 399 
 400           if (access(buffer, F_OK) == 0) {
 401             break;
 402           }



 403           pathname = p + 1;

 404           *buffer = '\0';
 405       }
 406 }
 407 
 408 /* Create the actual fill filename for a dynamic library.  */
 409 void
 410 md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
 411 {
 412     int   pnamelen;
 413 
 414     /* Length of options directory location. */
 415     pnamelen = pname ? strlen(pname) : 0;
 416 
 417     *holder = '\0';
 418     /* Quietly truncate on buffer overflow.  Should be an error. */
 419     if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
 420         return;
 421     }
 422 
 423     /* Construct path to library */




 368     return htonl(l);
 369 }
 370 
 371 unsigned
 372 md_ntohs(unsigned short s)
 373 {
 374     return ntohs(s);
 375 }
 376 
 377 unsigned
 378 md_ntohl(unsigned l)
 379 {
 380     return ntohl(l);
 381 }
 382 
 383 static void dll_build_name(char* buffer, size_t buflen,
 384                            const char* pname, const char* fname) {
 385     // Loosely based on os_solaris.cpp
 386 
 387       char *pathname = (char *)pname;
 388       *buffer = '\0';
 389       while (strlen(pathname) > 0) {
 390           char *p = strchr(pathname, ':');
 391           if (p == NULL) {
 392               p = pathname + strlen(pathname);
 393           }
 394           /* check for NULL path */
 395           if (p == pathname) {
 396               continue;
 397           }
 398           (void)snprintf(buffer, buflen, "%.*s/lib%s" JNI_LIB_SUFFIX,
 399                          (int)(p - pathname), pathname, fname);
 400 
 401           if (access(buffer, F_OK) == 0) {
 402               break;
 403           }
 404           if (*p == '\0') {
 405               pathname = p;
 406           } else {
 407               pathname = p + 1;
 408           }
 409           *buffer = '\0';
 410       }
 411 }
 412 
 413 /* Create the actual fill filename for a dynamic library.  */
 414 void
 415 md_build_library_name(char *holder, int holderlen, char *pname, char *fname)
 416 {
 417     int   pnamelen;
 418 
 419     /* Length of options directory location. */
 420     pnamelen = pname ? strlen(pname) : 0;
 421 
 422     *holder = '\0';
 423     /* Quietly truncate on buffer overflow.  Should be an error. */
 424     if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
 425         return;
 426     }
 427 
 428     /* Construct path to library */