suploader

Simple uploader — submit URLs to web archive services
git clone git clone https://git.krisyotam.com/krisyotam/suploader.git
Log | Files | Refs | LICENSE

CLAUDE.md (4059B)


      1 # suploader — CLAUDE.md
      2 
      3 ## Project
      4 
      5 suploader (Simple Uploader) is a suckless tool that uploads URLs to web
      6 archive services. It reads a file of URLs (one per line) or stdin and
      7 submits each to the Internet Archive (Wayback Machine), archive.today
      8 (archive.ph), and Wikiwix. Supports configurable rate limiting, random
      9 URL selection, and daemon mode for continuous background archiving.
     10 
     11 ## Coding Standards — Suckless C Style
     12 
     13 All code in this project MUST follow the suckless.org coding style:
     14 
     15 ### Language
     16 - C99 (ISO/IEC 9899:1999), no extensions
     17 - POSIX.1-2008 (`_POSIX_C_SOURCE 200809L`)
     18 
     19 ### Indentation & Whitespace
     20 - Tabs for indentation (1 tab = 1 level)
     21 - Spaces for alignment only, never for indentation
     22 - No tabs except at the beginning of a line
     23 - Maximum line length: 79 characters
     24 
     25 ### Comments
     26 - Use `/* */` only, never `//`
     27 - Comment fallthrough cases in switch statements
     28 
     29 ### Variables
     30 - All declarations at the top of the block
     31 - Pointer `*` adjacent to variable name: `char *p`, not `char* p`
     32 - No C99 `bool`; use `int` (0/1)
     33 - Global/static variables not used outside TU must be `static`
     34 
     35 ### Functions
     36 - Return type on its own line
     37 - Function name at column 0 on next line (enables `grep ^funcname`)
     38 - Opening `{` on its own line for functions
     39 - Functions not used outside their file: `static`
     40 
     41 ```c
     42 static void
     43 usage(void)
     44 {
     45 	fprintf(stderr, "usage: suploader [-v] [-d secs] file\n");
     46 	exit(1);
     47 }
     48 ```
     49 
     50 ### Braces
     51 - Opening `{` on same line for control flow (if, for, while, switch)
     52 - Closing `}` on its own line unless continuing (else, do-while)
     53 - Use braces even for single statements when sibling branches use them
     54 
     55 ### Naming
     56 - lowercase_with_underscores for functions and variables
     57 - UPPERCASE for macros and constants
     58 - CamelCase for typedef'd struct types
     59 - No `_t` suffix (reserved by POSIX)
     60 - Prefix module functions with module name
     61 
     62 ### Control Flow
     63 - Space after `if`, `for`, `while`, `switch`
     64 - No space after `(` or before `)`
     65 - Use `goto` for cleanup/unwind, not nested ifs
     66 - Return/exit early on failure
     67 - Test against 0, not -1: `if (func() < 0)`
     68 
     69 ### Error Handling
     70 - All allocation checked; goto cleanup on failure
     71 - `die()` for fatal errors (prints message, exits)
     72 - `warn()` for recoverable errors (prints, continues)
     73 
     74 ### File Organization Order
     75 1. License header
     76 2. System includes (alphabetical)
     77 3. Local includes
     78 4. Macros
     79 5. Type definitions
     80 6. Function declarations
     81 7. Global variables
     82 8. Function definitions (same order as declarations)
     83 
     84 ### Headers
     85 - System headers first, alphabetical
     86 - Local headers after blank line
     87 - No cyclic dependencies
     88 - Include only what is needed
     89 
     90 ## Architecture
     91 
     92 ### Module Layout
     93 
     94 | Module | Prefix | File | Responsibility |
     95 |--------|--------|------|----------------|
     96 | Main | — | suploader.c | Entry point, URL file I/O, daemon loop |
     97 | Services | `svc_` | services.c | Archive service submission (IA, archive.ph, Wikiwix) |
     98 | Utilities | `die`, `warn`, `x*` | util.c | Memory wrappers, string ops, error handling |
     99 | Config | — | config.h | Compile-time constants (timeouts, delays, user agent) |
    100 
    101 ### Architecture Rules
    102 - **Separate compilation.** Every .c file compiles independently.
    103 - **No dynamic loading.** All features compiled in.
    104 - **libcurl only.** Single external dependency for HTTP.
    105 - **Fire-and-forget.** Submit and move on; no verification polling.
    106 - **Text file interface.** One URL per line, Unix-philosophy I/O.
    107 
    108 ## Build
    109 
    110 ```sh
    111 make            # build suploader binary
    112 make clean      # remove build artifacts
    113 make install    # install to /usr/local/bin
    114 ```
    115 
    116 Dependencies: `libcurl` (via pkg-config)
    117 
    118 ## Usage
    119 
    120 ```sh
    121 # Upload URLs from a file
    122 suploader urls.txt
    123 
    124 # Read from stdin
    125 cat urls.txt | suploader -
    126 
    127 # Daemon mode (loop forever, process one URL per cycle)
    128 suploader -D urls.txt
    129 
    130 # Custom delay between submissions (seconds)
    131 suploader -d 60 urls.txt
    132 
    133 # Verbose output
    134 suploader -v urls.txt
    135 ```
    136 
    137 ## Git Conventions
    138 
    139 - No `Co-Authored-By: Claude` lines
    140 - Commit messages: imperative, <72 chars, no period
    141 - One logical change per commit