FreeTDS API
Loading...
Searching...
No Matches
path.h
1/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 * Copyright (C) 2023 Frediano Ziglio
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#ifndef _tdsguard_eI8iNo9FExd6aRlc3im79S_
21#define _tdsguard_eI8iNo9FExd6aRlc3im79S_
22
23#ifdef _WIN32
24#include <wchar.h>
25#endif
26
27#include <freetds/pushvis.h>
28
29#ifdef _WIN32
30#define TDS_SDIR_SEPARATOR L"\\"
31typedef wchar_t tds_dir_char;
32
33#define tds_dir_open _wfopen
34#define tds_dir_getenv _wgetenv
35#define tds_dir_dup _wcsdup
36#define tds_dir_len wcslen
37#define tds_dir_cmp wcscmp
38/* note: MS _snwprintf does not null terminate if buffer length exceeded */
39#define tds_dir_snprintf(buf, sz, ...) _snwprintf_s(buf, sz, _TRUNCATE, __VA_ARGS__)
40#define TDS_DIR_(s) L ## s
41#define TDS_DIR(s) TDS_DIR_(s)
42#define tdsPRIdir "ls"
43tds_dir_char *tds_dir_from_cstr(const char *path);
44#else
45#define TDS_SDIR_SEPARATOR "/"
46typedef char tds_dir_char;
47
48#define tds_dir_open fopen
49#define tds_dir_getenv getenv
50#define tds_dir_dup strdup
51#define tds_dir_len strlen
52#define tds_dir_cmp strcmp
53#define tds_dir_snprintf snprintf
54#define TDS_DIR(s) s
55#define tdsPRIdir "s"
56#define tds_dir_from_cstr(s) strdup(s)
57#endif
58
59tds_dir_char *tds_get_homedir(void);
60tds_dir_char *tds_join_path(const tds_dir_char * dir, const tds_dir_char * file);
61tds_dir_char *tds_get_home_file(const tds_dir_char * file);
62
63#include <freetds/popvis.h>
64
65#endif /* _tdsguard_eI8iNo9FExd6aRlc3im79S_ */