mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
5f64276fb2
modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/block.h modified: storage/connect/bson.cpp modified: storage/connect/cmgoconn.cpp modified: storage/connect/colblk.cpp modified: storage/connect/domdoc.cpp modified: storage/connect/filamap.cpp modified: storage/connect/filamdbf.cpp modified: storage/connect/filamfix.cpp modified: storage/connect/filamgz.cpp modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filamzip.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/fmdlex.c modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/javaconn.cpp modified: storage/connect/javaconn.h modified: storage/connect/jdbconn.cpp modified: storage/connect/jmgfam.cpp modified: storage/connect/json.cpp modified: storage/connect/macutil.cpp modified: storage/connect/macutil.h modified: storage/connect/maputil.cpp modified: storage/connect/mycat.cc modified: storage/connect/myconn.cpp modified: storage/connect/myconn.h modified: storage/connect/myutil.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/odbconn.h modified: storage/connect/os.h modified: storage/connect/osutil.c modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/plugutil.cpp modified: storage/connect/rcmsg.c modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabext.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabmac.cpp modified: storage/connect/tabmac.h modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/taboccur.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabrest.cpp modified: storage/connect/tabrest.h modified: storage/connect/tabsys.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxcl.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h - Fix Date errors and SSL warnings modified: storage/connect/mysql-test/connect/r/jdbc.result modified: storage/connect/mysql-test/connect/r/jdbc_new.result modified: storage/connect/mysql-test/connect/t/jdbc.test modified: storage/connect/mysql-test/connect/t/jdbc_new.test - Update java source files modified: storage/connect/Mongo2Interface.java modified: storage/connect/Mongo3Interface.java added: storage/connect/Client2.java added: storage/connect/Client3.java added: storage/connect/TestInsert2.java added: storage/connect/TestInsert3.java
179 lines
3.8 KiB
C
179 lines
3.8 KiB
C
/* Copyright (C) MariaDB Corporation Ab */
|
|
#include "my_global.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "osutil.h"
|
|
|
|
#ifdef _WIN32
|
|
my_bool CloseFileHandle(HANDLE h)
|
|
{
|
|
return !CloseHandle(h);
|
|
} /* end of CloseFileHandle */
|
|
|
|
#else /* UNIX */
|
|
/* code to handle Linux and Solaris */
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <ctype.h>
|
|
#include <fcntl.h>
|
|
#include <pwd.h>
|
|
|
|
extern FILE *debug;
|
|
|
|
/***********************************************************************/
|
|
/* Define some functions not existing in the UNIX library. */
|
|
/***********************************************************************/
|
|
PSZ strupr(PSZ p)
|
|
{
|
|
register int i;
|
|
|
|
for (i = 0; p[i]; i++)
|
|
p[i] = toupper(p[i]);
|
|
|
|
return (p);
|
|
} /* end of strupr */
|
|
|
|
PSZ strlwr(PSZ p)
|
|
{
|
|
register int i;
|
|
|
|
for (i = 0; p[i]; i++)
|
|
p[i] = tolower(p[i]);
|
|
|
|
return (p);
|
|
} /* end of strlwr */
|
|
|
|
/***********************************************************************/
|
|
/* Define the splitpath function not existing in the UNIX library. */
|
|
/***********************************************************************/
|
|
void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
|
|
{
|
|
LPCSTR p2, p = name;
|
|
|
|
#ifdef DEBTRACE
|
|
htrc("SplitPath: name=%s [%s (%d)]\n",
|
|
XSTR(name), XSTR(__FILE__), __LINE__);
|
|
#endif
|
|
|
|
if (drive) *drive = '\0';
|
|
if (dir) *dir = '\0';
|
|
if (fn) *fn = '\0';
|
|
if (ft) *ft = '\0';
|
|
|
|
if ((p2 = strrchr(p, '/'))) {
|
|
p2++;
|
|
if (dir) strncat(dir, p, p2 - p);
|
|
p = p2;
|
|
} /* endif p2 */
|
|
|
|
if ((p2 = strrchr(p, '.'))) {
|
|
if (fn) strncat(fn, p, p2 - p);
|
|
if (ft) strcpy(ft, p2);
|
|
} else
|
|
if (fn) strcpy(fn, p);
|
|
|
|
#ifdef DEBTRACE
|
|
htrc("SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n",
|
|
XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__);
|
|
#endif
|
|
} /* end of _splitpath */
|
|
|
|
/***********************************************************************/
|
|
/* Define the makepath function not existing in the UNIX library. */
|
|
/***********************************************************************/
|
|
void _makepath(LPSTR name, LPCSTR drive __attribute__((unused)), LPCSTR dir, LPCSTR fn, LPCSTR ft)
|
|
{
|
|
int n;
|
|
|
|
if (!name)
|
|
return;
|
|
else
|
|
*name = '\0';
|
|
|
|
if (dir && (n = strlen(dir)) > 0) {
|
|
strcpy(name, dir);
|
|
|
|
if (name[n-1] != '/')
|
|
strcat(name, "/");
|
|
|
|
} /* endif dir */
|
|
|
|
if (fn)
|
|
strcat(name, fn);
|
|
|
|
if (ft && strlen(ft)) {
|
|
if (*ft != '.')
|
|
strcat(name, ".");
|
|
|
|
strcat(name, ft);
|
|
} /* endif ft */
|
|
|
|
} /* end of _makepath */
|
|
|
|
my_bool CloseFileHandle(HANDLE h)
|
|
{
|
|
return (close(h)) ? TRUE : FALSE;
|
|
} /* end of CloseFileHandle */
|
|
|
|
int GetLastError()
|
|
{
|
|
return errno;
|
|
} /* end of GetLastError */
|
|
|
|
unsigned long _filelength(int fd)
|
|
{
|
|
struct stat st;
|
|
|
|
if (fd == -1)
|
|
return 0;
|
|
|
|
if (fstat(fd, &st) != 0)
|
|
return 0;
|
|
|
|
return st.st_size;
|
|
} /* end of _filelength */
|
|
|
|
char *_fullpath(char *absPath, const char *relPath, size_t maxLength)
|
|
{
|
|
// Fixme
|
|
char *p;
|
|
|
|
if ( *relPath == '\\' || *relPath == '/' ) {
|
|
strncpy(absPath, relPath, maxLength);
|
|
} else if (*relPath == '~') {
|
|
// get the path to the home directory
|
|
struct passwd *pw = getpwuid(getuid());
|
|
const char *homedir = pw->pw_dir;
|
|
|
|
if (homedir)
|
|
strcat(strncpy(absPath, homedir, maxLength), relPath + 1);
|
|
else
|
|
strncpy(absPath, relPath, maxLength);
|
|
|
|
} else {
|
|
char buff[2*_MAX_PATH];
|
|
|
|
p= getcwd(buff, _MAX_PATH);
|
|
assert(p);
|
|
strcat(buff,"/");
|
|
strcat(buff, relPath);
|
|
strncpy(absPath, buff, maxLength);
|
|
} /* endif's relPath */
|
|
|
|
p = absPath;
|
|
|
|
for(; *p; p++)
|
|
if (*p == '\\')
|
|
*p = '/';
|
|
|
|
return absPath;
|
|
} /* end of _fullpath */
|
|
|
|
BOOL MessageBeep(uint i __attribute__((unused)))
|
|
{
|
|
// Fixme
|
|
return TRUE;
|
|
} /* end of MessageBeep */
|
|
|
|
#endif // UNIX
|