This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Pacparser is a C library (with Python bindings) for parsing proxy auto-config (PAC) files. It embeds QuickJS JavaScript engine to evaluate PAC scripts and implements the standard PAC helper functions (e.g., dnsDomainIs, isInNet, myIpAddress). Licensed under LGPL.
All build commands run from the repo root using make -C src.
# Build C library and pactester CLI (also runs tests)
make -C src
# Build without internet-dependent tests
NO_INTERNET=1 make -C src
# Build Python module (also runs Python tests)
make -C src pymod
# Install C library and pactester
sudo make -C src install
# Install Python module
sudo make -C src install-pymod
# Clean all build artifacts
make -C src clean
# Windows build (requires MinGW/MSYS2)
make -C src -f Makefile.win32Tests run automatically as part of the build (make -C src runs testpactester target).
# Run C tests manually
../tests/runtests.sh # from src/
NO_INTERNET=1 ../tests/runtests.sh # skip DNS-dependent tests
# Run Python tests manually
python ../tests/runtests.py # from src/
NO_INTERNET=1 python ../tests/runtests.pyTest data is in tests/testdata with format: <pactester params> | <expected result>. Tests use tests/proxy.pac as the PAC file. Set DEBUG=1 for verbose test output.
- QuickJS engine compiles to
src/quickjs/libquickjs.a pacparser.ccompiles against QuickJS headers topacparser.o- Shared library (
libpacparser.so.1/.dylib/.dll) linkspacparser.o+libquickjs.a pactesterCLI statically links againstlibpacparser.a- Python C extension (
_pacparser) wrapspacparser.o+libquickjs.avia setuptools
src/pacparser.c— Core library. Initializes QuickJS context, evaluates PAC scripts, implements DNS helper functions (dns_resolve,my_ip). All public API functions live here.src/pacparser.h— Public C API (9 functions:init,parse_pac_file,parse_pac_string,find_proxy,just_find_proxy,cleanup,setmyip,set_error_printer,version).src/pac_utils.h— PAC standard JavaScript functions embedded as a C string. This is Mozilla's PAC utility implementation definingdnsDomainIs(),isInNet(),shExpMatch(), etc.src/pactester.c— CLI tool wrapping the library. Usage:pactester -p <pacfile> -u <url> [-c client_ip] [-f urlslist].src/pymod/pacparser/__init__.py— Python API wrapper. Adds host auto-extraction from URLs and theURLErrorexception.src/pymod/pacparser_py.c— Python C extension binding_pacparsermethods to the C library.src/pymod/setup.py— Python build config. Version derived from git tags.
The src/Makefile detects OS via uname and adjusts shared library naming, linking flags, and compiler flags for Linux, macOS, and FreeBSD. Windows uses src/Makefile.win32 with MinGW.