1da2e3ebdSchin /*********************************************************************** 2da2e3ebdSchin * * 3da2e3ebdSchin * This software is part of the ast package * 4*b30d1939SAndy Fiddaman * Copyright (c) 1985-2011 AT&T Intellectual Property * 5da2e3ebdSchin * and is licensed under the * 6*b30d1939SAndy Fiddaman * Eclipse Public License, Version 1.0 * 77c2fbfb3SApril Chin * by AT&T Intellectual Property * 8da2e3ebdSchin * * 9da2e3ebdSchin * A copy of the License is available at * 10*b30d1939SAndy Fiddaman * http://www.eclipse.org/org/documents/epl-v10.html * 11*b30d1939SAndy Fiddaman * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 12da2e3ebdSchin * * 13da2e3ebdSchin * Information and Software Systems Research * 14da2e3ebdSchin * AT&T Research * 15da2e3ebdSchin * Florham Park NJ * 16da2e3ebdSchin * * 17da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> * 18da2e3ebdSchin * David Korn <dgk@research.att.com> * 19da2e3ebdSchin * Phong Vo <kpv@research.att.com> * 20da2e3ebdSchin * * 21da2e3ebdSchin ***********************************************************************/ 22da2e3ebdSchin #pragma prototyped 23da2e3ebdSchin /* 24da2e3ebdSchin * strptime implementation 25da2e3ebdSchin */ 26da2e3ebdSchin 27da2e3ebdSchin #define strptime ______strptime 28da2e3ebdSchin 29da2e3ebdSchin #include <ast.h> 3034f9b3eeSRoland Mainz #include <tmx.h> 31da2e3ebdSchin 32da2e3ebdSchin #undef strptime 33da2e3ebdSchin 34da2e3ebdSchin #undef _def_map_ast 35da2e3ebdSchin #include <ast_map.h> 36da2e3ebdSchin 37da2e3ebdSchin #if _lib_strptime 38da2e3ebdSchin 39da2e3ebdSchin NoN(strptime) 40da2e3ebdSchin 41da2e3ebdSchin #else 42da2e3ebdSchin 43da2e3ebdSchin #if defined(__EXPORT__) 44da2e3ebdSchin #define extern __EXPORT__ 45da2e3ebdSchin #endif 46da2e3ebdSchin 47da2e3ebdSchin extern char* 48da2e3ebdSchin strptime(const char* s, const char* format, struct tm* ts) 49da2e3ebdSchin { 50da2e3ebdSchin char* e; 51da2e3ebdSchin char* f; 52da2e3ebdSchin time_t t; 53da2e3ebdSchin Tm_t tm; 54da2e3ebdSchin 5534f9b3eeSRoland Mainz memset(&tm, 0, sizeof(tm)); 56da2e3ebdSchin tm.tm_sec = ts->tm_sec; 57da2e3ebdSchin tm.tm_min = ts->tm_min; 58da2e3ebdSchin tm.tm_hour = ts->tm_hour; 59da2e3ebdSchin tm.tm_mday = ts->tm_mday; 60da2e3ebdSchin tm.tm_mon = ts->tm_mon; 61da2e3ebdSchin tm.tm_year = ts->tm_year; 62da2e3ebdSchin tm.tm_wday = ts->tm_wday; 63da2e3ebdSchin tm.tm_yday = ts->tm_yday; 64da2e3ebdSchin tm.tm_isdst = ts->tm_isdst; 65da2e3ebdSchin t = tmtime(&tm, TM_LOCALZONE); 66da2e3ebdSchin t = tmscan(s, &e, format, &f, &t, 0); 67da2e3ebdSchin if (e == (char*)s || *f) 68da2e3ebdSchin return 0; 6934f9b3eeSRoland Mainz tmxtm(&tm, tmxclock(&t), NiL); 7034f9b3eeSRoland Mainz ts->tm_sec = tm.tm_sec; 7134f9b3eeSRoland Mainz ts->tm_min = tm.tm_min; 7234f9b3eeSRoland Mainz ts->tm_hour = tm.tm_hour; 7334f9b3eeSRoland Mainz ts->tm_mday = tm.tm_mday; 7434f9b3eeSRoland Mainz ts->tm_mon = tm.tm_mon; 7534f9b3eeSRoland Mainz ts->tm_year = tm.tm_year; 7634f9b3eeSRoland Mainz ts->tm_wday = tm.tm_wday; 7734f9b3eeSRoland Mainz ts->tm_yday = tm.tm_yday; 7834f9b3eeSRoland Mainz ts->tm_isdst = tm.tm_isdst; 79da2e3ebdSchin return e; 80da2e3ebdSchin } 81da2e3ebdSchin 82da2e3ebdSchin #endif 83