Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    C99-snprintf 1.1

    Download button

    No screenshots available
    Downloads: 678  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.4/5)
    17 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Holger Weiss | More programs
    MIT/X Consortium Lic... / FREE
    January 27th, 2008, 17:52 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    C99-snprintf description

    C99-snprintf provides a portable implementation of snprintf, vsnprintf, asprintf, and vasprintf.

    C99-snprintf provides a portable implementation of snprintf, vsnprintf, asprintf, and vasprintf. It should be fully C99 compliant, with the exceptions that it doesn't provide wide character support and that %a and %A conversions aren't supported. C99-snprintf should be buildable with any ANSI C compiler, it doesn't require libc functionality other than malloc (for vasprintf) and the stdarg or varargs macros, and it has no other prerequisites.

    The snprintf and vsnprintf functions are part of the C99 standard library. However, they weren't included in the C89/C90 standards and some systems don't provide C99 compliant implementations of these functions. For example, if the ouput buffer isn't big enough to hold the full conversion result, IRIX up to the current release 6.5.30 and glibc up to 2.0.x don't return the same value as with a sufficiently sized buffer (which makes it impossible to precompute the required buffer size), and some older systems (such as 64-bit Solaris 7) ignore the specified buffer size and overrun the buffer if it's too small. The asprintf and vasprintf functions aren't standardized at all. They're included with recent releases of glibc and BSD's libc, but they aren't available on other systems, such as System V (e.g., Solaris).

    So, if any of these functions are used, portable software should include replacement code which is used in case the functions aren't available or don't work correctly on the target system. This library can be included with software packages in order to provide such replacement functions.

    Usage:

    With GNU Autoconf 2.60 or newer

    Add snprintf.c to your project files. If you're using GNU Automake, you could use a line such as foo_LDADD = $(LIBOBJS) (where foo is the name of your program) in your Makefile.am.

    Add snprintf.m4 to your m4 include directory or to your acinclude.m4 file. If you're using neither, you can simply include the contents of snprintf.m4 in your configure.ac file.

    For each replacement function which might be needed in your project, call the according Autoconf macro in your configure.ac file. That is, in order to have all four replacement functions available if needed:

    HW_FUNC_VSNPRINTF
    HW_FUNC_SNPRINTF
    HW_FUNC_VASPRINTF
    HW_FUNC_ASPRINTF

    The required replacement functions should be declared in some header file included throughout your project files:

    #if HAVE_CONFIG_H
    #include < config.h >
    #endif
    #if HAVE_STDARG_H
    #include < stdarg.h >
    #if !HAVE_VSNPRINTF
    int rpl_vsnprintf(char *, size_t, const char *, va_list);
    #endif
    #if !HAVE_SNPRINTF
    int rpl_snprintf(char *, size_t, const char *, ...);
    #endif
    #if !HAVE_VASPRINTF
    int rpl_vasprintf(char **, const char *, va_list);
    #endif
    #if !HAVE_ASPRINTF
    int rpl_asprintf(char **, const char *, ...);
    #endif
    #endif /* HAVE_STDARG_H */

    Without GNU Autoconf

    If you're not using GNU Autoconf, omit the steps 2 and 3 from the above instructions. Instead:

    The following preprocessor macros should be defined to 1 if the feature or file in question is available on the target system (though basic functionality should be available as long as HAVE_STDARG_H and HAVE_STDLIB_H are defined correctly):

    HAVE_VSNPRINTF
    HAVE_SNPRINTF
    HAVE_VASPRINTF
    HAVE_ASPRINTF
    HAVE_STDARG_H
    HAVE_STDDEF_H
    HAVE_STDINT_H
    HAVE_STDLIB_H
    HAVE_INTTYPES_H
    HAVE_LOCALE_H
    HAVE_LOCALECONV
    HAVE_LCONV_DECIMAL_POINT
    HAVE_LCONV_THOUSANDS_SEP
    HAVE_LONG_DOUBLE
    HAVE_LONG_LONG_INT
    HAVE_UNSIGNED_LONG_LONG_INT
    HAVE_INTMAX_T
    HAVE_UINTMAX_T
    HAVE_UINTPTR_T
    HAVE_PTRDIFF_T
    HAVE_VA_COPY
    HAVE___VA_COPY

    The calls to the functions which should be replaced must be redefined throughout the project files:

    #define vsnprintf rpl_vsnprintf
    #define snprintf rpl_snprintf
    #define vasprintf rpl_vasprintf
    #define asprintf rpl_asprintf

    What's New in This Release:

    · Fixed the detection of infinite floating point values on IRIX (and possibly other systems) and applied another few minor cleanups.



    Product's homepage

      


    TAGS:

    snprintf function | vsnprintf function | vasprintf function | snprintf | vsnprintf | asprintf

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM