00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include <stdarg.h> 00004 #include <unistd.h> 00005 #include <assert.h> 00006 #include <grass/gis.h> 00007 00008 /* IMPORTANT NOTE: 00009 the use of snprintf()/G_snprintf() is discouraged in favour 00010 of calculating how long the string will be and allocating 00011 enough memory! 00012 */ 00013 00014 /* TODO: if needed, implement alternative versions for portability. 00015 potential code source: 00016 - http://www.ijs.si/software/snprintf/ 00017 - openssh's snprintf() implementation: bsd-snprintf.c 00018 */ 00019 00020 /* #ifdef HAVE_SNPRINTF */ 00021 00022 int G_snprintf(char *str, size_t size, const char *fmt, ...) 00023 { 00024 va_list ap; 00025 int count; 00026 00027 va_start(ap, fmt); 00028 count = vsnprintf (str, size, fmt, ap); 00029 va_end(ap); 00030 00031 return count; 00032 } 00033 00034 /* #endif */