[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r429 - in GNUnet: . src/applications/fs/tools src/include s
From: |
durner |
Subject: |
[GNUnet-SVN] r429 - in GNUnet: . src/applications/fs/tools src/include src/util src/util/win |
Date: |
Sat, 12 Mar 2005 13:27:04 -0800 (PST) |
Author: durner
Date: 2005-03-12 13:27:01 -0800 (Sat, 12 Mar 2005)
New Revision: 429
Modified:
GNUnet/configure.ac
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/include/platform.h
GNUnet/src/include/winproc.h
GNUnet/src/util/logging.c
GNUnet/src/util/win/win.cc
GNUnet/src/util/win/winproc.c
Log:
Another symlink fix & nl_langinfo for Windows
Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2005-03-12 21:22:22 UTC (rev 428)
+++ GNUnet/configure.ac 2005-03-12 21:27:01 UTC (rev 429)
@@ -153,6 +153,7 @@
AC_CHECK_MEMBER(pthread_t.p, AC_DEFINE(HAVE_NEW_PTHREAD_T, 1,
[Define if you have a post 11/2004 pthread library]), , [#include
<pthread.h>])
+AC_CHECK_HEADER(langinfo.h)
# libgcrypt
gcrypt=0
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2005-03-12 21:22:22 UTC
(rev 428)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2005-03-12 21:27:01 UTC
(rev 429)
@@ -321,11 +321,7 @@
topKeywords[topKeywordCnt-1]
= convertToUtf8(GNoptarg,
strlen(GNoptarg),
-#ifndef MINGW
nl_langinfo(CODESET)
-#else
- ""
-#endif
);
break;
case 'K':
@@ -335,11 +331,7 @@
gloKeywords[gloKeywordCnt-1]
= convertToUtf8(GNoptarg,
strlen(GNoptarg),
-#ifndef MINGW
nl_langinfo(CODESET)
-#else
- ""
-#endif
);
break;
case 'm': {
@@ -348,11 +340,7 @@
tmp = convertToUtf8(GNoptarg,
strlen(GNoptarg),
-#ifndef MINGW
nl_langinfo(CODESET)
-#else
- ""
-#endif
);
type = EXTRACTOR_getHighestKeywordTypeNumber();
while (type > 0) {
@@ -573,19 +561,11 @@
if (timestr != NULL) {
struct tm t;
if ((NULL == strptime(timestr,
-#ifndef MINGW
nl_langinfo(D_T_FMT),
-#else
- "%Y%m%d",
-#endif
&t))) {
LOG_STRERROR(LOG_FATAL, "strptime");
errexit(_("Parsing time failed. Use '%s' format.\n"),
-#ifndef MINGW
nl_langinfo(D_T_FMT)
-#else
- "%Y%m%d"
-#endif
);
}
FREE(timestr);
Modified: GNUnet/src/include/platform.h
===================================================================
--- GNUnet/src/include/platform.h 2005-03-12 21:22:22 UTC (rev 428)
+++ GNUnet/src/include/platform.h 2005-03-12 21:27:01 UTC (rev 429)
@@ -290,4 +290,141 @@
long long atoll(const char *nptr);
#endif
+#ifndef HAVE_LANGINFO_H
+/* Modified version of glibc's langinfo.h */
+
+/* Enumeration of locale items that can be queried with `nl_langinfo'. */
+enum
+{
+ /* LC_TIME category: date and time formatting. */
+
+ /* Abbreviated days of the week. */
+ ABDAY_1, /* Sun */
+#define ABDAY_1 ABDAY_1
+ ABDAY_2,
+#define ABDAY_2 ABDAY_2
+ ABDAY_3,
+#define ABDAY_3 ABDAY_3
+ ABDAY_4,
+#define ABDAY_4 ABDAY_4
+ ABDAY_5,
+#define ABDAY_5 ABDAY_5
+ ABDAY_6,
+#define ABDAY_6 ABDAY_6
+ ABDAY_7,
+#define ABDAY_7 ABDAY_7
+
+ /* Long-named days of the week. */
+ DAY_1, /* Sunday */
+#define DAY_1 DAY_1
+ DAY_2, /* Monday */
+#define DAY_2 DAY_2
+ DAY_3, /* Tuesday */
+#define DAY_3 DAY_3
+ DAY_4, /* Wednesday */
+#define DAY_4 DAY_4
+ DAY_5, /* Thursday */
+#define DAY_5 DAY_5
+ DAY_6, /* Friday */
+#define DAY_6 DAY_6
+ DAY_7, /* Saturday */
+#define DAY_7 DAY_7
+
+ /* Abbreviated month names. */
+ ABMON_1, /* Jan */
+#define ABMON_1 ABMON_1
+ ABMON_2,
+#define ABMON_2 ABMON_2
+ ABMON_3,
+#define ABMON_3 ABMON_3
+ ABMON_4,
+#define ABMON_4 ABMON_4
+ ABMON_5,
+#define ABMON_5 ABMON_5
+ ABMON_6,
+#define ABMON_6 ABMON_6
+ ABMON_7,
+#define ABMON_7 ABMON_7
+ ABMON_8,
+#define ABMON_8 ABMON_8
+ ABMON_9,
+#define ABMON_9 ABMON_9
+ ABMON_10,
+#define ABMON_10 ABMON_10
+ ABMON_11,
+#define ABMON_11 ABMON_11
+ ABMON_12,
+#define ABMON_12 ABMON_12
+
+ /* Long month names. */
+ MON_1, /* January */
+#define MON_1 MON_1
+ MON_2,
+#define MON_2 MON_2
+ MON_3,
+#define MON_3 MON_3
+ MON_4,
+#define MON_4 MON_4
+ MON_5,
+#define MON_5 MON_5
+ MON_6,
+#define MON_6 MON_6
+ MON_7,
+#define MON_7 MON_7
+ MON_8,
+#define MON_8 MON_8
+ MON_9,
+#define MON_9 MON_9
+ MON_10,
+#define MON_10 MON_10
+ MON_11,
+#define MON_11 MON_11
+ MON_12,
+#define MON_12 MON_12
+
+ AM_STR, /* Ante meridian string. */
+#define AM_STR AM_STR
+ PM_STR, /* Post meridian string. */
+#define PM_STR PM_STR
+
+ D_T_FMT, /* Date and time format for strftime. */
+#define D_T_FMT D_T_FMT
+ D_FMT, /* Date format for strftime. */
+#define D_FMT D_FMT
+ T_FMT, /* Time format for strftime. */
+#define T_FMT T_FMT
+ T_FMT_AMPM, /* 12-hour time format for strftime. */
+#define T_FMT_AMPM T_FMT_AMPM
+
+ ERA, /* Alternate era. */
+#define ERA ERA
+ ERA_D_FMT, /* Date in alternate era format. */
+#define ERA_D_FMT ERA_D_FMT
+ ALT_DIGITS, /* Alternate symbols for digits. */
+#define ALT_DIGITS ALT_DIGITS
+ ERA_D_T_FMT, /* Date and time in alternate era format. */
+#define ERA_D_T_FMT ERA_D_T_FMT
+ ERA_T_FMT, /* Time in alternate era format. */
+#define ERA_T_FMT ERA_T_FMT
+ _DATE_FMT, /* strftime format for date. */
+#define _DATE_FMT _DATE_FMT
+ CODESET,
+#define CODESET CODESET
+ CRNCYSTR,
+#define CRNCYSTR CRNCYSTR
+ RADIXCHAR,
+#define RADIXCHAR RADIXCHAR
+ THOUSEP,
+#define THOUSEP THOUSEP
+ YESEXPR,
+#define YESEXPR YESEXPR
+ NOEXPR, /* Regex matching ``no'' input. */
+#define NOEXPR NOEXPR
+ /* This marks the highest value used. */
+ _NL_NUM
+};
+#else
+ #include <langinfo.h>
+#endif /* #ifndef HAVE_LANGINFO_H */
+
#endif
Modified: GNUnet/src/include/winproc.h
===================================================================
--- GNUnet/src/include/winproc.h 2005-03-12 21:22:22 UTC (rev 428)
+++ GNUnet/src/include/winproc.h 2005-03-12 21:27:01 UTC (rev 429)
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/timeb.h>
+#include <time.h>
#include <dirent.h>
#include <windows.h>
#include <winsock.h>
@@ -41,6 +42,7 @@
#include <objbase.h>
#include <sys/param.h> /* #define BYTE_ORDER */
#include "gnunet_util.h"
+#include "platform.h"
#ifdef __cplusplus
extern "C" {
@@ -429,6 +431,9 @@
int _win_vscanf(const char *format, va_list arg_ptr);
int _win_scanf(const char *format, ...);
int _win_fscanf(FILE *stream, const char *format, ...);
+#ifndef HAVE_LANGINFO_H
+char *nl_langinfo(int item);
+#endif
int _win_bind(SOCKET s, const struct sockaddr *name, int namelen);
int _win_connect(SOCKET s,const struct sockaddr *name, int namelen);
int _win_getpeername(SOCKET s, struct sockaddr *name,
Modified: GNUnet/src/util/logging.c
===================================================================
--- GNUnet/src/util/logging.c 2005-03-12 21:22:22 UTC (rev 428)
+++ GNUnet/src/util/logging.c 2005-03-12 21:27:01 UTC (rev 429)
@@ -135,11 +135,7 @@
}
logdate = &fullname[strlen(def->basename)];
ret = strptime(logdate,
-#ifndef MINGW
nl_langinfo(D_FMT),
-#else
- "%Y%m%d",
-#endif
&t);
if ( (ret == NULL) ||
(ret[0] != '\0') ) {
@@ -180,11 +176,7 @@
time_t curtime;
char *datefmt;
-#ifndef MINGW
datefmt = nl_langinfo(D_FMT);
-#else
- datefmt = "%Y%m%d";
-#endif
time(&curtime);
#ifdef localtime_r
localtime_r(&curtime, &def.curtime);
Modified: GNUnet/src/util/win/win.cc
===================================================================
--- GNUnet/src/util/win/win.cc 2005-03-12 21:22:22 UTC (rev 428)
+++ GNUnet/src/util/win/win.cc 2005-03-12 21:27:01 UTC (rev 429)
@@ -116,8 +116,13 @@
int iErr, iLen;
HRESULT hRes;
HANDLE hLink;
+ char szTarget[_MAX_PATH + 1];
+ if (! *pszShortcut)
+ return TRUE;
+
CoInitialize(NULL);
+ szTarget[0] = 0;
/* Create Shortcut-Object */
if (CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
@@ -228,7 +233,7 @@
free(pwszShortcut);
/* Get target file */
- if (FAILED(hRes = pLink->GetPath(pszShortcut, _MAX_PATH, NULL, 0)))
+ if (FAILED(hRes = pLink->GetPath(szTarget, _MAX_PATH, NULL, 0)))
{
pLink->Release();
pFile->Release();
@@ -247,7 +252,14 @@
CoUninitialize();
errno = 0;
- return TRUE;
+ if (szTarget[0] != 0)
+ return TRUE;
+ else
+ {
+ /* GetPath() did not return a valid path */
+ errno = EINVAL;
+ return FALSE;
+ }
}
/**
Modified: GNUnet/src/util/win/winproc.c
===================================================================
--- GNUnet/src/util/win/winproc.c 2005-03-12 21:22:22 UTC (rev 428)
+++ GNUnet/src/util/win/winproc.c 2005-03-12 21:27:01 UTC (rev 429)
@@ -50,6 +50,7 @@
unsigned int uiSockCount = 0;
Winsock *pSocks;
HANDLE hSocksLock;
+static char __langinfo[251];
static HINSTANCE hNTDLL, hIphlpapi, hAdvapi;
TNtQuerySystemInformation GNNtQuerySystemInformation;
@@ -616,6 +617,7 @@
/* Use ANSI codepage for console IO */
SetConsoleCP(CP_ACP);
SetConsoleOutputCP(CP_ACP);
+ setlocale( LC_ALL, ".OCP" );
/* Initialize COM library */
CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -1989,6 +1991,195 @@
return iLen;
}
+/**
+ * language information
+ */
+#ifndef HAVE_LANGINFO_H
+char *nl_langinfo(int item)
+{
+ unsigned int loc;
+
+ loc = GetThreadLocale();
+
+ switch(item)
+ {
+ case CODESET:
+ {
+ unsigned int cp = GetACP();
+
+ if (cp)
+ sprintf(__langinfo, "CP%u", cp);
+ else
+ strcpy(__langinfo, "UTF-8"); /* ? */
+ return __langinfo;
+ }
+ case D_T_FMT:
+ case T_FMT_AMPM:
+ case ERA_D_T_FMT:
+ strcpy(__langinfo, "%c");
+ return __langinfo;
+ case D_FMT:
+ case ERA_D_FMT:
+ strcpy(__langinfo, "%x");
+ return __langinfo;
+ case T_FMT:
+ case ERA_T_FMT:
+ strcpy(__langinfo, "%X");
+ return __langinfo;
+ case AM_STR:
+ GetLocaleInfo(loc, LOCALE_S1159, __langinfo, 251);
+ return __langinfo;
+ case PM_STR:
+ GetLocaleInfo(loc, LOCALE_S2359, __langinfo, 251);
+ return __langinfo;
+ case DAY_1:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME1, __langinfo, 251);
+ return __langinfo;
+ case DAY_2:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME2, __langinfo, 251);
+ return __langinfo;
+ case DAY_3:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME3, __langinfo, 251);
+ return __langinfo;
+ case DAY_4:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME4, __langinfo, 251);
+ return __langinfo;
+ case DAY_5:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME5, __langinfo, 251);
+ return __langinfo;
+ case DAY_6:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME6, __langinfo, 251);
+ return __langinfo;
+ case DAY_7:
+ GetLocaleInfo(loc, LOCALE_SDAYNAME7, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_1:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME1, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_2:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME2, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_3:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME3, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_4:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME4, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_5:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME5, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_6:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME6, __langinfo, 251);
+ return __langinfo;
+ case ABDAY_7:
+ GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME7, __langinfo, 251);
+ return __langinfo;
+ case MON_1:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME1, __langinfo, 251);
+ return __langinfo;
+ case MON_2:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME2, __langinfo, 251);
+ return __langinfo;
+ case MON_3:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME3, __langinfo, 251);
+ return __langinfo;
+ case MON_4:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME4, __langinfo, 251);
+ return __langinfo;
+ case MON_5:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME5, __langinfo, 251);
+ return __langinfo;
+ case MON_6:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME6, __langinfo, 251);
+ return __langinfo;
+ case MON_7:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME7, __langinfo, 251);
+ return __langinfo;
+ case MON_8:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME8, __langinfo, 251);
+ return __langinfo;
+ case MON_9:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME9, __langinfo, 251);
+ return __langinfo;
+ case MON_10:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME10, __langinfo, 251);
+ return __langinfo;
+ case MON_11:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME11, __langinfo, 251);
+ return __langinfo;
+ case MON_12:
+ GetLocaleInfo(loc, LOCALE_SMONTHNAME12, __langinfo, 251);
+ return __langinfo;
+ case ABMON_1:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME1, __langinfo, 251);
+ return __langinfo;
+ case ABMON_2:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME2, __langinfo, 251);
+ return __langinfo;
+ case ABMON_3:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME3, __langinfo, 251);
+ return __langinfo;
+ case ABMON_4:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME4, __langinfo, 251);
+ return __langinfo;
+ case ABMON_5:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME5, __langinfo, 251);
+ return __langinfo;
+ case ABMON_6:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME6, __langinfo, 251);
+ return __langinfo;
+ case ABMON_7:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME7, __langinfo, 251);
+ return __langinfo;
+ case ABMON_8:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME8, __langinfo, 251);
+ return __langinfo;
+ case ABMON_9:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME9, __langinfo, 251);
+ return __langinfo;
+ case ABMON_10:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME10, __langinfo, 251);
+ return __langinfo;
+ case ABMON_11:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME11, __langinfo, 251);
+ return __langinfo;
+ case ABMON_12:
+ GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME12, __langinfo, 251);
+ return __langinfo;
+ case ERA:
+ /* Not implemented */
+ __langinfo[0] = 0;
+ return __langinfo;
+ case ALT_DIGITS:
+ GetLocaleInfo(loc, LOCALE_SNATIVEDIGITS, __langinfo, 251);
+ return __langinfo;
+ case RADIXCHAR:
+ GetLocaleInfo(loc, LOCALE_SDECIMAL, __langinfo, 251);
+ return __langinfo;
+ case THOUSEP:
+ GetLocaleInfo(loc, LOCALE_STHOUSAND, __langinfo, 251);
+ return __langinfo;
+ case YESEXPR:
+ /* Not localized */
+ strcpy(__langinfo, "^[yY]");
+ return __langinfo;
+ case NOEXPR:
+ /* Not localized */
+ strcpy(__langinfo, "^[nN]");
+ return __langinfo;
+ case CRNCYSTR:
+ GetLocaleInfo(loc, LOCALE_STHOUSAND, __langinfo, 251);
+ if (__langinfo[0] == '0' || __langinfo[0] == '2')
+ __langinfo[0] = '-';
+ else
+ __langinfo[0] = '+';
+ GetLocaleInfo(loc, LOCALE_SCURRENCY, __langinfo + 1, 251);
+ default:
+ __langinfo[0] = 0;
+ return __langinfo;
+ }
+}
+#endif
/**
* Accepts an incoming connection attempt on a socket
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r429 - in GNUnet: . src/applications/fs/tools src/include src/util src/util/win,
durner <=