oaa-windows.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006  SRI International
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  *
00018  * SRI International: 333 Ravenswood Ave, Menlo Park, CA 94025
00019  */
00020 
00021 #ifdef _WINDOWS
00022 #include <windows.h>
00023 #include <stdio.h>
00024 #include "oaa-windows.h"
00025 
00026 enum { SNPRINTF_BUFFER_SIZE=300 };
00027 
00038 int win_oaa_snprintf(char *buffer, size_t count, const char *format, ...) {
00039   int ret = 0;
00040   static char scratch_buffer[SNPRINTF_BUFFER_SIZE];
00041   va_list args;
00042   va_start(args, format);
00043   if (buffer != NULL) {
00044     ret = _vsnprintf(buffer, count, format, args);
00045   } else {
00046     ret = _vsnprintf(scratch_buffer, SNPRINTF_BUFFER_SIZE, format, args);
00047   }
00048   va_end(args);
00049   return ret;
00050 }
00051 
00057 __int64 strtoll(const char *nptr, char **endptr, int base) {
00058   // Only base 10 is supported by this function!
00059   if (base == 10) {
00060     char *itr = (char*)nptr;
00061     while ((*itr) != '\0') {
00062       itr++;
00063     }
00064     *endptr = itr;
00065     return _atoi64(nptr);
00066   } else {
00067     fprintf(stderr, "Error: strtoll only implemented for base 10");
00068     return 0;
00069   }
00070 }
00071 #endif
00072 

Generated on Wed May 23 17:20:12 2007 using doxygen 1.5.2