Skip to content
pi-c Documentation
Login

Documentation

/* Inputs that are files by nature (input.c): AGENTS.md and the other
 * instruction files, models.json, the certificate bundle, and the prompt templates (prompts.c, which
 * lists their directories through pic_platform's input_list). They are read through this one function so a build
 * without a filesystem can supply them another way. */
#ifndef PIC_INPUT_H
#define PIC_INPUT_H

#include <stddef.h>

enum {
    /* Refuse a file not owned by the user or root, or writable by others,
     * or in such a directory (errno EPERM): for the certificate bundle. */
    PIC_INPUT_TRUSTED = 1,
    /* Over max: return the first max bytes and set *truncated, instead of
     * failing with EFBIG. */
    PIC_INPUT_TRUNCATE = 2,
};

/* The whole regular file at PATH (malloc'd, NUL-terminated, *len bytes), or
 * NULL with errno: ENOENT when it is missing (or not a regular file), EFBIG
 * when over MAX, EPERM when PIC_INPUT_TRUSTED refuses it. */
char *pic_input_read(const char *path, size_t max, int flags, size_t *len, int *truncated);

#endif