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#define tds_dir_open _wfopen
33#define tds_dir_getenv _wgetenv
34#define tds_dir_dup _wcsdup
35#define tds_dir_len wcslen
36#define tds_dir_cmp wcscmp
37/* note: MS _snwprintf does not null terminate if buffer length exceeded */
38#define tds_dir_snprintf(buf, sz, ...) _snwprintf_s(buf, sz, _TRUNCATE, __VA_ARGS__)
39#define TDS_DIR_(s) L ## s
40#define TDS_DIR(s) TDS_DIR_(s)
41#define tdsPRIdir "ls"
42tds_dir_char *tds_dir_from_cstr(const char *path);
43#else
44#define TDS_SDIR_SEPARATOR "/"
45typedef char tds_dir_char;
46#define tds_dir_open fopen
47#define tds_dir_getenv getenv
48#define tds_dir_dup strdup
49#define tds_dir_len strlen
50#define tds_dir_cmp strcmp
51#define tds_dir_snprintf snprintf
52#define TDS_DIR(s) s
53#define tdsPRIdir "s"
54#define tds_dir_from_cstr(s) strdup(s)
55#endif
56
57tds_dir_char *tds_get_homedir(void);
58tds_dir_char* tds_join_path(const tds_dir_char *dir, const tds_dir_char *file);
59tds_dir_char *tds_get_home_file(const tds_dir_char *file);
60
61#include <freetds/popvis.h>
62
63#endif /* _tdsguard_eI8iNo9FExd6aRlc3im79S_ */