CProtoGen
A simple Python library and command-line tool for generating C function prototypes from source files.
Installation
To install it, use pip:
pip install cprotogen
Usage
Library
You can use the exposed API:
from cprotogen.generator import generate_prototypes
# Generate prototypes for multiple files
source_files = ["file1.c", "file2.c", "file3.c"]
for source in source_files:
header = source.replace(".c", ".h")
generate_prototypes(source, header, overwrite=True)
print(f"Updated {header} with prototypes from {source}")
As a Command-Line Tool
CProtoGen can be used directly from the command line:
# Generate prototypes and create/update a header file
cprotogen path/to/source.c --header path/to/header.h
# Generate prototypes and overwrite existing header file
cprotogen path/to/source.c --header path/to/existing_header.h --overwrite
# Show help
cprotogen -h
Examples
Generating Prototypes for a Simple File
from cprotogen.generator import generate_prototypes
# Input file: hello.c
"""
#include <stdio.h>
void hello_world() {
printf("Hello, World!\n");
}
"""
# Generate prototypes and create a header file
generate_prototypes("hello.c", "hello.h")
# Output file: hello.h
"""
#ifndef HELLO_H
#define HELLO_H
void hello_world();
#endif // HELLO_H
"""
Updating Existing Header with New Function
from cprotogen.generator import generate_prototypes
# Updated input file: hello.c
"""
#include <stdio.h>
void hello_world() {
printf("Hello, World!\n");
}
int add_numbers(int a, int b) {
return a + b;
}
"""
# Generate prototypes and update the header file
generate_prototypes("hello.c", "hello.h", overwrite=True)
# Updated output file: hello.h
"""
#ifndef HELLO_H
#define HELLO_H
void hello_world();
int add_numbers(int a, int b);
#endif // HELLO_H
"""
Generating Prototypes Without Creating a Header File
from cprotogen.generator import generate_prototypes
# Generate prototypes without creating a header file
prototypes = generate_prototypes("hello.c")
print(prototypes)
# Output:
# ['void hello_world();\n', 'int add_numbers(int a, int b);\n']
Metadata
Release files for cprotogen 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cprotogen-0.1.0.tar.gz | 7.7 kB | With provenance | Details for cprotogen-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cprotogen-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cprotogen-0.1.0-py3-none-any.whl |
Total release size: 14.6 kB
Release files / cprotogen-0.1.0.tar.gz
| Download URL | cprotogen-0.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4dabc9b8b7629d21ebaeb40c92ad4b4b1c94f145b72f7334213ae01ec70f5687
|
|
BLAKE2b-256 checksum How to use checksums |
dbc5b841b1d4b306e8de84601dcd7f7fd8975a96f1920ed2abbfc0d1c2013f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2024.
Transparency logRelease files / cprotogen-0.1.0-py3-none-any.whl
| Download URL | cprotogen-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
542b6a347dc30bef197580e5f19ba47bae18bf4c3c0a64dd5ee308991cdb5532
|
|
BLAKE2b-256 checksum How to use checksums |
302eb96005a29a5c103aaff97bd0867de03965810dc259ab48303a38b76a0737
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2024.
Transparency logSecurity for cprotogen 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cprotogen-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2024.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.