"Fossies" - the Fresh Open Source Software Archive

Member "udunits-2.2.28/lib/udunits_snprintf.c" (23 Nov 2020, 771 Bytes) of package /linux/privat/udunits-2.2.28.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "udunits_snprintf.c" see the Fossies "Dox" file reference documentation.

    1 /*! udunits_snprintf class for use with Visual Studio.
    2 
    3   MSVC versions less than 1900 do not implement snprintf, so we must provide our
    4   own.
    5 
    6   The following is adapted from:
    7 
    8   http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
    9 */
   10 
   11 #include "udunits2.h"
   12 
   13 int udunits_snprintf(char* str, size_t size, const char* format, ...)
   14 {
   15     int count;
   16     va_list ap;
   17 
   18     va_start(ap, format);
   19     count = udunits_vsnprintf(str, size, format, ap);
   20     va_end(ap);
   21 
   22     return count;
   23 }
   24 
   25 int udunits_vsnprintf(char* str, size_t size, const char* format, va_list ap)
   26 {
   27     int count = -1;
   28 
   29     if (size != 0)
   30         count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
   31     if (count == -1)
   32         count = _vscprintf(format, ap);
   33 
   34     return count;
   35 }