/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
#ifndef XPTIHTTP_H
#define XPTIHTTP_H


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys\types.h>
#include <sys\timeb.h>
#include <sys\stat.h>
#include <time.h>
#include <windows.h>

#include "xpttypes.h"

#define CACHE_BUFFER_SIZE   2000    // Size of the transfer buffer
#define CHUNK_HEADER_SIZE   8 // size of a chunk header.
		                      // must be greater than (CACHE_BUFFER_SIZE LOG 10) + 2


#define ltoa _ltoa

CString_t _getTime (StringBuffer_t pchBuffer) // in: buffer to a chunk of memory
   {
   const char *wdy [] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
   const char *mon [] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

   // CE CRTL does not support time or gmtime
   SYSTEMTIME st;

   GetSystemTime(&st);

   sprintf ((char *) pchBuffer,
            "%s, %d %s %d %02d:%02d:%02d GMT",
            wdy[st.wDayOfWeek], st.wDay, mon[st.wMonth-1], st.wYear,
            st.wHour, st.wMinute, st.wSecond);

   return pchBuffer;
   }

/*

CString_t _getTime (StringBuffer_t pchBuffer) // in: buffer to a chunk of memory
   {
   const char *wdy [] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
   const char *mon [] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
   char achDist [8];
   struct tm * t;
   time_t tm;
   time (&tm);
   t = gmtime (&tm);

   if (t->tm_isdst == 0)
      achDist [0] = '\0';

   else if (t->tm_isdst > 0)
      {
      achDist [0] = '+';
      itoa (t->tm_isdst, achDist+1, 10);
      }

   else
      itoa (t->tm_isdst, achDist, 10);

   sprintf ((char *) pchBuffer,
            "%s, %d %s %d %02d:%02d:%02d GMT%s",
            wdy[t->tm_wday], t->tm_mday, mon[t->tm_mon], t->tm_year+1900,
            t->tm_hour, t->tm_min, t->tm_sec, achDist);
   return pchBuffer;
   }

*/
#endif
