aboutsummaryrefslogtreecommitdiffstats
path: root/build-data
AgeCommit message (Expand)AuthorFilesLines
2016-04-18Add support for AArch32Christophe Fontaine3-4/+49
2016-04-12Add unit test infrastructure for LISP protocolFilip Tehlar1-0/+4
2016-04-11Add configure option to enable building unit testsDamjan Marion2-1/+7
2016-04-01Add options to link with external DPDK treeDamjan Marion6-3/+37
2016-03-25Use rte_mempool private data for storing vlib_buffer_tDamjan Marion2-4/+0
2016-03-25vpp-api-test and sample-plugin should depend on dpdk conditionallyDamjan Marion2-12/+13
2016-02-27Invert matching logic for *_uses_dpdk in build-data/packages/*.mkDamjan Marion3-3/+3
2016-02-26Update PowerPC (qppc) platform to build with Ubuntu cross-toolsDamjan Marion6-109/+22
2016-02-26Add support for native vpp_lite (non-dpdk) platformDamjan Marion6-10/+60
2016-02-12Performance tools, initial check-inDave Barach2-0/+10
2016-02-10Compile with -Werror, so Jenkins will catch warningsDave Barach1-4/+4
2016-02-03Need to include symbolic links in the lib package: libXXX.so, libXXX.so.0Dave Barach1-2/+4
2016-02-02Enable ganglia module integration buildDave Barach2-2/+2
2016-02-01Add a vpp-dpdk-dev package, enable plugins to use dpdk APIs directlyDave Barach1-0/+4
2016-01-29Rationalize metric names.Dave Barach1-2/+2
2016-01-28vpp metrics upload via gmond pluginDave Barach1-0/+9
2016-01-22aarch64 CPU arch / ThunderX platform initial supportDave Barach13-34/+223
2016-01-21PowerPC64-be arch support. Qemu ("qppc") platform support.Dave Barach6-0/+123
2015-12-16Move vppctl to vpp-api-testDamjan Marion2-12/+1
2015-12-16Add vppctl as a simple cli interface to vppEd Warnicke2-1/+12
2015-12-15Remove vppversion subtree, move elftool to vppinfraDamjan Marion2-2/+2
2015-12-08Initial commit of vpp code.v1.0.0Ed Warnicke14-0/+349
ght: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/* 
 *------------------------------------------------------------------
 * Copyright (c) 2006-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* Break up a delimited string into a vector of substrings */

#include <stdio.h>
#include <vppinfra/clib.h>
#include <vppinfra/vec.h>
#include <vppinfra/hash.h>
#include <stdarg.h>

/*
 * #define UNIT_TESTS 1
 * #define MATCH_TRACE 1 
 */

/*
 * delsvec
 * break up an input string into a vector of [null-terminated] u8 *'s
 * 
 * Each supplied delimiter character results in a string in the output
 * vector, unless the delimiters occur back-to-back.  When matched,
 * a whitespace character in the delimiter consumes an arbitrary
 * run of whitespace. See the unit tests at the end of this file
 * for a set of examples.
 *
 * Returns a u8 **, or NULL if the input fails to match.  It is assumed
 * that both input and fmt are C strings, not necessarily vectors.
 *
 * Output strings are both vectors and proper C strings.
 */

static u8 **string_cache;
static u8 **svec_cache;

void delsvec_recycle_this_string (u8 *s)
{
    if (s) {
        _vec_len (s) = 0;
        vec_add1(string_cache, s);
    }
}

void delsvec_recycle_this_svec (u8 **svec)
{
    if (svec) {
        if (svec_cache) {
            vec_free (svec_cache);
        }
        _vec_len (svec) = 0;
        svec_cache = svec;
    }
}

int pvl (char *a)
{
    return vec_len(a);
}

u8 **delsvec(void *input_arg, char *fmt)
{
    u8 **rv = 0;
    int input_index=0;
    u8 *this;
    int dirflag=0;
    int i;
    u8 *input = input_arg;

    if (svec_cache) {
        rv = svec_cache;
        svec_cache = 0;
    }

    while (fmt) {
        dirflag=0;
        if (vec_len (string_cache) > 0) {
            this = string_cache [vec_len(string_cache)-1];
            _vec_len (string_cache) = vec_len (string_cache) - 1;
        } else 
            this = 0;
        /*
         * '*' means one of two things: match the rest of the input, 
         * or match as many characters as possible 
         */
        if (fmt[0] == '*') {
            fmt++;
            dirflag=1;
            /*
             * no more format: eat rest of string... 
             */
            if (!fmt[0]) {
                for (;input[input_index]; input_index++)
                    vec_add1(this, input[input_index]);
                if (vec_len(this)) {
                    vec_add1(this, 0);
#ifdef MATCH_TRACE
                    printf("final star-match adds: '%s'\n", this);
#endif
                    vec_add1(rv, this);
                } else {
                    vec_add1(string_cache, this);
                }

                return(rv);
            }
        }
        /*
         * Left-to-right scan, adding chars until next delimiter char 
         * appears.
         */
        if (!dirflag) {
            while (input[input_index]) {
                if (input[input_index] == fmt[0]) {
                    /* If we just (exact) matched a whitespace delimiter */
                    if (fmt[0] == ' '){
                        /* scan forward eating whitespace */
                        while (input[input_index] == ' ' ||
                               input[input_index] == '\t' ||
                               input[input_index] == '\n')
                            input_index++;
                        input_index--;
                    }
                    goto found;
                }
                /* If we're looking for whitespace */
                if (fmt[0] == ' ') {
                    /* and we have whitespace */
                    if (input[input_index] == ' ' ||
                        input[input_index] == '\t' ||
                        input[input_index] == '\n') {
                        /* scan forward eating whitespace */
                        while (input[input_index] == ' ' ||
                               input[input_index] == '\t' ||
                               input[input_index] == '\n') {
                            input_index++;
                        }
                        input_index--;
                        goto found;
                    }
                }
                /* Not a delimiter, save it */
                vec_add1(this, input[input_index]);
                input_index++;
            }
            /*
             * Fell off the wagon, clean up and bail out 
             */
        bail:

#ifdef MATCH_TRACE
            printf("failed, fmt[0] = '%c', input[%d]='%s'\n",
                   fmt[0], input_index, &input[input_index]);
#endif
            delsvec_recycle_this_string(this);
            for (i = 0; i < vec_len(rv); i++)
                delsvec_recycle_this_string(rv[i]);
            delsvec_recycle_this_svec(rv);
            return(0);
            
        found:
            /*
             * Delimiter matched
             */
            input_index++;
            fmt++;
            /*
             * If we actually accumulated non-delimiter characters,
             * add them to the result vector
             */
            if (vec_len(this)) {
                vec_add1(this, 0);
#ifdef MATCH_TRACE
                printf("match: add '%s'\n", this);
#endif
                vec_add1(rv, this);
            } else {
                vec_add1(string_cache, this);
            }
        } else { 
            /*
             * right-to-left scan, '*' not at 
             * the end of the delimiter string 
             */
            i = input_index;
            while (input[++i])
                ; /* scan forward */
            i--;
            while (i > input_index) {
                if (input[i] == fmt[0])
                    goto found2;
                
                if (fmt[0] == ' ' || fmt[0] == '\t' ||
                    fmt[0] == '\n') {
                    if (input[i] == ' ' ||
                        input[i] == '\t' ||
                        input[i] == '\n')
                        goto found2;
                }
                i--;
            }
            goto bail;

        found2:
            for (; input_index < i; input_index++) {
                vec_add1(this, input[input_index]);
            }
            input_index++;
            fmt++;
            vec_add1(this, 0);
#ifdef MATCH_TRACE
                printf("inner '*' match: add '%s'\n", this);
#endif
            vec_add1(rv, this);
        }
    }
    return (rv);
}

#ifdef UNIT_TESTS

typedef struct utest_ {
    char *string;
    char *fmt;
} utest_t;

utest_t tests[] = {
#ifdef NOTDEF
    {"Dec  7 08:56",
     "  :*"},
    {"Dec 17 08:56",
     "  :*"},
    {"Dec  7 08:56:41.239 install/inst_repl 0/9/CPU0 t1  [40989] File List:Successfully blobbified file list. Took 1 milliseconds",
     "  ::. / //  [] *"},
    {"RP/0/9/CPU0:Dec  7 08:55:28.550 : sam_server[291]: SAM backs up digest list to memory file",
     "///:  ::. : []: *"},
    /* Expected to fail */
    {"Dec  7 08:56:41.239 install/inst_repl 0/9/CPU0 t1  [40989] File List:Successfully blobbified file list. Took 1 milliseconds",
     "///:  ::. : : *"},
    /* Expected to fail */
    {"RP/0/9/CPU0:Dec  7 08:55:28.550 : sam_server[291]: SAM backs up digest list to memory file",
     "  ::. / //  [] *"},
    {"THIS that and + theother", "*+ *"}, 
    {"Dec 12 15:33:07.103 ifmgr/errors 0/RP0/CPU0 3# t2  Failed to open IM connection: No such file or directory", "  ::. / //   *"}, 
    {"Dec 16 21:43:47.328 ifmgr/bulk 0/3/CPU0 t8  Bulk DPC async download complete. Partitions 1, node_count 1, total_out 0, out_offset 0, out_expected 0: No error","  ::. / //  *"},
    {"t:0x53034bd6 CPU:00 PROCESS :PROCCREATE_NAME",
     ": :  :*"},
    {"                       pid:1", " *"},
    {"t:0x53034cbb CPU:00 THREAD  :THCREATE      pid:1 tid:1",
     ": :  : pid: tid:*"},
    {"t:0x5303f950 CPU:00 COMM    :REC_PULSE     scoid:0x40000003 pid:364659",
     ": :  : *"},
    {"/hfr-base-3.3.85/lib/libttyconnection.dll 0xfc000000 0x0000306c 0xfc027000 0x000001c8    1", 
     "     *"},
    {"Feb 28 02:38:26.123 seqtrace 0/1/CPU0 t8  :msg_receive:ifmgr/t8:IMC_MSG_MTU_UPDATE:ppp_ma/t1", 
     "  ::.  //  ::::*"},

    {"Feb 28 02:38:26.123 seqtrace 0/1/CPU0 t8  :msg_send_event:call:ifmgr/t8:124/0:cdp/t1", 
     "  ::.  //  :msg_send_event::::*"},

    {"Feb 28 02:38:26.125 seqtrace 0/1/CPU0 t1  :msg_receive_event:cdp/t1:124/0", 
     "  ::.  //  :msg_receive_event::*"}
    {"t:0x645dd86d CPU:00 USREVENT:EVENT:100, d0:0x00000002 d1:0x00000000",
     ": : USREVENT:EVENT:, d0: *"}
    {"t:0x5303f950 CPU:00 COMM    :REC_PULSE     scoid:0x40000003 pid:364659",
     ": :  : *"},
    {"t:0x2ccf9f5a CPU:00 INT_ENTR:0x80000000 (-2147483648)       IP:0x002d8b18", 
     ": : INT_ENTR:  IP:*"}
    {"t:0xd473951c CPU:00 KER_EXIT:SCHED_GET/88 ret_val:2 sched_priority:10",
     ": : KER_EXIT:SCHED_GET : sched_priority:*"}
    {"t:0x00000123 CPU:01 SYSTEM  :FUNC_ENTER thisfn:0x40e62048 call_site:0x00000000",
    ": : SYSTEM :FUNC_ thisfn: *"},
    {"t:0x5af8de95 CPU:00 INT_HANDLER_ENTR:0x0000004d (77)       PID:8200 IP:0x00000000 AREA:0x0bf9b290", ": : INT_HANDLER_*"},
#endif
    {"t:0x6d1ff92f CPU:00 CONTROL: BUFFER sequence = 1053, num_events = 714",
     ": : CONTROL*"},
    {"t:0x6d1ff92f CPU:00 CONTROL :TIME msb:0x0000003c lsb(offset):0x6d1ff921",
     ": : CONTROL*"},
};

int main (int argc, char **argv)
{
    int i, j;
    u8 **svec;

    for (j = 0; j < ARRAY_LEN(tests); j++) {
        printf ("input string: '%s'\n", tests[j].string);
        printf ("delimiter arg: '%s'\n", tests[j].fmt);
        printf ("parse trace:\n");
        svec = delsvec(tests[j].string, tests[j].fmt);
        if (!svec) {
            printf("index %d failed\n", j);
            continue;
        }
        printf("%d substring vectors\n", vec_len(svec));
        for (i = 0; i < vec_len(svec); i++) {
            printf("[%d]: '%s'\n", i, svec[i]);
        }
        printf ("-------------------\n");
    }
    exit(0);
}
#endif