コード例 #1
0
ファイル: play_mp3_example.c プロジェクト: xieweimin/esp-adf
void app_main(void)
{
    audio_pipeline_handle_t pipeline;
    audio_element_handle_t i2s_stream_writer, mp3_decoder;
    esp_log_level_set("*", ESP_LOG_WARN);
    esp_log_level_set(TAG, ESP_LOG_INFO);


    ESP_LOGI(TAG, "[ 1 ] Start audio codec chip");
    audio_hal_codec_config_t audio_hal_codec_cfg =  AUDIO_HAL_ES8388_DEFAULT();
    audio_hal_handle_t hal = audio_hal_init(&audio_hal_codec_cfg, 0);
    audio_hal_ctrl_codec(hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START);

    ESP_LOGI(TAG, "[ 2 ] Create audio pipeline, add all elements to pipeline, and subscribe pipeline event");
    audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
    pipeline = audio_pipeline_init(&pipeline_cfg);
    mem_assert(pipeline);

    ESP_LOGI(TAG, "[2.1] Create mp3 decoder to decode mp3 file and set custom read callback");
    mp3_decoder_cfg_t mp3_cfg = DEFAULT_MP3_DECODER_CONFIG();
    mp3_decoder = mp3_decoder_init(&mp3_cfg);
    audio_element_set_read_cb(mp3_decoder, mp3_music_read_cb, NULL);

    ESP_LOGI(TAG, "[2.2] Create i2s stream to write data to codec chip");
    i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();
    i2s_cfg.type = AUDIO_STREAM_WRITER;
    i2s_stream_writer = i2s_stream_init(&i2s_cfg);

    ESP_LOGI(TAG, "[2.3] Register all elements to audio pipeline");
    audio_pipeline_register(pipeline, mp3_decoder, "mp3");
    audio_pipeline_register(pipeline, i2s_stream_writer, "i2s");

    ESP_LOGI(TAG, "[2.4] Link it together [mp3_music_read_cb]-->mp3_decoder-->i2s_stream-->[codec_chip]");
    audio_pipeline_link(pipeline, (const char *[]) {"mp3", "i2s"}, 2);
コード例 #2
0
ファイル: testscrp.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    int
        argn;
    char
       *arg;
    Bool
        parallel = FALSE;

    gsl_argc = argc;
    gsl_argv = argv;

    if (gsl_argc <= 1)
      {
        printf ("testscrp [-parallel] <filename> ...\n");
        exit (0);
      }

    smt_init ();                        /*  Initialise SMT kernel            */
    myqueue = queue_create (NULL, 0);
    if (! myqueue)
      {
        fprintf (stderr, "Error creating queue.\n");
        exit (1);
      }

    if (register_script_line_classes ())   /*  Initialise script handler      */
      {
        fprintf (stderr, "Can't start parser agent...\n");
        exit (1);
      }

    argn = 1;
    while (argn < gsl_argc)
      {
        arg = gsl_argv [argn];
        if (streq (arg, "-parallel"))
            parallel = TRUE;
        else
          {
            script_load_file (argv [argn], TRUE, FALSE, &result, myqueue);

            if (! parallel)
                execute_smt ();
          }
        argn++;
      }

    if (parallel)
        execute_smt ();

    shutdown_script_line_classes ();
    queue_destroy (myqueue);
    smt_term ();                        /*  Shut-down SMT kernel             */

    mem_assert ();
    return (EXIT_SUCCESS);
}
コード例 #3
0
ファイル: tstsmtp.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    bin_name = strip_file_path (argv[0]);

    if (argc < 2 || argc > 3)
      {
         display_usage ();
         return -1;
      }

    if (! load_config (argv[1]) )
        return -1;

    if (argc == 3)
      {
        if (!load_body (argv[2]))
          {
            coprintf ("bad body file");
            return -1;
          }
      }

    coprintf (
        "Sending one mail from [%s] to [%s] via [%s]",
        main_sender,
        main_dest,
        main_server
      );

    smt_init ();                   /*  Initialise SMT kernel    */
    /*  Application is latent - initialise it                   */
    if (agent_lookup (SMT_SOCKET) == NULL)
        sock_init ();
    if (agent_lookup (AGENT_NAME) == NULL)
        tstsmtp_init ();

    thread_create (AGENT_NAME, "");

    /*  Application is active - execute it                      */
    smt_exec_full ();              /*  Run until completed      */

    /*  Application is halted - terminate it                    */
    smt_term ();                   /*  Shut-down SMT kernel     */
    sock_term ();

    mem_free (main_server);
    mem_free (main_sender);
    mem_free (main_dest);
    mem_free (main_body);

    printf ("Allocs=%ld frees=%ld\n", mem_allocs (), mem_frees ());
    mem_assert ();

    return (0);
}
コード例 #4
0
ファイル: echod.c プロジェクト: cookrn/openamq
int
main (int argc, char *argv [])
{
    if (argc > 1)                       /*  Use port base if specified       */
        ip_portbase = atoi (argv [1]);

    smt_init ();                        /*  Initialise SMT kernel            */
    smtecho_init ();                    /*  Initialise echo agent            */
    smt_exec_full ();                   /*  Run until completed              */
    smt_term ();                        /*  Shut-down SMT kernel             */

    printf ("Allocs=%ld frees=%ld\n", mem_allocs (), mem_frees ());
    mem_assert ();
    return (0);
}
コード例 #5
0
ファイル: syscli.c プロジェクト: cookrn/openamq
int
main (int argc, char *argv [])
{
    int
        argn;                           /*  Argument number                  */
    Bool
        args_ok = TRUE,                 /*  Were the arguments okay?         */
        quiet_mode = FALSE;             /*  -q means suppress messages       */
    char
        *port,                          /*  Port to connect to               */
        **argparm;                      /*  Argument parameter to pick-up    */
    static char
        command [LINE_MAX];             /*  Command to pass to agent         */

    /*  These are the arguments we may get on the command line               */
    port       = NULL;
    strclr (command);

    argparm = NULL;                     /*  Argument parameter to pick-up    */
    for (argn = 1; argn < argc; argn++)
      {
        /*  If argparm is set, we have to collect an argument parameter      */
        if (argparm)
          {
            if (*argv [argn] != '-')    /*  Parameter can't start with '-'   */
              {
                *argparm = strdupl (argv [argn]);
                argparm = NULL;
              }
            else
              {
                args_ok = FALSE;
                break;
              }
          }
        else
        if (*argv [argn] == '-')
          {
            switch (argv [argn][1])
              {
                /*  These switches take a parameter                          */
                case 'p':
                    argparm = &port; break;

                /*  These switches have an immediate effect                  */
                case 'q':
                    quiet_mode = TRUE;
                    break;
                case 't':
                    smtsock_trace (TRUE);
                    break;
                case 'v':
                    coprintf ("Syscli %s", SYSCLI_VERSION);
                    coprintf (PRODUCT);
                    coprintf (BUILDMODEL);
                    coprintf (COPYRIGHT);
                    coprintf ("Built on: %s", BUILDDATE);
                    exit (EXIT_SUCCESS);
                case 'h':
                    coprintf ("Syscli %s", SYSCLI_VERSION);
                    coprintf (COPYRIGHT);
                    coprintf (USAGE);
                    exit (EXIT_SUCCESS);

                /*  Anything else is an error                                */
                default:
                    args_ok = FALSE;
              }
          }
        else
          {
            strcat (command, " ");
            strcat (command, argv [argn]);
          }
      }

    /*  If there was a missing parameter or an argument error, quit          */
    if (argparm)
      {
        puts ("Argument missing - type 'syscli -h' for help");
        exit (EXIT_FAILURE);
      }
    else
    if (!args_ok)
      {
        puts ("Invalid arguments - type 'syscli -h' for help");
        exit (EXIT_FAILURE);
      }
    
    /*  Handle the remaining arguments we got                                */
    if (!port)
        port = SYSMAN_DEFAULT_PORT;
    if (quiet_mode)
      {
        fclose (stdout);                /*  Kill standard output             */
        fclose (stderr);                /*   and standard error              */
      }
    else
      {
        puts ("Syscli " SYSCLI_VERSION);
        puts (COPYRIGHT);
      }

    smt_init ();                        /*  Initialise SMT kernel            */
    sysclia_init (command, port);       /*  Initialise SYSMAN client agent   */
    smt_exec_full ();                   /*  Run until completed              */
    smt_term ();                        /*  Shut-down SMT kernel             */
    mem_assert ();                      /*  Assert memory is clean           */
    return (0);
}
コード例 #6
0
ファイル: sysman.c プロジェクト: INNOAUS/gsl
int
main (int argc, char *argv [])
{
    int
        argn;                           /*  Argument number                  */
    Bool
        args_ok = TRUE,                 /*  Were the arguments okay?         */
        quiet_mode = FALSE,             /*  -q means suppress messages       */
        background = FALSE;             /*  -s means run in background       */
    char
        *workdir,                       /*  Working directory                */
        *port,                          /*  Value for listen port            */
        **argparm;                      /*  Argument parameter to pick-up    */

    /*  First off, switch to user's id                                       */
    set_uid_user ();

    /*  These are the arguments we may get on the command line               */
    workdir    = NULL;
    port       = NULL;

    argparm = NULL;                     /*  Argument parameter to pick-up    */
    for (argn = 1; argn < argc; argn++)
      {
        /*  If argparm is set, we have to collect an argument parameter      */
        if (argparm)
          {
            if (*argv [argn] != '-')    /*  Parameter can't start with '-'   */
              {
                *argparm = strdupl (argv [argn]);
                argparm = NULL;
              }
            else
              {
                args_ok = FALSE;
                break;
              }
          }
        else
        if (*argv [argn] == '-')
          {
            switch (argv [argn][1])
              {
                /*  These switches take a parameter                          */
                case 'w':
                    argparm = &workdir;  break;
                case 'p':
                    argparm = &port; break;

                /*  These switches have an immediate effect                  */
                case 'q':
                    quiet_mode = TRUE;
                    break;
                case 's':
                    background = TRUE;
                    break;
                case 'S':
                    background = FALSE;
                    break;
                case 't':
                    smtsock_trace (TRUE);
                    break;
                case 'v':
                    coprintf ("Sysman %s", SYSMAN_VERSION);
                    coprintf (PRODUCT);
                    coprintf (BUILDMODEL);
                    coprintf (COPYRIGHT);
                    coprintf ("Built on: %s", BUILDDATE);
                    exit (EXIT_SUCCESS);
                case 'h':
                    coprintf ("Sysman %s", SYSMAN_VERSION);
                    coprintf (COPYRIGHT);
                    coprintf (USAGE);
                    exit (EXIT_SUCCESS);

                /*  Anything else is an error                                */
                default:
                    args_ok = FALSE;
              }
          }
        else
          {
            args_ok = FALSE;
            break;
          }
      }

    /*  If there was a missing parameter or an argument error, quit          */
    if (argparm)
      {
        puts ("Argument missing - type 'sysman -h' for help");
        exit (EXIT_FAILURE);
      }
    else
    if (!args_ok)
      {
        puts ("Invalid arguments - type 'sysman -h' for help");
        exit (EXIT_FAILURE);
      }
      
    /*  Set server working directory if necessary                            */
    if (workdir
    &&  set_curdir (workdir))
      {
        printf ("Can't work in '%s' - %s\n", workdir, strerror (errno));
        exit (EXIT_FAILURE);
      }
    
    /*  Handle the remaining arguments we got                                */
    if (!port)
        port = SYSMAN_DEFAULT_PORT;
    if (quiet_mode)
      {
        fclose (stdout);                /*  Kill standard output             */
        fclose (stderr);                /*   and standard error              */
      }
    else
      {
        puts ("Sysman " SYSMAN_VERSION);
        puts (COPYRIGHT);
      }

    if (background)
      {
        const char
           *background_args [] = { "-s", NULL };

        puts ("Moving into the background");
        if (process_server (NULL, NULL, argc, argv, background_args) != 0)
          {
            puts ("Backgrounding failed.  Giving up.");
            exit (EXIT_FAILURE);
          }
      }

    smt_init ();                        /*  Initialise SMT kernel            */
    if (sysmana_init (port) == 0)       /*  Initialise SYSMAN agent          */
        smt_exec_full ();               /*  Run until completed              */
    else
        printf ("Initialisation error\n");
    smt_term ();                        /*  Shut-down SMT kernel             */

    mem_assert ();

    return (EXIT_SUCCESS);
}
コード例 #7
0
ファイル: xitami.c プロジェクト: imatix/Xitami-25
int
main (int argc, char *argv [])
{
    int
        argn;                           /*  Argument number                  */
    Bool
        args_ok = TRUE,                 /*  Were the arguments okay?         */
        quiet_mode = FALSE;             /*  -q means suppress messages       */
    char
        *workdir,                       /*  Working directory                */
        *rootdir,                       /*  Default root directory           */
        *cgidir,                        /*  CGI program directory            */
        *ftproot,                       /*  Default FTP root directory       */
        *portbase,                      /*  Value for IP portbase            */
        *background,                    /*  -s means run in background       */
        **argparm;                      /*  Argument parameter to pick-up    */

    /*  First off, switch to user's id                                       */
    set_uid_user ();

    /*  These are the arguments we may get on the command line               */
    workdir    = NULL;
    rootdir    = NULL;
    cgidir     = NULL;
    portbase   = NULL;
    background = NULL;
    ftproot    = NULL;

    argparm = NULL;                     /*  Argument parameter to pick-up    */
    for (argn = 1; argn < argc; argn++)
      {
        /*  If argparm is set, we have to collect an argument parameter      */
        if (argparm)
          {
            if (*argv [argn] != '-')    /*  Parameter can't start with '-'   */
              {
                *argparm = strdupl (argv [argn]);
                argparm = NULL;
              }
            else
              {
                args_ok = FALSE;
                break;
              }
          }
        else
        if (*argv [argn] == '-')
          {
            switch (argv [argn][1])
              {
                /*  These switches take a parameter                          */
                case 'w':
                    argparm = &workdir;  break;
                case 'r':
                    argparm = &rootdir;  break;
                case 'c':
                    argparm = &cgidir;   break;
                case 'b':
                    argparm = &portbase; break;
                case 'f':
                    argparm = &ftproot;  break;

                /*  These switches have an immediate effect                  */
                case 'q':
                    quiet_mode = TRUE;
                    break;
                case 's':
                    background = "1";
                    break;
                case 'S':
                    background = "0";
                    break;
                case 't':
                    smtsock_trace (TRUE);
                    break;
                case 'v':
                    coprintf (PRODUCT);
                    coprintf (BUILDMODEL);
                    coprintf (COPYRIGHT);
                    coprintf ("Built on: %s", BUILDDATE);
                    exit (EXIT_SUCCESS);
                case 'h':
                    coprintf (SERVER_NAME);
                    coprintf (COPYRIGHT);
                    coprintf (USAGE);
                    exit (EXIT_SUCCESS);

                /*  Anything else is an error                                */
                default:
                    args_ok = FALSE;
              }
          }
        else
          {
            args_ok = FALSE;
            break;
          }
      }

    /*  If there was a missing parameter or an argument error, quit          */
    if (argparm)
      {
        puts ("Argument missing - type 'xitami -h' for help");
        exit (EXIT_FAILURE);
      }
    else
    if (!args_ok)
      {
        puts ("Invalid arguments - type 'xitami -h' for help");
        exit (EXIT_FAILURE);
      }
      
    /*  Set server working directory if necessary                            */
    if (workdir
    &&  set_curdir (workdir))
      {
        printf ("Can't work in '%s' - %s\n", workdir, strerror (errno));
        exit (EXIT_FAILURE);
      }

    /*  Load configuration data, if any, into the config_table               */
    config = ini_dyn_load (NULL, "xitami.cfg");
    ini_dyn_load (config, CONFIG ("server:defaults"));

    /*  Initialise arguments, taking defaults from the config_table          */
    if (!rootdir)
        rootdir    = CONFIG ("server:webpages");
    if (!cgidir)
        cgidir     = CONFIG ("server:cgi-bin");
    if (!portbase)
        portbase   = CONFIG ("server:portbase");
    if (!background)
        background = CONFIG ("server:background");
    if (!ftproot)
        ftproot    = CONFIG ("ftp:root");

    /*  Now, handle the remaining arguments we got                           */
    ip_portbase = atoi (portbase);
    if (quiet_mode)
      {
        fclose (stdout);                /*  Kill standard output             */
        fclose (stderr);                /*   and standard error              */
      }
    else
      {
        puts (SERVER_NAME);
        puts (COPYRIGHT);
      }

    if (*background == '1')
      {
        const char
           *background_args [] = { "-s", NULL };

        puts ("Moving into the background");
        if (process_server (NULL, NULL, argc, argv, background_args) != 0)
          {
            puts ("Backgrounding failed.  Giving up.");
            exit (EXIT_FAILURE);
          }
      }

    /*  Initialise the SMT kernel                                            */
    smt_init ();
    server_name = "Xitami";

    /*  Load the agents we want to use                                       */
    if (*CONFIG ("lrwp:enabled") == '1')
        xilrwp_init ();                 /*  LRWP service agent               */
    if (*CONFIG ("security:admin") == '1')
        xiadmin_init ();                /*  Administration agent             */
    if (*CONFIG ("server:supervisor") == '1')
        xisuper_init ();                /*  Supervisor agent                 */
    xierror_init ();                    /*  Error-simulation agent           */
    xiredir_init ();                    /*  Redirection agent                */
    xiddns_init ();                     /*  Dynamic DNS registration         */
    xiimap_init ();                     /*  Image mapping agent              */
    xixlog_init ();                     /*  Extended logging agent           */
    xixssi_init ();                     /*  Internal SSI processor           */
    xixxml_init ();                     /*  Internal XML processor           */
    smthttp_init (rootdir, cgidir);     /*  HTTP agent, required             */
    smtftpc_init (ftproot);             /*  FTP service agent                */
    smtpipe_init (CONFIG ("server:pipedef"));  /*  Transfer pipe agent       */

    smt_exec_full ();                   /*  Run SMT until completed          */
    smt_term ();

    /*  Deallocate configuration symbol table                                */
    sym_delete_table (config);

    /*  Check that all memory was cleanly released                           */
    mem_assert ();

    return (EXIT_SUCCESS);
}
コード例 #8
0
ファイル: testconv.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    FILE
        *testfile;                      /*  Read input from driver file      */
    char
        curline [LINE_MAX + 1],
        *token,
        *filter;                        /*  Points to filter or NULL         */
    int
        offset;

    if (argc == 1)
      {
        puts ("Usage: 'testconv filename [filter]' where filename contains");
        puts ("lines following this format\n");
        puts ("! comment");
        puts ("> echo text");
        puts ("@ btos 1/0  YESNO|TRUEFALSE|YN|TF|10 ");
        puts ("@ stob string");
        puts ("@ dtop yyyymmdd picture");
        puts ("@ dtos yyyymmdd YMD|DMY|MDY format flags width");
        puts ("  Format: YMD YMD_ YMD/ YMD, YM YM_ YM/ MD MD_ MD/");
        puts ("  Flags: D=dd-d M=mm-m a=Month c=cent u=upper y m d");
        puts ("@ stod datestr YMD|DMY|MDY format flags");
        puts ("@ ttos hhmmsscc picture");
        puts ("@ stot timestr flags width");
        puts ("  Flags: h=hh-h m=mm-m s=ss-s c=cc-s /=compact p=12-hr");
        puts ("@ ntos +00012345 flags decs ./, decfmt signfmt width");
        puts ("  Flags: -=sign .=dec <=left 0=0pad B=0blank ,=thousands");
        puts ("  Decfmt: 1.10 1.1 1  Signfmt: n- n+ -n +n (n)");
        puts ("@ ston string flags decs ./, decfmt width");
        puts ("\nfilter is @ command, eg. dtos");
        exit (0);
      }
    testfile = file_open (argv [1], 'r');
    if (testfile == NULL)
      {
        printf ("Input file '%s' not found\n", argv [1]);
        exit (1);
      }
    if (argc > 2)
        filter = argv [2];
    else
        filter = NULL;

    while (file_read (testfile, curline))
      {
        switch (*curline)
          {
            case ' ':                   /*  Comment - ignore                 */
            case 0:
            case '!':
                break;

            case '>':                   /*  Echo line to output              */
                puts (curline);
                break;

            case '@':                   /*  Call test function               */
                offset = 1;
                token = get_token (curline, &offset);
                offset++;
                if (streq (token, "btos"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_btos (curline + offset);
                  }
                else
                if (streq (token, "stob"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_stob (curline + offset);
                  }
                else
                if (streq (token, "dtop"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_dtop (curline + offset);
                  }
                else
                if (streq (token, "dtos"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_dtos (curline + offset);
                  }
                else
                if (streq (token, "stod"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_stod (curline + offset);
                  }
                else
                if (streq (token, "ttop"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_ttop (curline + offset);
                  }
                else
                if (streq (token, "ttos"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_ttos (curline + offset);
                  }
                else
                if (streq (token, "stot"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_stot (curline + offset);
                  }
                else
                if (streq (token, "ntos"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_ntos (curline + offset);
                  }
                else
                if (streq (token, "ston"))
                  {
                    if (filter == NULL || streq (filter, token))
                        test_ston (curline + offset);
                  }
                else
                    printf ("Invalid @ action: %s\n", token);
                break;

            default:
                printf ("Invalid line: %s\n", curline);
          }
      }
    file_close (testfile);
    mem_assert ();

    return (EXIT_SUCCESS);
}
コード例 #9
0
ファイル: testpars.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    long
        argn;
    char
       *arg;
    Bool
        parallel = FALSE;
    FILE
       *scriptfile;

    gsl_argc = argc;
    gsl_argv = argv;

    if (gsl_argc <= 1)
      {
        printf ("testpars [-parallel] <filename> ...\n");
        exit (1);
      }

    scriptfiles = mem_alloc (gsl_argc * sizeof (*scriptfiles));

    smt_init ();                        /*  Initialise SMT kernel            */
    myqueue = queue_create (NULL, 0);
    if (! myqueue)
      {
        fprintf (stderr, "Error creating queue.\n");
        exit (1);
      }

    if (ggpars_init ())                 /*  Initialise parser                */
      {
        fprintf (stderr, "Can't start parser agent...\n");
        exit (1);
      }

    argn = 1;
    while (argn < gsl_argc)
      {
        arg = gsl_argv [argn];
        if (streq (arg, "-parallel"))
            parallel = TRUE;
        else
          {
            scriptfile = file_open (arg, 'r');
            if (! scriptfile)
              {
                fprintf (stderr, "Error opening file: %s\n", gsl_argv[1]);
                exit (1);
              }
            scriptfiles [argn] = scriptfile;
            if (gg_parse_template (read_script, (JOBID) argn, myqueue))
              {
                fprintf (stderr, "Can't create parsing thread...\n");
                exit (1);
              }

            if (! parallel)
                execute_smt ();
          }
        argn++;
      }

    if (parallel)
        execute_smt ();

    ggpars_term ();

    queue_destroy (myqueue);
    smt_term ();                        /*  Shut-down SMT kernel             */

    mem_free (scriptfiles);

    mem_assert ();
    return (EXIT_SUCCESS);
}
コード例 #10
0
ファイル: testxmls.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    XML_STORE
        *store;
    int
        index;

    store = xmls_new (XML_DATA);
    xmls_index (store, 3);

    if (store)
      {
        printf ("Testing get value\n");
        printf ("-----------------\n");
        index = 0;
        while (test_value [index].path)
          {
            printf ("%-40.40s => %s\n",
                    test_value [index].path,
                    streq (xmls_get_value (store, test_value [index].path, ""),
                           test_value [index].result)? "OK": "FAIL");
            index++;
          }
        printf ("Testing get item count\n");
        printf ("----------------------\n");
        printf ("count of item_1:           %s\n",
                (xmls_count_item (store, "/main/item_1") == 2)? "OK": "FAIL");
        printf ("count of sub item of main: %s\n",
                (xmls_count_item (store, "/main/*") == 3)? "OK": "FAIL");

        printf ("Testing Save\n");
        printf ("------------\n");
        printf ("Store xml to %s\n", TEST_FILE_NAME);
        xmls_save (store, TEST_FILE_NAME);


        printf ("Testing Set value\n");
        printf ("-----------------\n");
        index = 0;
        while (test_set_value [index].path)
          {
            xmls_set_value (store, test_set_value [index].path,
                                   test_set_value [index].result);
            printf ("%-40.40s => %s\n",
                    test_set_value [index].path,
                    streq (xmls_get_value (store, test_set_value [index].path, ""),
                           test_set_value [index].result)? "OK": "FAIL");
            index++;
          }

        printf ("Testing Add\n");
        printf ("-----------\n");
        index = 0;
        while (test_add_value [index].path)
          {
            xmls_add (store, test_add_value [index].path,
                             test_add_value [index].result);
            printf ("%-40.40s => %s\n",
                    test_add_value [index].path,
                    streq (xmls_get_value (store, test_add_value [index].path, ""),
                           test_add_value [index].result)? "OK": "FAIL");
            index++;
          }

        xmls_save (store, TEST_FILE_NAME);
        
        xmls_free (store);

      }

    mem_assert ();
    return (EXIT_SUCCESS);
}
コード例 #11
0
ファイル: gslgen.c プロジェクト: tempbottle/openamq
MODULE terminate_the_program (void)
{
    mem_assert ();
    the_next_event = terminate_event;
}