summaryrefslogtreecommitdiff
path: root/src/util/strings.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/strings.c')
-rw-r--r--src/util/strings.c95
1 files changed, 4 insertions, 91 deletions
diff --git a/src/util/strings.c b/src/util/strings.c
index 1b4f75ab0..dc46ad33a 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -789,31 +789,9 @@ GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
789 * (otherwise we'd have to detect current codepage or use W32API character 789 * (otherwise we'd have to detect current codepage or use W32API character
790 * set conversion routines to convert to UTF8). 790 * set conversion routines to convert to UTF8).
791 */ 791 */
792#ifndef WINDOWS 792
793 strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y", tp); 793 strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y", tp);
794#else 794
795 {
796 static wchar_t wbuf[255];
797 uint8_t *conved;
798 size_t ssize;
799
800 wcsftime(wbuf,
801 sizeof(wbuf) / sizeof(wchar_t),
802 L"%a %b %d %H:%M:%S %Y",
803 tp);
804
805 ssize = sizeof(buf);
806 conved = u16_to_u8(wbuf,
807 sizeof(wbuf) / sizeof(wchar_t),
808 (uint8_t *)buf,
809 &ssize);
810 if (conved != (uint8_t *)buf)
811 {
812 GNUNET_strlcpy(buf, (char *)conved, sizeof(buf));
813 free(conved);
814 }
815 }
816#endif
817 return buf; 795 return buf;
818} 796}
819 797
@@ -1168,9 +1146,6 @@ GNUNET_STRINGS_path_is_absolute(const char *filename,
1168 int *r_is_uri, 1146 int *r_is_uri,
1169 char **r_uri_scheme) 1147 char **r_uri_scheme)
1170{ 1148{
1171#if WINDOWS
1172 size_t len;
1173#endif
1174 const char *post_scheme_path; 1149 const char *post_scheme_path;
1175 int is_uri; 1150 int is_uri;
1176 char *uri; 1151 char *uri;
@@ -1190,14 +1165,7 @@ GNUNET_STRINGS_path_is_absolute(const char *filename,
1190 *r_uri_scheme = uri; 1165 *r_uri_scheme = uri;
1191 else 1166 else
1192 GNUNET_free_non_null(uri); 1167 GNUNET_free_non_null(uri);
1193#if WINDOWS 1168
1194 len = strlen(post_scheme_path);
1195 /* Special check for file:///c:/blah
1196 * We want to parse 'c:/', not '/c:/'
1197 */
1198 if (post_scheme_path[0] == '/' && len >= 3 && post_scheme_path[2] == ':')
1199 post_scheme_path = &post_scheme_path[1];
1200#endif
1201 return GNUNET_STRINGS_path_is_absolute(post_scheme_path, 1169 return GNUNET_STRINGS_path_is_absolute(post_scheme_path,
1202 GNUNET_NO, 1170 GNUNET_NO,
1203 NULL, 1171 NULL,
@@ -1209,23 +1177,10 @@ GNUNET_STRINGS_path_is_absolute(const char *filename,
1209 if (r_is_uri) 1177 if (r_is_uri)
1210 *r_is_uri = GNUNET_NO; 1178 *r_is_uri = GNUNET_NO;
1211 } 1179 }
1212#if WINDOWS 1180
1213 len = strlen(filename);
1214 if (len >= 3 &&
1215 ((filename[0] >= 'A' && filename[0] <= 'Z') ||
1216 (filename[0] >= 'a' && filename[0] <= 'z')) &&
1217 filename[1] == ':' && (filename[2] == '/' || filename[2] == '\\'))
1218 return GNUNET_YES;
1219#endif
1220 return GNUNET_NO; 1181 return GNUNET_NO;
1221} 1182}
1222 1183
1223#if MINGW
1224#define _IFMT 0170000 /* type of file */
1225#define _IFLNK 0120000 /* symbolic link */
1226#define S_ISLNK(m) (((m) & _IFMT) == _IFLNK)
1227#endif
1228
1229 1184
1230/** 1185/**
1231 * Perform @a checks on @a filename. 1186 * Perform @a checks on @a filename.
@@ -1521,53 +1476,11 @@ GNUNET_STRINGS_get_utf8_args(int argc,
1521 int *u8argc, 1476 int *u8argc,
1522 char *const **u8argv) 1477 char *const **u8argv)
1523{ 1478{
1524#if WINDOWS
1525 wchar_t *wcmd;
1526 wchar_t **wargv;
1527 int wargc;
1528 int i;
1529 char **split_u8argv;
1530
1531 wcmd = GetCommandLineW();
1532 if (NULL == wcmd)
1533 return GNUNET_SYSERR;
1534 wargv = CommandLineToArgvW(wcmd, &wargc);
1535 if (NULL == wargv)
1536 return GNUNET_SYSERR;
1537
1538 split_u8argv = GNUNET_malloc(argc * sizeof(char *));
1539
1540 for (i = 0; i < wargc; i++)
1541 {
1542 size_t strl;
1543 /* Hopefully it will allocate us NUL-terminated strings... */
1544 split_u8argv[i] =
1545 (char *)u16_to_u8(wargv[i], wcslen(wargv[i]) + 1, NULL, &strl);
1546 if (NULL == split_u8argv[i])
1547 {
1548 int j;
1549 for (j = 0; j < i; j++)
1550 free(split_u8argv[j]);
1551 GNUNET_free(split_u8argv);
1552 LocalFree(wargv);
1553 return GNUNET_SYSERR;
1554 }
1555 }
1556
1557 *u8argv = _make_continuous_arg_copy(wargc, split_u8argv);
1558 *u8argc = wargc;
1559
1560 for (i = 0; i < wargc; i++)
1561 free(split_u8argv[i]);
1562 free(split_u8argv);
1563 return GNUNET_OK;
1564#else
1565 char *const *new_argv = 1479 char *const *new_argv =
1566 (char *const *)_make_continuous_arg_copy(argc, argv); 1480 (char *const *)_make_continuous_arg_copy(argc, argv);
1567 *u8argv = new_argv; 1481 *u8argv = new_argv;
1568 *u8argc = argc; 1482 *u8argc = argc;
1569 return GNUNET_OK; 1483 return GNUNET_OK;
1570#endif
1571} 1484}
1572 1485
1573 1486