<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glusterfs.git/libglusterfs/src/gfdb/gfdb_data_store.h, branch release-3.3</title>
<subtitle></subtitle>
<link rel='alternate' type='text/html' href='http://git.gluster.org/cgit/glusterfs.git/'/>
</feed>
://www.gluster.com>
  This file is part of GlusterFS.

  GlusterFS is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 3 of the License,
  or (at your option) any later version.

  GlusterFS is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see
  <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>

#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif

#include "cli.h"
#include "cli-cmd.h"
#include "cli-mem-types.h"

#include "event.h"

#include <fnmatch.h>

#ifdef HAVE_READLINE

#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>


int
cli_rl_out (struct cli_state *state, const char *fmt, va_list ap)
{
        int tmp_rl_point = rl_point;
        int            n = rl_end;
        int            i = 0;
        int            ret = 0;

        if (rl_end >= 0 ) {
                rl_kill_text (0, rl_end);
                rl_redisplay ();
        }

        printf ("\r");

        for (i = 0; i <= strlen (state->prompt); i++)
                printf (" ");

        printf ("\r");

        ret = vprintf (fmt, ap);

        printf ("\n");
        fflush(stdout);

        if (n) {
                rl_do_undo ();
                rl_point = tmp_rl_point;
                rl_reset_line_state ();
        }

        return ret;
}


void
cli_rl_process_line (char *line)
{
        struct cli_state *state = NULL;
        int               ret = 0;

        state = global_state;

        state->rl_processing = 1;
        {
                ret = cli_cmd_process_line (state, line);
                if (ret)
                        gf_log (THIS->name, GF_LOG_WARNING,
                                "failed to process line");

                add_history (line);
        }
        state->rl_processing = 0;

}


int
cli_rl_stdin (int fd, int idx, void *data,
              int poll_out, int poll_in, int poll_err)
{
        rl_callback_read_char ();

        return 0;
}


char *
cli_rl_autocomplete_entry (const char *text, int times)
{
        struct cli_state  *state = NULL;
        char              *retp = NULL;

        state = global_state;

        if (!state->matchesp)
                return NULL;

        retp = *state->matchesp;

        state->matchesp++;

        return retp ? strdup (retp) : NULL;
}


int
cli_rl_token_count (const char *text)
{
        int          count = 0;
        const char  *trav = NULL;
        int          is_spc = 1;

        for (trav = text; *trav; trav++) {
                if (*trav == ' ') {
                        is_spc = 1;
                } else {
                        if (is_spc) {
                                count++;
                                is_spc = 0;
                        }
                }
        }

        if (is_spc)
                /* what needs to be autocompleted is a full
                   new word, and not extend the last word
                */
                count++;

        return count;
}


char **
cli_rl_tokenize (const char *text)
{
        int     count = 0;
        char  **tokens = NULL;
        char  **tokenp = NULL;
        char   *token = NULL;
        char   *copy = NULL;
        char   *saveptr = NULL;