Changeset: ca4fb08b3152 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ca4fb08b3152 Modified Files: clients/Tests/exports.stable.out common/stream/stdio_stream.c common/utils/msabaoth.c common/utils/mutils.c common/utils/mutils.h gdk/gdk_bat.c gdk/gdk_bbp.c gdk/gdk_heap.c gdk/gdk_interprocess.c gdk/gdk_logger.c gdk/gdk_posix.c gdk/gdk_posix.h gdk/gdk_storage.c gdk/gdk_tracer.c gdk/gdk_utils.c monetdb5/extras/rapi/rapi.c monetdb5/mal/mal_authorize.c monetdb5/mal/mal_embedded.c monetdb5/mal/mal_linker.c monetdb5/modules/mal/bbp.c monetdb5/modules/mal/bbp.h monetdb5/modules/mal/mal_io.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/wlc.c sql/backends/monet5/UDF/capi/capi.c sql/backends/monet5/UDF/pyapi3/pyapi3.c sql/backends/monet5/vaults/fits/fits.c sql/backends/monet5/wlr.c sql/storage/bat/bat_logger.c sql/storage/store.c tools/mserver/mserver5.c tools/mserver/shutdowntest.c Branch: default Log Message:
On Windows, use the wide character interface for file names. For now, only in mserver5. This is done by creating an extra layer for library functions. On Linux, the layer is very thin indeed (inline function), but on Windows the layer converts UTF-8 strings to wide characters. Also, on Windows, we use the wmain interface to start up the server which also gives us wide characters. diffs (truncated from 2272 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -336,16 +336,25 @@ size_t HEAPmemsize(Heap *h); size_t HEAPvmsize(Heap *h); void IMPSdestroy(BAT *b); lng IMPSimprintsize(BAT *b); +int MT_access(const char *pathname, int mode); int MT_check_nr_cores(void); int MT_create_thread(MT_Id *t, void (*function)(void *), void *arg, enum MT_thr_detach d, const char *threadname); void MT_exiting_thread(void); +FILE *MT_fopen(const char *filename, const char *mode); +char *MT_getcwd(char *buffer, size_t size); MT_Id MT_getpid(void); size_t MT_getrss(void); void MT_init(void); int MT_join_thread(MT_Id t); -int MT_lockf(char *filename, int mode); +int MT_lockf(const char *filename, int mode); +int MT_mkdir(const char *dirname); +int MT_open(const char *filename, int flags); bool MT_path_absolute(const char *path); +int MT_remove(const char *filename); +int MT_rename(const char *old, const char *new); +int MT_rmdir(const char *dirname); void MT_sleep_ms(unsigned int ms); +int MT_stat(const char *filename, struct stat *stb); const char *MT_thread_getalgorithm(void); void *MT_thread_getdata(void); const char *MT_thread_getname(void); @@ -562,12 +571,9 @@ ssize_t timestamp_precision_tostr(str *b ssize_t timestamp_tostr(str *buf, size_t *len, const timestamp *val, bool external); ssize_t timestamp_tz_fromstr(const char *buf, size_t *len, timestamp **ret, bool external); const timestamp unixepoch; +wchar_t *utf8towchar(const char *src); gdk_return void_inplace(BAT *b, oid id, const void *val, bool force) __attribute__((__warn_unused_result__)); -int win_mkdir(const char *, const int mode); -int win_rename(const char *, const char *); -int win_rmdir(const char *); -int win_stat(const char *, struct stat *); -int win_unlink(const char *); +char *wchartoutf8(const wchar_t *src); int winerror(int); # mapi diff --git a/common/stream/stdio_stream.c b/common/stream/stdio_stream.c --- a/common/stream/stdio_stream.c +++ b/common/stream/stdio_stream.c @@ -165,7 +165,7 @@ file_fsetpos(stream *restrict s, fpos_t /* convert a string from UTF-8 to wide characters; the return value is * freshly allocated */ -#ifdef HAVE__WFOPEN +#ifdef NATIVE_WIN32 static wchar_t * utf8towchar(const char *src) { @@ -297,7 +297,7 @@ open_stream(const char *restrict filenam if ((s = create_stream(filename)) == NULL) return NULL; -#ifdef HAVE__WFOPEN +#ifdef NATIVE_WIN32 { wchar_t *wfname = utf8towchar(filename); wchar_t *wflags = utf8towchar(flags); @@ -506,7 +506,7 @@ file_remove(const char *filename) { int rc = -1; -#ifdef HAVE__WFOPEN +#ifdef NATIVE_WIN32 wchar_t *wfname = utf8towchar(filename); if (wfname != NULL) { rc = _wremove(wfname); diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -207,7 +207,7 @@ msab_init(const char *dbfarm, const char /* remove in a separate loop after reading the directory, * so as to not have any interference */ while (dbe != NULL) { - (void) remove(dbe->path); + (void) MT_remove(dbe->path); db = dbe; dbe = dbe->next; free(db); @@ -290,7 +290,7 @@ msab_marchScenario(const char *lang) if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), SCENARIOFILE)) != NULL) return(tmp); - if ((f = fopen(pathbuf, "a+")) != NULL) { + if ((f = MT_fopen(pathbuf, "a+")) != NULL) { if ((len = fread(buf, 1, 255, f)) > 0) { char *p; @@ -334,7 +334,7 @@ msab_retreatScenario(const char *lang) if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), SCENARIOFILE)) != NULL) return(tmp); - if ((f = fopen(pathbuf, "a+")) != NULL) { + if ((f = MT_fopen(pathbuf, "a+")) != NULL) { if ((len = fread(buf, 1, 255, f)) > 0) { char *p; char written = 0; @@ -366,7 +366,7 @@ msab_retreatScenario(const char *lang) return(NULL); } (void)fclose(f); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); return(NULL); } else { if (ferror(f)) { @@ -377,7 +377,7 @@ msab_retreatScenario(const char *lang) return strdup(buf); } (void)fclose(f); - (void) remove(pathbuf); /* empty file? try to remove */ + (void) MT_remove(pathbuf); /* empty file? try to remove */ return(NULL); } } @@ -408,7 +408,7 @@ msab_marchConnection(const char *host, c return(strdup("UNIX domain connections should be given as " "absolute path")); - if ((f = fopen(pathbuf, "a")) != NULL) { + if ((f = MT_fopen(pathbuf, "a")) != NULL) { /* append to the file */ if (port > 0) { fprintf(f, "mapi:monetdb://%s:%i/\n", host, port); @@ -440,19 +440,19 @@ msab_wildRetreat(void) if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), SCENARIOFILE)) != NULL) return(tmp); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), CONNECTIONFILE)) != NULL) return(tmp); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), STARTEDFILE)) != NULL) return(tmp); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), _sabaoth_internal_uuid)) != NULL) return(tmp); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); return(NULL); } @@ -480,7 +480,7 @@ msab_registerStarting(void) if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), UPLOGFILE)) != NULL) return(tmp); - if ((f = fopen(pathbuf, "a")) != NULL) { + if ((f = MT_fopen(pathbuf, "a")) != NULL) { /* append to the file */ fprintf(f, "%" PRId64 "\t", (int64_t)time(NULL)); (void)fflush(f); @@ -499,14 +499,14 @@ msab_registerStarting(void) free(tmp); return(NULL); } - f = fopen(pathbuf, "w"); + f = MT_fopen(pathbuf, "w"); if (f) fclose(f); /* remove any stray file that would suggest we've finished starting up */ if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), STARTEDFILE)) != NULL) return(tmp); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); return(NULL); @@ -527,7 +527,7 @@ msab_registerStarted(void) /* flag this database as started up */ if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), STARTEDFILE)) != NULL) return(tmp); - fp = fopen(pathbuf, "w"); + fp = MT_fopen(pathbuf, "w"); if (fp) fclose(fp); else @@ -550,7 +550,7 @@ msab_registerStop(void) if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), UPLOGFILE)) != NULL) return(tmp); - if ((f = fopen(pathbuf, "a")) != NULL) { + if ((f = MT_fopen(pathbuf, "a")) != NULL) { /* append to the file */ fprintf(f, "%" PRId64 "\n", (int64_t)time(NULL)); (void)fflush(f); @@ -566,7 +566,7 @@ msab_registerStop(void) * but for the sake of keeping things clean ... */ if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), _sabaoth_internal_uuid)) != NULL) return(tmp); - (void) remove(pathbuf); + (void) MT_remove(pathbuf); return(NULL); } @@ -584,7 +584,7 @@ msab_pickSecret(char **generated_secret) return e; // delete existing so we can recreate with appropriate permissions - if (remove(pathbuf) < 0 && errno != ENOENT) { + if (MT_remove(pathbuf) < 0 && errno != ENOENT) { char err[FILENAME_MAX + 512]; snprintf(err, sizeof(err), "unable to remove '%s': %s", pathbuf, strerror(errno)); @@ -625,7 +625,7 @@ msab_pickSecret(char **generated_secret) ); } - if ((fd = open(pathbuf, O_CREAT | O_WRONLY | O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) { + if ((fd = MT_open(pathbuf, O_CREAT | O_WRONLY | O_CLOEXEC)) == -1) { char err[512]; snprintf(err, sizeof(err), "unable to open '%s': %s", pathbuf, strerror(errno)); @@ -637,7 +637,7 @@ msab_pickSecret(char **generated_secret) snprintf(err, sizeof(err), "unable to open '%s': %s", pathbuf, strerror(errno)); close(fd); - (void)remove(pathbuf); + (void)MT_remove(pathbuf); free(secret); return strdup(err); } @@ -648,7 +648,7 @@ msab_pickSecret(char **generated_secret) char err[512]; snprintf(err, sizeof(err), "cannot write secret: %s", strerror(errno)); - (void)remove(pathbuf); + (void)MT_remove(pathbuf); free(secret); return strdup(err); } @@ -696,7 +696,7 @@ msab_getSingleStatus(const char *pathbuf sdb = NULL; snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); - if (stat(buf, &statbuf) == -1) + if (MT_stat(buf, &statbuf) == -1) return next; sdb = malloc(sizeof(sabdb)); @@ -722,11 +722,11 @@ msab_getSingleStatus(const char *pathbuf */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, _sabaoth_internal_uuid); - if (stat(buf, &statbuf) == 0) { + if (MT_stat(buf, &statbuf) == 0) { /* database has the same process signature as ours, which * means, it must be us, rely on the uplog state */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, UPLOGFILE); - if ((f = fopen(log, "r")) != NULL) { + if ((f = MT_fopen(log, "r")) != NULL) { (void)fseek(f, -1, SEEK_END); if (fread(data, 1, 1, f) != 1) { /* the log is empty, assume no crash */ @@ -735,7 +735,7 @@ msab_getSingleStatus(const char *pathbuf /* see if the database has finished starting */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); - if (stat(buf, &statbuf) == -1) { + if (MT_stat(buf, &statbuf) == -1) { sdb->state = SABdbStarting; } else { sdb->state = SABdbRunning; @@ -755,7 +755,7 @@ msab_getSingleStatus(const char *pathbuf } else if (fd == -1) { #ifndef WIN32 /* extract process ID from lock file */ - if ((f = fopen(buf, "r")) != NULL) { + if ((f = MT_fopen(buf, "r")) != NULL) { int pid; if (fscanf(f, "USR=%*d PID=%d TIME=", &pid) == 1) sdb->pid = pid; @@ -764,7 +764,7 @@ msab_getSingleStatus(const char *pathbuf #endif /* see if the database has finished starting */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); - if (stat(buf, &statbuf) == -1) { + if (MT_stat(buf, &statbuf) == -1) { sdb->state = SABdbStarting; } else { sdb->state = SABdbRunning; @@ -774,9 +774,9 @@ msab_getSingleStatus(const char *pathbuf * in the uplog */ snprintf(log, sizeof(log), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); /* just to be sure, remove the .started file */ - (void) remove(log); /* may fail, that's fine */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list