File: libjodycode.3

package info (click to toggle)
libjodycode 4.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,680 kB
  • sloc: ansic: 2,755; makefile: 193; sh: 139; xml: 9
file content (245 lines) | stat: -rw-r--r-- 9,328 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
.\" Copyright (C) 2023-2025 by Jody Bruchon <jody@jodybruchon.com>
.TH "LIBJODYCODE" "3" "2025-01-21" "4.0" "libjodycode"
.SH NAME
libjodycode \- shared code used by several tools written by Jody Bruchon

.SH SYNOPSIS
.B #include <libjodycode.h>

.SH DESCRIPTION
libjodycode is a software code library containing code shared among several of
the programs written by Jody Bruchon such as imagepile, jdupes, winregfs, and
zeromerge. These shared pieces of code were copied between each program as
they were updated. As the number of programs increased and keeping these
pieces of code synced became more annoying, the decision was made to combine
all of them into a single reusable shared library.

.SH APPLICATION USAGE

.SS "Standard C library swap-in calls"
.nf
.BI "int jc_access(const char *" pathname ", int " mode ")"
.BI "int jc_closedir(JC_DIR * const restrict " dirp ")"
.BI "int jc_fclose(FILE *" stream ")"
.BI "FILE *jc_fopen(const char *" pathname ", const JC_WCHAR_T *" mode ")"
.BI "char *jc_getcwd(char * const restrict " pathname ", const size_t " size ")"
.BI "int jc_link(const char *" path1 ", const char *" path2 ");"
.BI "JC_DIR *jc_opendir(const char * restrict " path ")"
.BI "struct JC_DIRENT *jc_readdir(JC_DIR * const restrict " dirp ")"
.BI "int jc_rename(const char *" oldpath ", const char *" newpath ")"
.BI "int jc_remove(const char *" pathname ")"
.BI "int jc_stat(const char * const " filename ", struct JC_STAT * const restrict " buf ")"

.SS "Alarm API"
.nf
.BI "int jc_start_alarm(const unsigned int " seconds ", const int " repeat ")"
.BI "int jc_stop_alarm(void)"
.IP int\ jc_alarm_ring
Number of alarm triggers that have occurred; writable by the program

.SS "Batch file list API"
.nf
.BI "struct jc_fileinfo_batch *jc_fileinfo_batch_alloc(const int " filecnt ", const int " stat ", const int " namlen ")"
.BI "void jc_fileinfo_batch_free(struct jc_fileinfo_batch * const restrict " batch ")"

.SS "Cacheinfo API"
.nf
.BI "struct jc_proc_cacheinfo *jc_get_proc_cacheinfo(int " cleanup ")"

.SS "Directory API"
.nf
.BI "size_t jc_get_d_namlen(const struct JC_DIRENT * const restrict " dirent ")"

.SS "Error API"
.nf
.BI "const char *jc_get_errname(int " errnum ")"
.BI "const char *jc_get_errdesc(int " errnum ")"
.BI "int jc_print_error(int " errnum ")"
.IP int32_t\ jc_errno
libjodycode equivalent to C library's errno

.SS "jodyhash API"
.nf
.BI "int jc_block_hash(const enum jc_e_hash " type ", jodyhash_t *" data ", jodyhash_t *" hash ", const size_t " count ")"
.IP enum\ jc_e_hash
Selects hash type to perform, NORMAL or ROLLING
.IP #define JODY_HASH_VERSION
Version of \fIjody_hash\fP the library currently uses

.SS "Linkfiles API"
.nf
.BI "int jc_linkfiles(struct jc_fileinfo_batch * const restrict " batch ", const enum jc_e_link " linktype ")"
.IP enum\ jc_e_link
Selects type of link to perform: SYMLINK, HARDLINK, or REFLINK

.SS "OOM (out-of-memory) API"
.nf
.BI "void jc_oom(const char * restrict " msg ")"
.BI "void jc_nullptr(const char * restrict " func ")"

.SS "Path manipulation API"
.nf
.BI "int jc_collapse_dotdot(char * const " path ")"
.BI "int jc_make_relative_link_name(const char * const " src ", const char * const " dest ", char *" rel_path ")"

.SS "Size Suffix API"
.nf
.BI "const struct jc_size_suffix jc_size_suffix[]"

.SS "Numerically correct string comparison API"
.nf
.BI "int jc_numeric_strcmp(char * restrict " c1 ", char * restrict " c2 ", int " insensitive ")"

.SS "String API"
.nf
.BI "int jc_fwprint(FILE * const restrict " stream ", const char * const restrict " str ", const int " cr ")"
.BI "int jc_strncaseeq(const char *" s1 ", const char *" s2 ", const size_t " len ")"
.BI "int jc_strcaseeq(const char *" s1 ", const char *" s2 ")"
.BI "int jc_strneq(const char *" s1 ", const char *" s2 ", const size_t " len ")"
.BI "int jc_streq(const char *" s1 ", const char *" s2 ")"
.BI "JC_STR_T *jc_str_init(const char *" string ", uint32_t " len ")"
.BI "int jc_strteq(const JC_STR_T *" s1 ", const JC_STR_T *" s2 ")"
.BI "int jc_strtneq(const JC_STR_T *" s1 ", const JC_STR_T *" s2 ", const size_t " len ")"
.BI "int jc_strtcaseeq(const JC_STR_T *" s1 ", const JC_STR_T *" s2 ")"
.BI "int jc_strtncaseeq(const JC_STR_T *" s1 ", const JC_STR_T *" s2 ", const size_t " len ")"
.BI "int jc_strtcmp(const JC_STR_T *" s1 ", const JC_STR_T * " s2 " ")"
.BI "int jc_strtncmp(const JC_STR_T *" s1 ", const JC_STR_T * " s2 ", size_t " len " ")"
.BI "int jc_strtcasecmp(const JC_STR_T *" s1 ", const JC_STR_T *" s2 " ")"
.BI "int jc_strtncasecmp(const JC_STR_T *" s1 ", const JC_STR_T *" s2 ", size_t " len ")"
.IP JC_STR_T
Structure for a string with its length prefixed as a 32-bit unsigned integer
Members: len = length, str = string

.SS "Time API"
.nf
.BI "time_t jc_strtoepoch(const char * const " datetime ")"
.BI "int jc_nttime_to_unixtime(const FILETIME * const restrict " filetime ", struct JC_TIMESPEC * const restrict " unixtime ")"
.BI "int jc_unixtime_to_nttime(const struct JC_TIMESPEC * const restrict " unixtime ", FILETIME * const restrict " filetime ")"
.IP "struct JC_TIMESPEC"
libjodycode equivalent to \fIstruct timespec\fP from \fItime.h\fP

.SS "Version API"
.nf
.BI "const char *jc_version"
.BI "const char *jc_verdate"
.BI "const int jc_api_version"
.BI "const int jc_api_featurelevel"
.BI "const int jc_jodyhash_version"
.BI "const unsigned char jc_api_versiontable[]"

.BI "int jc_get_kernel_version(" void ")"
(Linux only) get current Linux kernel version as an integer

.SS "Windows-specific stat() mode test definitions"
.IP S_ISARCHIVE(st_mode) 22
is Windows archive attribute set?
.IP S_ISRO(st_mode) 22
is Windows read-only attribute set?
.IP S_ISHIDDEN(st_mode) 22
is Windows hidden attribute set?
.IP S_ISSYSTEM(st_mode) 22
is Windows system attribute set?
.IP S_ISCRYPT(st_mode) 22
is it a Windows encrypted file/dir?
.IP S_ISDIR(st_mode) 22
is it a directory?
.IP S_ISCOMPR(st_mode) 22
is it a Windows compressed file?
.IP S_ISREPARSE(st_mode) 22
is it a Windows reparse point?
.IP S_ISSPARSE(st_mode) 22
is it a Windows sparse file?
.IP S_ISTEMP(st_mode) 22
is it a Windows temporary file?
.IP S_ISREG(st_mode) 22
is it a regular file?

.SS "Windows Unicode API"
.nf
.BI "int jc_ffd_to_dirent(JC_DIR **" dirp ", HANDLE " hFind ", WIN32_FIND_DATA *" ffd ")"
.BI "void jc_set_output_modes(const int " out ", const int " err ")"
.BI "int jc_setup_unicode_terminal(int " argc ", JC_WCHAR_T **" wargv ", char ***" argv ", int * " stdout_tty ")"
.BI "void jc_slash_convert(char *" path ")"
.BI "int jc_string_to_wstring(const char * const restrict " string ", JC_WCHAR_T **" wstring ")"
.BI "int jc_widearg_to_argv(int " argc ", JC_WCHAR_T **" wargv ", char **" argv ")"


.SS "Windows Unicode wide equivalence definitions"
.nf
.IP JC_WCHAR_T 31
wchar_t for Windows Unicode, char otherwise
.IP JC_FILE_MODE_RDONLY 31
string "rb"
.IP JC_FILE_MODE_WRONLY 31
string "wb"
.IP JC_FILE_MODE_RW 31
string "w+b"
.IP JC_FILE_MODE_RW_EXISTING 31
string "r+b"
.IP JC_FILE_MODE_WRONLY_APPEND 31
string "ab"
.IP JC_FILE_MODE_RW_APPEND 31
string "a+b"
.IP JC_FILE_MODE_RDONLY_SEQ 31
string "rbS" (Windows) or "rb"
.IP JC_FILE_MODE_WRONLY_SEQ 31
string "wbS" (Windows) or "wb"
.IP JC_FILE_MODE_RW_SEQ 31
string "w+bS" (Windows) or "w+b"
.IP JC_FILE_MODE_RW_EXISTING_SEQ 31
string "r+bS" (Windows) or "r+b"
.IP JC_FILE_MODE_WRONLY_APPEND_SEQ 31
string "abS" (Windows) or "ab"
.IP JC_FILE_MODE_RW_APPEND_SEQ 31
string "a+bS" (Windows) or "a+b"
.IP JC_F_OK 10
unistd.h F_OK
.IP JC_R_OK 10
unistd.h R_OK
.IP JC_W_OK 10
unistd.h W_OK
.IP JC_X_OK 10
unistd.h X_OK

.SS "Windows Unicode conversion shortcut definitions"
.nf
.BI "M2W(char *" a ", JC_WCHAR_T *" b ")"
convert string a to wide string b using MultiByteToWideChar()

.BI "W2M(JC_WCHAR_T *" a ", char *" b ")"
convert wide string a to normal string b using WideCharToMultiByte()

.SH NOTES

libjodycode is created and maintained by Jody Bruchon <jody@jodybruchon.com>

General information, help, and tech info: http://www.jdupes.com/

Development, source code, releases: https://codeberg.org/jbruchon/libjodycode

If you find this software useful, please consider financially supporting
its development through the author's home page: https://www.jodybruchon.com/

.SH LICENSE

MIT License

Copyright (c) 2014-2025 Jody Lee Bruchon <jody@jodybruchon.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.