1
0
Fork
You've already forked libjodycode
0
Shared code used by several utilities written by Jody Bruchon - report all issues to jody@jodybruchon.com
  • C 77.4%
  • Makefile 10.8%
  • Roff 6.5%
  • Shell 5.2%
Find a file
2026年03月31日 12:23:21 -04:00
helper_code v4.1.2 release 2026年02月08日 15:40:11 -05:00
skeleton v4.1.2 release 2026年02月08日 15:40:11 -05:00
tests linkfiles: move the loop under the switch/case 2024年04月09日 17:55:31 -04:00
.gitignore Update libjodycode manual and move from section 7 to 3 2025年09月21日 13:50:18 -04:00
access.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
alarm.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
batch.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
block_hash.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
build_msvc.bat v4.1.2 release 2026年02月08日 15:40:11 -05:00
c99_aligned_alloc.c Support C99; use 'make USE_C99=1' to switch compilation to C99 2025年08月22日 08:51:47 -04:00
c99_aligned_alloc.h Support C99; use 'make USE_C99=1' to switch compilation to C99 2025年08月22日 08:51:47 -04:00
cacheinfo.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
CHANGES.txt v4.1.2 release 2026年02月08日 15:40:11 -05:00
chroot_build.sh Move libjodycode version info into libjodycode.h 2023年05月02日 14:21:10 -04:00
dir.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
error.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
fopen.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
generate_packages.sh make package: package build improvements for Linux 2025年12月27日 18:18:22 -05:00
getcwd.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
jc_fwprint.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
jody_hash.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
jody_hash.h Update jody_hash to v7.3.1 2024年02月05日 21:02:31 -05:00
jody_hash_avx2.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
jody_hash_simd.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
jody_hash_simd.h Support C99; use 'make USE_C99=1' to switch compilation to C99 2025年08月22日 08:51:47 -04:00
jody_hash_sse2.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
libjodycode.3 v4.1.2 release 2026年02月08日 15:40:11 -05:00
libjodycode.h v4.1.2 release 2026年02月08日 15:40:11 -05:00
LICENSE.txt v4.1.2 release 2026年02月08日 15:40:11 -05:00
likely_unlikely.h Add guards to likely_unlikely.h 2023年06月19日 15:38:41 -04:00
link.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
linkfiles.c Fix compile-time errors on Linux 2025年09月25日 08:48:30 -04:00
Makefile make package: package build improvements for Linux 2025年12月27日 18:18:22 -05:00
numstrcmp.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
oom.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
paths.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
README.md v4.1.2 release 2026年02月08日 15:40:11 -05:00
remove.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
rename.c Fix a minor (rare) memory leak 2026年03月31日 12:23:21 -04:00
size_suffix.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
stat.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
str_t.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
string.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
test.sh Add dummy test.sh for automated builds; add a basic man page 2023年06月12日 22:36:12 -04:00
time.c Fix minor nttime error 2026年03月31日 09:09:55 -04:00
tune_winres.sh Correct winres manifest 2023年06月17日 12:49:21 -04:00
version.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
win_unicode.c v4.1.2 release 2026年02月08日 15:40:11 -05:00
winres.manifest.xml v4.1.2 release 2026年02月08日 15:40:11 -05:00
winres.rc v4.1.2 release 2026年02月08日 15:40:11 -05:00
winres_xp.rc v4.1.2 release 2026年02月08日 15:40:11 -05:00

Introduction

In a nutshell: libjodycode helps you to write a cross-platform C console program that works on Windows and handles some Unicode complications properly.

libjodycode is a combination of a C code portability helper library and a set of useful extras such as a simple hash function. Most of the calls provided by libjodycode are drop-in replacements for C, SuS, or POSIX calls that don't work well or don't exist on Windows, mostly because Windows natively works in UTF-16 rather than UTF-8 like nearly all other operating systems. Several minor quirks are abstracted away, such as using CreateFile and FindFirstFile on Windows to read file information and open directories, or using fopen() with 'S' in mode strings to indicate an intended sequential access pattern.

It started as a pile of code shared among several 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 grew, the copied code was eventually combined into a single reusable shared library.

Please consider financially supporting continued development of libjodycode using the links on my home page (Ko-fi, PayPal, SubscribeStar, etc.):

https://www.jodybruchon.com/

Version compatibility

As of libjodycode 3.0, a "feature level" is provided. Whenever anything is added to the public API, this number increases. Programs can integrate the code under helper_code/libjodycode_check.{c,h} to dynamically check the version of libjodycode linked at run time and exit with an error if the feature level is too low or the major version is not correct. In general, you should check for the lowest feature level that your program will work with. This can be a bit difficult to determine, so the feature level in the version of libjodycode you are building against is a safe choice

To use the libjodycode_check.c/.h helper code, copy the files into the program's code somewhere, add #include "libjodycode_check.h" to the main C file, and add

if (libjodycode_version_check(verbose, bail) != 0) failure_action();

somewhere early in main(). Set verbose to 1 to output detailed error info via fprintf(stderr, ...) if a bad version is found. Set bail to 1 to have the check code immediately exit if a bad version is found instead of returning to the caller with a non-zero return value.

Building information

Some parts of libjodycode use C11 aligned_alloc(). Some users have ancient toolchains only supporting C99 properly. libjodycode now includes support code to allow C99 compilation. To build using C99 instead of C11, use USE_C99:

make USE_C99=1

You can use link-time optimization (LTO) if your compiler supports it:

make USE_LTO=1

Getting started quickly with the libjodycode skeleton

If you want to start coding with libjodycode from scratch, copy everything in the "skeleton" directory to your program directory. Make sure you place your program directroy "beside" the libjodycode source (if you're in your program's project directory, '../libjodycode' is the libjodycode source directory). You will need to modify almost every file to contain the name of your program, the correct copyright and license information, and add your own LICENSE.txt file. You need to apply a version number and version date in version.h and then run ./tune_winres.sh to modify the Windows resource files automatically to pull in your version information. To test that the template builds correctly, make sure that you've built libjodycode already, then run 'make static_jc' to build a dummy test program and try running it.

Contact information

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

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

Have a bug report or questions? contact Jody Bruchon jody@jodybruchon.com

libjodycode is Copyright (C) 2014-2026 by Jody Bruchon jody@jodybruchon.com

The MIT License

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.