Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    coccigrep 1.12

    Download button

    Downloads: 235  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Eric Leblond | More programs
    GPL / FREE
    December 29th, 2012, 20:25 GMT [view history]
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    coccigrep description

    Semantic grep for C based on Coccinelle

    coccigrep is a semantic grep for the C language based on coccinelle.

    coccigrep can be used to find where a given structure is used in code files. coccigrep depends on the spatch program which comes with coccinelle.

    As you may have guess, the source can be accessed via github.

    Examples:

    To find where in a set of files the structure named Packet is used, you can run:

    $ coccigrep -t Packet *c
    source-af-packet.c:272: p = ptv->in_p;
    source-af-packet.c:300: p->datalink = ptv->datalink;
    source-af-packet.c:758: switch(p->datalink) {


    To find where in a set of files the datalink attribute is used in the structure
    named Packet, you can simply do:

    $ coccigrep -t Packet -a datalink *c
    source-af-packet.c:300: p->datalink = ptv->datalink;
    source-af-packet.c:758: switch(p->datalink) {
    source-erf-dag.c:525: p->datalink = LINKTYPE_ETHERNET;


    If you want to be more precise and find where this attribute is set, you can use
    the operation flag (-o). One of its value is set which indicate we only want
    the match where the attribute is set:

    $ coccigrep -t Packet -a datalink -o set source*c
    source-af-packet.c:300: p->datalink = ptv->datalink;
    source-erf-dag.c:525: p->datalink = LINKTYPE_ETHERNET;

    coccigrep supports syntax highlighting through the pygments module. For example, running coccigrep -t Packet -a datalink -o test -c -A 3 -B 3 -f html /tmp/test.c will output to stdout some colorized HTML code:

    /tmp/test.c: l.300 -3, l.300 +3, Packet *p
     hdrp->sll_protocol = from.sll_protocol;
     }

     while (p->datalink >= ptv->datalink) {
     SET_PKT_LEN(p, caplen + offset);
     if (PacketCopyData(p, ptv->data, GET_PKT_LEN(p)) == -1) {
     TmqhOutputPacketpool(ptv->tv, p);

    Usage:

    usage: coccigrep [-h] [-t TYPE] [-a ATTRIBUT] [-o {used,test,set}] [-A AFTER]
     [-B BEFORE] [-c] [-f {term,html}] [-v] [--version]
     file [file ...]

    Semantic grep based on coccinelle

    positional arguments:
     file List of files

    optional arguments:
     -h, --help show this help message and exit
     -t TYPE, --type TYPE C type where looking for
     -a ATTRIBUT, --attribut ATTRIBUT
     C attribut that is set
     -o {used,test,set}, --operation {used,test,set}
     Operation on structure
     -A AFTER, --after-context AFTER
     Number of line after context
     -B BEFORE, --before-context BEFORE
     Number of line before context
     -c, --color colorize output (need pigments)
     -f {term,html}, --output-format {term,html}
     colorize format for output
     -v, --verbose verbose output (including coccinelle error)
     --version show program's version number and exit


    Run coccigrep -h for up-to-date and complete list of options.


    Product's homepage

    Requirements:

    · Python

    What's New in This Release: [ read full changelog ]

    · This version contains an improvement in recursive searching which now includes header files.
    · It also features some bugfixes.

      


    TAGS:

    semantic grep | Coccinelle grep | Coccinelle | semantic | grep

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM