{"id":26366764,"url":"https://github.com/stifskere/bfptr","last_synced_at":"2026-01-02T19:46:33.715Z","repository":{"id":248507078,"uuid":"828883434","full_name":"stifskere/bfptr","owner":"stifskere","description":"Run brainfuck on your pointers.","archived":false,"fork":false,"pushed_at":"2024-07-19T17:56:01.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-20T08:40:34.922Z","etag":null,"topics":["brainfuck","esoteric","joke","memory","pointers"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stifskere.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T10:13:55.000Z","updated_at":"2024-07-19T17:56:04.000Z","dependencies_parsed_at":"2024-07-15T12:16:39.215Z","dependency_job_id":"e0d7b217-1587-4ad1-91f9-70190fafb2a1","html_url":"https://github.com/stifskere/bfptr","commit_stats":null,"previous_names":["stifskere/bfptr"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stifskere%2Fbfptr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stifskere%2Fbfptr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stifskere%2Fbfptr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stifskere%2Fbfptr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stifskere","download_url":"https://codeload.github.com/stifskere/bfptr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933358,"owners_count":20370989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brainfuck","esoteric","joke","memory","pointers"],"created_at":"2025-03-16T20:46:14.391Z","updated_at":"2026-01-02T19:46:33.710Z","avatar_url":"https://github.com/stifskere.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# BFPTR, Run brainfuck on your pointers.\n\n![tests](https://github.com/stifskere/bfptr/actions/workflows/cmake-multi-platform.yml/badge.svg)\n![release](https://img.shields.io/github/v/release/stifskere/bfptr?style=flat)\n\n\u003e [!warning]\n\u003e **This repository is unmaintained**, this project is damned as finished, there are no dependencies so it will never be updated.\n\u003e\n\u003e This project was never intended to use on production, if you want to use it as a joke you can still download it.\n\nThis library exposes two functions that evaluate brainfuck\non runtime.\n\nThis library is mostly unmaintained due to its nature, and not\nmeant to be used in production.\n\n## Installation\n\nGo to the releases section of this repository, and download both files,\nyou want the `bfptr.h` which contains the definitions and the\ndocumentation for the functions and the `libbfptr.a` which is the\nlibrary binary, containing the declarations of these functions.\n\nYou can do the following if you use cmake.\n\n```cmake\n# assuming that you have your .h files here.\ninclude_directories(${CMAKE_SOURCE_DIR}/include)\n\n# link the directory containing the library.\nlink_directories(${CMAKE_SOURCE_DIR}/libs)\n\n# add your project source files before linking the library.\n\n# link this static library\ntarget_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE bfptr)\n```\n\n## Usage\n\nWhen you have it linked you will have the `bfptr.h` header\navailable for use.\n\n```c\n#include \u003cbfptr.h\u003e\n```\n\nNow you can use the functions this library exposes, which are 2, `brainfuck_on_ctx`\nwhich runs brainfuck on a specified context and `brainfuck` which\nruns brainfuck on a default isolated context.\n\n### brainfuck_on_ctx\n\nThis function asks for a `bfptr_context` which is defined the following\nway in the `bfptr.h` file.\n\n```c\ntypedef struct {\n\n    /*\n         You can or either pass `NULL` or a pointer,\n         if you pass `NULL`, the code will generate a 30_000\n         position array for you and will free it automatically.\n    */\n    unsigned char *memory;\n\n    /*\n        The memory_size is only required if you pass\n        a pointer to memory, otherwise you can set this\n        to a negative value such as -1.\n        Doing so will make the program understand that you\n        didn't pass a memory pointer.\n    */\n    int memory_size;\n\n    /*\n        The code is always required, and it's what will be\n        interpreted by the function itself.\n    */\n    const char *code;\n\n    /*\n        The output is a `char *` that stores the current memory\n        address when the `.` instruction is used in the brainfuck\n        code.\n\n        The output should be big enough to store all the printed\n        data, the output can also be null and stdout will be used\n        instead.\n\n        The function will automatically\n        NULL terminate it with a '\\0' as per the C standard on\n        strings.\n\n        This pointer will be moved, so make sure to store a\n        copy.\n    */\n    unsigned char *output;\n\n    /*\n        If this boolean value is set to \u003ctrue\u003e,\n        the error will be returned instead of thrown.\n    */\n    bool return_error;\n\n    /*\n        Set the prefix for the input instruction,\n        by default when the code is waiting for an input\n        character, you won't get notified.\n\n        To get notified, set the input_prefix which will be\n        printed every time an `,` in the brainfuck code, and\n        before the input instruction.\n\n        You can set it to NULL, so no prefix prints\n        before input.\n    */\n    const char *input_prefix;\n\n    /*\n        If set to true, this waits for the program\n        to finish before any stdout if this is false,\n        the output will be printed directly when the\n        instruction `.` is found.\n    */\n    bool defer_output;\n\n} bfptr_context;\n```\n\nThis structure acts as a context for your brainfuck execution,\nnow, the `brainfuck_on_ctx` function has the following signature:\n\n```c\nbfptr_exception *brainfuck_on_ctx(bfptr_context ctx);\n```\n\nThe function returns a `bfptr_exception` pointer which is null\non two cases, there was no error or the return_error option\nis disabled, which will lead to the program exiting with code `-1`.\n\nif there was an error and the return_error is true in the context\nan instance of `bfptr_exception` is returned, this instance\nmust be freed after consumption by using `free()` on the result.\n\nThe structure looks like this in the `bfptr.h` file\n\n```c\ntypedef union {\n\n    /*\n        The error code, you can check\n        the definitions in the documentation\n        of \u003cbfptr_error_code\u003e\n    */\n    bfptr_error_code code;\n\n    /*\n        A more specific reason for the error.\n    */\n    char *reason;\n\n} bfptr_exception;\n```\n\nThe `bfptr_error_code` is an enum which acts as a generic error\ndefinition, the values are the following: \n\n\n\u003e Invalid parameters were passed to\n\u003e the execution context.\n\u003e \n\u003e    `BFPTR_INVALID_PARAMETERS = 1 \u003c\u003c 0`\n\n\u003e Invalid or badly formatted brainfuck\n\u003e most probably an unclosed loop.\n\u003e \n\u003e `BFPTR_CODE_ERROR = 1 \u003c\u003c 1`\n\n\n\u003e Generic allocation error, not enough\n\u003e space for an internal pointer allocation\n\u003e or the memory itself if managed.\n\u003e\n\u003e `BFPTR_MEMORY_ERROR = 1 \u003c\u003c 2`\n\n### brainfuck\n\nThe `brainfuck` function has the following signature\n\n```c\nbfptr_exception *brainfuck(char *code);\n```\n\nThe `code` parameter is the code to be run, delimited by `\\0` as\nper the C standard.\n\nThis function runs `brainfuck_on_ctx` with a default context, which\nis the following\n\n```c\n(bfptr_context){\n    .memory = NULL, // a default 30000 position array that's freed automatically.\n    .memory_size = -1, // no size override specified for the context.\n    .output = NULL, // stdout as default.\n    .return_error = false, // will throw on error.\n    .code = code, // the parameter you passed as code.\n    .defer_output = true, // will wait for stdin before output.\n    .input_prefix = NULL // nothing is printed before input.\n}; \n```\n\n## Good to know\n\nYou have more information on the code comments, hovering the mouse\nover the function names. This library is not maintained as it's just made\nas a joke, so if you have any issue, I might or might not see it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstifskere%2Fbfptr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstifskere%2Fbfptr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstifskere%2Fbfptr/lists"}