Okular

synctex_parser_utils.h
1/*
2 SPDX-FileCopyrightText: 2008-2017 jerome DOT laurens AT u-bourgogne DOT fr
3 SPDX-License-Identifier: X11
4
5 This file is part of the __SyncTeX__ package.
6
7 [//]: # (Latest Revision: Fri Jul 14 16:20:41 UTC 2017)
8 [//]: # (Version: 1.19)
9
10 See `synctex_parser_readme.md` for more details
11*/
12
13#ifndef SYNCTEX_PARSER_UTILS_H
14#define SYNCTEX_PARSER_UTILS_H
15
16/* The utilities declared here are subject to conditional implementation.
17 * All the operating system special stuff goes here.
18 * The problem mainly comes from file name management: path separator, encoding...
19 */
20
21typedef int synctex_bool_t;
22#define synctex_YES (0 == 0)
23#define synctex_NO (0 == 1)
24
25#define synctex_ADD_QUOTES -1
26#define synctex_COMPRESS -1
27#define synctex_DONT_ADD_QUOTES 0
28#define synctex_DONT_COMPRESS 0
29
30#ifndef __SYNCTEX_PARSER_UTILS__
31#define __SYNCTEX_PARSER_UTILS__
32
33#include <stdlib.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#if defined(_WIN32) || defined(__OS2__)
40#define SYNCTEX_CASE_SENSITIVE_PATH 0
41#define SYNCTEX_IS_PATH_SEPARATOR(c) ('/' == c || '\\' == c)
42#else
43#define SYNCTEX_CASE_SENSITIVE_PATH 1
44#define SYNCTEX_IS_PATH_SEPARATOR(c) ('/' == c)
45#endif
46
47#if defined(_WIN32) || defined(__OS2__)
48#define SYNCTEX_IS_DOT(c) ('.' == c)
49#else
50#define SYNCTEX_IS_DOT(c) ('.' == c)
51#endif
52
53#if SYNCTEX_CASE_SENSITIVE_PATH
54#define SYNCTEX_ARE_PATH_CHARACTERS_EQUAL(left, right) (left != right)
55#else
56#define SYNCTEX_ARE_PATH_CHARACTERS_EQUAL(left, right) (toupper(left) != toupper(right))
57#endif
58
59#ifdef __GNUC__
60#define SYNCTEX_PRINTF_FORMAT(si, ftc) __attribute__((format(printf, si, ftc)))
61#else
62#define SYNCTEX_PRINTF_FORMAT(si, ftc)
63#endif
64
65/* This custom malloc functions initializes to 0 the newly allocated memory.
66 * There is no bzero function on windows. */
67void *_synctex_malloc(size_t size);
68
69/* To balance _synctex_malloc.
70 * ptr might be NULL. */
71void _synctex_free(void *ptr);
72
73/* This is used to log some informational message to the standard error stream.
74 * On Windows, the stderr stream is not exposed and another method is used.
75 * The return value is the number of characters printed. */
76int _synctex_error(const char *reason, ...) SYNCTEX_PRINTF_FORMAT(1, 2);
77int _synctex_debug(const char *reason, ...) SYNCTEX_PRINTF_FORMAT(1, 2);
78
79/* strip the last extension of the given string, this string is modified!
80 * This function depends on the OS because the path separator may differ.
81 * This should be discussed more precisely. */
82void _synctex_strip_last_path_extension(char *string);
83
84/* Compare two file names, windows is sometimes case insensitive...
85 * The given strings may differ stricto sensu, but represent the same file name.
86 * It might not be the real way of doing things.
87 * The return value is an undefined non 0 value when the two file names are equivalent.
88 * It is 0 otherwise. */
89synctex_bool_t _synctex_is_equivalent_file_name(const char *lhs, const char *rhs);
90
91/* Description forthcoming.*/
92synctex_bool_t _synctex_path_is_absolute(const char *name);
93
94/* Description forthcoming...*/
95const char *_synctex_last_path_component(const char *name);
96
97/* Description forthcoming...*/
98const char *_synctex_base_name(const char *path);
99
100/* If the core of the last path component of src is not already enclosed with double quotes ('"')
101 * and contains a space character (' '), then a new buffer is created, the src is copied and quotes are added.
102 * In all other cases, no destination buffer is created and the src is not copied.
103 * 0 on success, which means no error, something non 0 means error, mainly due to memory allocation failure, or bad parameter.
104 * This is used to fix a bug in the first version of pdftex with synctex (1.40.9) for which names with spaces
105 * were not managed in a standard way.
106 * On success, the caller owns the buffer pointed to by dest_ref (is any) and
107 * is responsible of freeing the memory when done.
108 * The size argument is the size of the src buffer. On return the dest_ref points to a buffer sized size+2.*/
109int _synctex_copy_with_quoting_last_path_component(const char *src, char **dest_ref, size_t size);
110
111/* These are the possible extensions of the synctex file */
112extern const char *synctex_suffix;
113extern const char *synctex_suffix_gz;
114
115typedef unsigned int synctex_io_mode_t;
116
117typedef enum { synctex_io_append_mask = 1, synctex_io_gz_mask = synctex_io_append_mask << 1 } synctex_io_mode_masks_t;
118
119typedef enum { synctex_compress_mode_none = 0, synctex_compress_mode_gz = 1 } synctex_compress_mode_t;
120
121int _synctex_get_name(const char *output, const char *build_directory, char **synctex_name_ref, synctex_io_mode_t *io_mode_ref);
122
123/* returns the correct mode required by fopen and gzopen from the given io_mode */
124const char *_synctex_get_io_mode_name(synctex_io_mode_t io_mode);
125
126synctex_bool_t synctex_ignore_leading_dot_slash_in_path(const char **name);
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif
133#endif /* SYNCTEX_PARSER_UTILS_H */
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 11:49:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.