Changeset 616 in openpam for trunk/lib


Ignore:
Timestamp:
Aug 7, 2012, 3:18:16 PM (8 years ago)
Author:
Dag-Erling Smørgrav
Message:

Move our strlcat() and strlcpy() implementations into .c files.
Add asprintf() and vasprintf() for systems that don't have it.

Location:
trunk/lib
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Makefile.am

    r615 r616  
    88
    99noinst_HEADERS = \
     10        openpam_asprintf.h \
    1011        openpam_constants.h \
    1112        openpam_cred.h \
     
    1617        openpam_strlcat.h \
    1718        openpam_strlcmp.h \
    18         openpam_strlcpy.h
     19        openpam_strlcpy.h \
     20        openpam_vasprintf.h
    1921
    2022libpam_la_SOURCES = \
     23        openpam_asprintf.c \
    2124        openpam_borrow_cred.c \
    2225        openpam_check_owner_perms.c \
     
    4144        openpam_set_feature.c \
    4245        openpam_static.c \
     46        openpam_strlcat.c \
     47        openpam_strlcpy.c \
    4348        openpam_straddch.c \
    4449        openpam_subst.c \
     50        openpam_vasprintf.c \
    4551        openpam_ttyconv.c \
    4652        pam_acct_mgmt.c \
  • trunk/lib/openpam_dynamic.c

    r607 r616  
    5151
    5252#include "openpam_impl.h"
     53#include "openpam_asprintf.h"
    5354
    5455#ifndef RTLD_NOW
  • trunk/lib/openpam_log.c

    r544 r616  
    4949
    5050#include "openpam_impl.h"
     51#include "openpam_asprintf.h"
    5152
    5253#ifdef OPENPAM_DEBUG
  • trunk/lib/openpam_set_option.c

    r532 r616  
    4949
    5050#include "openpam_impl.h"
     51#include "openpam_asprintf.h"
    5152
    5253/*
  • trunk/lib/openpam_strlcat.h

    r578 r616  
    3535
    3636#ifndef HAVE_STRLCAT
    37 /* like strcat(3), but always NUL-terminates; returns strlen(src) */
    38 static size_t
    39 strlcat(char *dst, const char *src, size_t size)
    40 {
    41         size_t len;
    42 
    43         for (len = 0; *dst && size > 1; ++len, --size)
    44                 dst++;
    45         for (; *src && size > 1; ++len, --size)
    46                 *dst++ = *src++;
    47         *dst = '\0';
    48         while (*src)
    49                 ++len, ++src;
    50         return (len);
    51 }
     37size_t openpam_strlcat(char *, const char *, size_t);
     38#undef strlcat
     39#define strlcat(arg, ...) openpam_strlcat(arg, __VA_ARGS__)
    5240#endif
    5341
  • trunk/lib/openpam_strlcpy.h

    r578 r616  
    3535
    3636#ifndef HAVE_STRLCPY
    37 /* like strcpy(3), but always NUL-terminates; returns strlen(src) */
    38 static size_t
    39 strlcpy(char *dst, const char *src, size_t size)
    40 {
    41         size_t len;
    42 
    43         for (len = 0; *src && size > 1; ++len, --size)
    44                 *dst++ = *src++;
    45         *dst = '\0';
    46         while (*src)
    47                 ++len, ++src;
    48         return (len);
    49 }
     37size_t openpam_strlcpy(char *, const char *, size_t);
     38#undef strlcpy
     39#define strlcpy(arg, ...) openpam_strlcpy(arg, __VA_ARGS__)
    5040#endif
    5141
  • trunk/lib/pam_setenv.c

    r539 r616  
    4747
    4848#include "openpam_impl.h"
     49#include "openpam_asprintf.h"
    4950
    5051/*
Note: See TracChangeset for help on using the changeset viewer.