Skip to main content

A library that simplifies proxying stub functions in c

Project description

k3stubproxy

An proxy implementation to be used by embedded c stub implementations

Stub generation

Use the cli tool k3stubproxy-generate-stub included in this package.

Requirements:

  • Stub functions begin with extern
  • In the code documnetation a parameter is labled in/out in the following style
    • param [in] variableName
    • param [out] variableName

V0.1.0 Help:

usage: k3stubproxy-generate-stub [-h] [--func_prefix FUNC_PREFIX]
                                 [--filename_suffix FILENAME_SUFFIX]
                                 [--file_header FILE_HEADER]
                                 [--stub_function_definition_out STUB_FUNCTION_DEFINITION_OUT]
                                 [-o OUTPUT] [-v] [-vv]
                                 files [files ...]

Tool for generating stub.c files that work with k3stubproxy from implemented stub.c files

Author: Joachim Kestner <joachim.kestner@khoch3.de>
Version: 0.1.0

positional arguments:
  files                 One or more files to be parsed for stub creation

optional arguments:
  -h, --help            show this help message and exit
  --func_prefix FUNC_PREFIX
                        A function prefix that will, if set, only stub
                        functions that match this prefix
  --filename_suffix FILENAME_SUFFIX
                        A suffix that is added before the extension for
                        created files
  --file_header FILE_HEADER
                        Path to a file whose contents will become the initial
                        part of each file. Use for generic includes.
  --stub_function_definition_out STUB_FUNCTION_DEFINITION_OUT
                        File path to which the stub function definition will
                        be written to as json. Default:
                        stub_function_definition.json
  -o OUTPUT, --output OUTPUT
                        Output directory. Default is .
  -v, --verbose         Enable info logging
  -vv, --extra_verbose  Enable debug logging

Example CLI Usage

k3stubproxy-generate-stub -v ../Code/HAL/HAL_*.c --func_prefix HAL_ -o ../Code/HAL/high_level_stub/ --filename_suffix _teststub --file_header defheader.txt --stub_function_definition_out stub_function_definition.json

Example usage within C

C API usage

General Information About Embedding Python Within C

char* phDir = "/some/path/to/a/venv";
printf("INFO: Using virutalenv: %s", phDir);
// This should not be some hard code palth like /home/annoying_user/temp/project123
// For example in some usages of the k3stubproxy this is set dynamically to look
// beside the exe vor the venv

// Note: Need to check return of Py_DecodeLocale is != NULL
Py_SetPythonHome(Py_DecodeLocale(phDir, NULL));

//optional but recommended
wchar_t *program = Py_DecodeLocale("stub_program", NULL);
Py_SetProgramName(program);

Py_Initialize();

// Then any lib within the venv can be used via cpython
PyRun_SimpleString("import k3stubproxy;");

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k3stubproxy-0.1.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k3stubproxy-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file k3stubproxy-0.1.1.tar.gz.

File metadata

  • Download URL: k3stubproxy-0.1.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for k3stubproxy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1b8ba3758985342270e0db141cede3ff9ad1dbd9776e4c413995caeedffe17f1
MD5 6f57ed5d9de1d46db33115ebe9b77fec
BLAKE2b-256 05d0471e00a55d06ee9e5aaf2f824e20188f3b0a117ac7b85d9ff287f6a93454

See more details on using hashes here.

File details

Details for the file k3stubproxy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: k3stubproxy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for k3stubproxy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad9ca55325835e8e4146d4c1ed38de3d1414f62b7910037a57c5802dda93298a
MD5 105b0cd6c877eff021ed6a083bff577c
BLAKE2b-256 645584953f5e4478d4e9d447a4495534b1cd4c5b752147a28644ed451394a642

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page