Mercurial > libpst
comparison src/libpst.c @ 182:b65e8d0a088a
more cleanup on external names in the shared object file
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 13 Apr 2009 11:39:33 -0700 |
parents | ac6e22c8a9cf |
children | 0a4f7ecd7452 |
comparison
equal
deleted
inserted
replaced
181:3b04745ff76d | 182:b65e8d0a088a |
---|---|
1671 } | 1671 } |
1672 } | 1672 } |
1673 if (table_rec.ref_type == (uint16_t)0x1f) { | 1673 if (table_rec.ref_type == (uint16_t)0x1f) { |
1674 // there is more to do for the type 0x1f unicode strings | 1674 // there is more to do for the type 0x1f unicode strings |
1675 size_t rc; | 1675 size_t rc; |
1676 static vbuf *utf16buf = NULL; | 1676 static pst_vbuf *utf16buf = NULL; |
1677 static vbuf *utf8buf = NULL; | 1677 static pst_vbuf *utf8buf = NULL; |
1678 if (!utf16buf) utf16buf = pst_vballoc((size_t)1024); | 1678 if (!utf16buf) utf16buf = pst_vballoc((size_t)1024); |
1679 if (!utf8buf) utf8buf = pst_vballoc((size_t)1024); | 1679 if (!utf8buf) utf8buf = pst_vballoc((size_t)1024); |
1680 | |
1681 // splint barfed on the following lines | |
1682 //VBUF_STATIC(utf16buf, 1024); | |
1683 //VBUF_STATIC(utf8buf, 1024); | |
1684 | 1680 |
1685 //need UTF-16 zero-termination | 1681 //need UTF-16 zero-termination |
1686 pst_vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); | 1682 pst_vbset(utf16buf, mo_ptr->elements[x]->data, mo_ptr->elements[x]->size); |
1687 pst_vbappend(utf16buf, "\0\0", (size_t)2); | 1683 pst_vbappend(utf16buf, "\0\0", (size_t)2); |
1688 DEBUG_INDEX(("Iconv in:\n")); | 1684 DEBUG_INDEX(("Iconv in:\n")); |
3932 DEBUG_RET(); | 3928 DEBUG_RET(); |
3933 return size; | 3929 return size; |
3934 } | 3930 } |
3935 | 3931 |
3936 | 3932 |
3937 #ifdef _WIN32 | |
3938 char * pst_fileTimeToAscii(const FILETIME* filetime) { | |
3939 time_t t; | |
3940 DEBUG_ENT("pst_fileTimeToAscii"); | |
3941 t = pst_fileTimeToUnixTime(filetime, 0); | |
3942 if (t == -1) | |
3943 DEBUG_WARN(("ERROR time_t varible that was produced, is -1\n")); | |
3944 DEBUG_RET(); | |
3945 return ctime(&t); | |
3946 } | |
3947 | |
3948 | |
3949 time_t pst_fileTimeToUnixTime(const FILETIME* filetime, DWORD *x) { | |
3950 SYSTEMTIME s; | |
3951 struct tm t; | |
3952 DEBUG_ENT("pst_fileTimeToUnixTime"); | |
3953 memset (&t, 0, sizeof(struct tm)); | |
3954 FileTimeToSystemTime(filetime, &s); | |
3955 t.tm_year = s.wYear-1900; // this is what is required | |
3956 t.tm_mon = s.wMonth-1; // also required! It made me a bit confused | |
3957 t.tm_mday = s.wDay; | |
3958 t.tm_hour = s.wHour; | |
3959 t.tm_min = s.wMinute; | |
3960 t.tm_sec = s.wSecond; | |
3961 DEBUG_RET(); | |
3962 return mktime(&t); | |
3963 } | |
3964 | |
3965 | |
3966 struct tm * pst_fileTimeToStructTM (const FILETIME *filetime) { | |
3967 time_t t1; | |
3968 t1 = pst_fileTimeToUnixTime(filetime, 0); | |
3969 return gmtime(&t1); | |
3970 } | |
3971 | |
3972 | |
3973 #endif //_WIN32 | |
3974 | |
3975 static int pst_stricmp(char *a, char *b) { | 3933 static int pst_stricmp(char *a, char *b) { |
3976 // compare strings case-insensitive. | 3934 // compare strings case-insensitive. |
3977 // returns -1 if a < b, 0 if a==b, 1 if a > b | 3935 // returns -1 if a < b, 0 if a==b, 1 if a > b |
3978 while(*a != '\0' && *b != '\0' && toupper(*a)==toupper(*b)) { | 3936 while(*a != '\0' && *b != '\0' && toupper(*a)==toupper(*b)) { |
3979 a++; b++; | 3937 a++; b++; |
4213 return; | 4171 return; |
4214 } | 4172 } |
4215 const char *charset = pst_default_charset(item); | 4173 const char *charset = pst_default_charset(item); |
4216 if (!strcasecmp("utf-8", charset)) return; // already utf8 | 4174 if (!strcasecmp("utf-8", charset)) return; // already utf8 |
4217 DEBUG_ENT("pst_convert_utf8"); | 4175 DEBUG_ENT("pst_convert_utf8"); |
4218 vbuf *newer = pst_vballoc(2); | 4176 pst_vbuf *newer = pst_vballoc(2); |
4219 size_t rc = pst_vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset); | 4177 size_t rc = pst_vb_8bit2utf8(newer, str->str, strlen(str->str) + 1, charset); |
4220 if (rc == (size_t)-1) { | 4178 if (rc == (size_t)-1) { |
4221 free(newer->b); | 4179 free(newer->b); |
4222 DEBUG_EMAIL(("Failed to convert %s to utf-8 - %s\n", charset, str->str)); | 4180 DEBUG_EMAIL(("Failed to convert %s to utf-8 - %s\n", charset, str->str)); |
4223 } | 4181 } |