Socket
Socket
Sign inDemoInstall

cdefs

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cdefs

describe c function prototypes in JSON.


Version published
Weekly downloads
6
Maintainers
1
Install size
12.5 kB
Created
Weekly downloads
 

Readme

Source

cdefs

Describe C function prototypes in JSON.

const char* get_name(int id) {
  // ...
}

=>

{
  "get_name": {
    "returns": "const char*",
    "arguments": [
      {
        "name": "id",
        "type": "int"
      }
    ]
  }
}

Install

$ npm install cdefs -g

Usage

from command-line
$ cdefs [-o output_file] [file1, [file2, [...]]]

Inspect ex1.c and ex2.c and print prototypes to stdout.

$ cdefs example/ex1.c example/ex2.c
{
  "ex1.c": {
    "main": {
      "returns": "int",
      "arguments": [
        {
          "name": "argc",
          "type": "int"
        },
        {
          "name": "argv",
          "type": "char**"
        }
      ]
    }
  },
  "ex2.c": {
    "test": {
      "returns": "float",
      "arguments": []
    },
    "print": {
      "returns": "void",
      "arguments": [
        {
          "name": " str",
          "type": "char*"
        }
      ]
    }
  }
}

Inspect ex2.c and save prototypes to ex2.json:

$ cdefs example/ex2.c -o ex2.json
from your module
var cdefs = require('cdefs');

Get the prototypes for ex1.c:

var fs = require('fs'),
    src = fs.readFileSync('./example/ex1.c', 'utf8'),
    prototypes = cdefs(src);

Contribute

Contributions are welcome.

FAQs

Last updated on 31 Aug 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc