You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Project Overview
6
+
7
+
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.
8
+
9
+
## Build Commands
10
+
11
+
All build commands run from the repo root using `make -C src`.
12
+
13
+
```bash
14
+
# Build C library and pactester CLI (also runs tests)
15
+
make -C src
16
+
17
+
# Build without internet-dependent tests
18
+
NO_INTERNET=1 make -C src
19
+
20
+
# Build Python module (also runs Python tests)
21
+
make -C src pymod
22
+
23
+
# Install C library and pactester
24
+
sudo make -C src install
25
+
26
+
# Install Python module
27
+
sudo make -C src install-pymod
28
+
29
+
# Clean all build artifacts
30
+
make -C src clean
31
+
32
+
# Windows build (requires MinGW/MSYS2)
33
+
make -C src -f Makefile.win32
34
+
```
35
+
36
+
## Testing
37
+
38
+
Tests run automatically as part of the build (`make -C src` runs `testpactester` target).
Test 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.
51
+
52
+
## Architecture
53
+
54
+
### Build Flow
55
+
1. QuickJS engine compiles to `src/quickjs/libquickjs.a`
56
+
2.`pacparser.c` compiles against QuickJS headers to `pacparser.o`
4.`pactester` CLI statically links against `libpacparser.a`
59
+
5. Python C extension (`_pacparser`) wraps `pacparser.o` + `libquickjs.a` via setuptools
60
+
61
+
### Key Source Files
62
+
63
+
-**`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.
64
+
-**`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`).
65
+
-**`src/pac_utils.h`** — PAC standard JavaScript functions embedded as a C string. This is Mozilla's PAC utility implementation defining `dnsDomainIs()`, `isInNet()`, `shExpMatch()`, etc.
-**`src/pymod/pacparser/__init__.py`** — Python API wrapper. Adds host auto-extraction from URLs and the `URLError` exception.
68
+
-**`src/pymod/pacparser_py.c`** — Python C extension binding `_pacparser` methods to the C library.
69
+
-**`src/pymod/setup.py`** — Python build config. Version derived from git tags.
70
+
71
+
### Platform Handling
72
+
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.
0 commit comments