Changeset 66331


Ignore:
Timestamp:
Apr 9, 2010, 12:07:54 PM (11 years ago)
Author:
jmr@…
Message:

cope with the absence of strlcpy and sysctlbyname (#22716)

Location:
trunk/base
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/configure

    r66033 r66331  
    82338233
    82348234for ac_header in limits.h paths.h sys/file.h crt_externs.h fcntl.h sys/fcntl.h sys/cdefs.h err.h sys/socket.h \
    8235         readline/readline.h readline/history.h pwd.h sys/paths.h utime.h
     8235        sys/sysctl.h readline/readline.h readline/history.h pwd.h sys/paths.h utime.h
    82368236do :
    82378237  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
     
    82518251
    82528252# Checks for library functions.
    8253 for ac_func in bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv
     8253for ac_func in bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv sysctlbyname
    82548254do :
    82558255  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
  • trunk/base/configure.ac

    r65096 r66331  
    195195AC_HEADER_SYS_WAIT
    196196AC_CHECK_HEADERS([limits.h paths.h sys/file.h crt_externs.h fcntl.h sys/fcntl.h sys/cdefs.h err.h sys/socket.h \
    197         readline/readline.h readline/history.h pwd.h sys/paths.h utime.h])
     197        sys/sysctl.h readline/readline.h readline/history.h pwd.h sys/paths.h utime.h])
    198198
    199199INCLUDES="-I.. -I. $INCLUDES"
    200200
    201201# Checks for library functions.
    202 AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv])
     202AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv sysctlbyname])
    203203MP_CHECK_READLINK_IS_P1003_1A
    204204
  • trunk/base/src/config.h.in

    r66033 r66331  
    153153#undef HAVE_STRNCASECMP
    154154
     155/* Define to 1 if you have the `sysctlbyname' function. */
     156#undef HAVE_SYSCTLBYNAME
     157
    155158/* Define to 1 if you have the <sys/cdefs.h> header file. */
    156159#undef HAVE_SYS_CDEFS_H
     
    179182#undef HAVE_SYS_STAT_H
    180183
     184/* Define to 1 if you have the <sys/sysctl.h> header file. */
     185#undef HAVE_SYS_SYSCTL_H
     186
    181187/* Define to 1 if you have the <sys/types.h> header file. */
    182188#undef HAVE_SYS_TYPES_H
  • trunk/base/src/macports1.0/sysctl.c

    r55279 r66331  
    4040#include <errno.h>
    4141#include <sys/types.h>
     42
     43#if HAVE_SYS_SYSCTL_H
    4244#include <sys/sysctl.h>
     45#endif
    4346
    4447#include "sysctl.h"
     
    4952int SysctlCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    5053{
     54#if HAVE_SYSCTLBYNAME
    5155    const char error_message[] = "sysctl failed: ";
    5256    Tcl_Obj *tcl_result;
     
    8589    Tcl_SetObjResult(interp, tcl_result);
    8690    return TCL_OK;
     91#else
     92    Tcl_SetObjResult(interp, Tcl_NewStringObj("sysctl not available", -1));
     93    return TCL_ERROR;
     94#endif
    8795}
  • trunk/base/src/pextlib1.0/tracelib.c

    r64294 r66331  
    3131 */
    3232
     33#if HAVE_CONFIG_H
    3334#include <config.h>
     35#endif
     36
    3437#include <string.h>
    3538#include <sys/time.h>
     
    4750#include <limits.h>
    4851#include "tracelib.h"
     52
     53#ifndef HAVE_STRLCPY
     54/* Define strlcpy if it's not available. */
     55size_t strlcpy(char* dst, const char* src, size_t size);
     56size_t strlcpy(char* dst, const char* src, size_t size)
     57{
     58        size_t result = strlen(src);
     59        if (size > 0)
     60        {
     61                size_t copylen = size - 1;
     62                if (copylen > result)
     63                {
     64                        copylen = result;
     65                }
     66                memcpy(dst, src, copylen);
     67                dst[copylen] = 0;
     68        }
     69        return result;
     70}
     71#endif
    4972
    5073static char * name;
Note: See TracChangeset for help on using the changeset viewer.