Exemplo n.º 1
0
void
complete_colorschemes(const char *name)
{
	char colors_dir[PATH_MAX];
	DIR *dir;
	struct dirent *d;
	size_t len;

	snprintf(colors_dir, sizeof(colors_dir), "%s/colors", cfg.config_dir);

	dir = opendir(colors_dir);
	if(dir == NULL)
		return;

	len = strlen(name);

	while((d = readdir(dir)) != NULL)
	{
#ifndef _WIN32
		if(d->d_type != DT_REG && d->d_type != DT_LNK)
			continue;
#endif

		if(d->d_name[0] == '.')
			continue;

		if(strncmp(name, d->d_name, len) == 0)
			add_completion(d->d_name);
	}
	closedir(dir);

	completion_group_end();
	add_completion(name);
}
Exemplo n.º 2
0
void
complete_variables(const char *cmd, const char **start)
{
	int i;
	size_t len;
	assert(initialized);

	/* currently we support only environment variables */
	if(*cmd != '$')
	{
		*start = cmd;
		add_completion(cmd);
		return;
	}
	cmd++;
	*start = cmd;

	/* add all variables that start with given beginning */
	len = strlen(cmd);
	for(i = 0; i < nvars; i++)
	{
		if(vars[i].name == NULL)
			continue;
		if(vars[i].removed)
			continue;
		if(strnoscmp(vars[i].name, cmd, len) == 0)
			add_completion(vars[i].name);
	}
	completion_group_end();
	add_completion(cmd);
}
Exemplo n.º 3
0
static void
test_general(void)
{
    char *buf;

    assert_int_equal(0, add_completion("abc"));
    assert_int_equal(0, add_completion("acd"));
    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    buf = next_completion();
    assert_string_equal("abc", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("acd", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("abc", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("acd", buf);
    free(buf);
}
Exemplo n.º 4
0
static void
test_removes_duplicates(void)
{
    char *buf;

    assert_int_equal(0, add_completion("mou"));
    assert_int_equal(0, add_completion("mount"));
    assert_int_equal(0, add_completion("mount"));
    completion_group_end();

    assert_int_equal(0, add_completion("m"));

    buf = next_completion();
    assert_string_equal("mou", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mount", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("m", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mou", buf);
    free(buf);
}
Exemplo n.º 5
0
static void
test_umbiguous_begin(void)
{
    char *buf;

    assert_int_equal(0, add_completion("sort"));
    assert_int_equal(0, add_completion("sortorder"));
    assert_int_equal(0, add_completion("sortnumbers"));
    completion_group_end();

    assert_int_equal(0, add_completion("sort"));

    buf = next_completion();
    assert_string_equal("sort", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sortnumbers", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sortorder", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sort", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sort", buf);
    free(buf);
}
Exemplo n.º 6
0
static void
test_two_matches(void)
{
    char *buf;

    assert_int_equal(0, add_completion("mountpoint"));
    completion_group_end();
    assert_int_equal(0, add_completion("mount"));
    completion_group_end();

    assert_int_equal(0, add_completion("mount"));

    buf = next_completion();
    assert_string_equal("mountpoint", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mount", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mount", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mountpoint", buf);
    free(buf);
}
Exemplo n.º 7
0
static void
test_rewind_one_unambiguous_completion(void)
{
    char *buf;

    assert_int_equal(0, add_completion("abcd"));
    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    buf = next_completion();
    assert_string_equal("abcd", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("abcd", buf);
    free(buf);

    rewind_completion();

    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("abcd", buf);
    free(buf);
}
Exemplo n.º 8
0
static void
test_order(void)
{
    char *buf;

    assert_int_equal(0, add_completion("aa"));
    assert_int_equal(0, add_completion("az"));
    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    set_completion_order(1);

    buf = next_completion();
    assert_string_equal("az", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("aa", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
}
Exemplo n.º 9
0
static int
complete_args(int id, const char *args, int argc, char **argv, int arg_pos)
{
	const char *arg;

	reset_completion();
	add_completion("followlinks");
	add_completion("fastrun");
	completion_group_end();
	add_completion("f");

	arg = strrchr(args, ' ');
	if(arg == NULL)
		arg = args;
	else
		arg++;
	return arg - args;
}
Exemplo n.º 10
0
Arquivo: env.c Projeto: nellynette/dex
void collect_builtin_env(const char *prefix, int len)
{
	int i;

	for (i = 0; i < ARRAY_COUNT(builtin); i++) {
		if (!strncmp(builtin[i].name, prefix, len))
			add_completion(xstrdup(builtin[i].name));
	}
}
Exemplo n.º 11
0
Arquivo: tag.c Projeto: nellynette/dex
void collect_tags(const char *prefix)
{
	struct tag t;
	size_t pos = 0;
	char *prev = NULL;

	if (!load_tag_file())
		return;

	while (next_tag(tag_file, &pos, prefix, 0, &t)) {
		if (!prev || strcmp(prev, t.name)) {
			add_completion(t.name);
			prev = t.name;
			t.name = NULL;
		}
		free_tag(&t);
	}
}
Exemplo n.º 12
0
boolean
get_eg_file_list()
{
  /* On exit, "completion_list" specifies a list of extant files
   *   completion_list->identifier is the local name
   *   completion_list->data is the full path name
   */

  char ch, *cp;
  char localname[FILENAME_LEN], realname[FILENAME_LEN];
  size_t cmdp;

  /* Collect the library name */
  for (cmdp = nodebot + 2, cp = lib; (ch = info_file[cmdp]) != '\n'; cmdp++)
    *cp++ = ch;
  if (cp != lib) *cp = '\0';

  free_completion_list();

  /* collect the information about extant files */
  for (cmdp++; info_file[cmdp] != info_separator_char; cmdp++) {
    for (cp = localname;
	 ((ch = info_file[cmdp]) != '\n') && (ch != TAB) && (ch != SPACE);
	 cmdp++)
      *cp++ = ch;
    *cp = '\0';
    for ( ; info_file[cmdp] != '\n'; cmdp++ )
      ;

    /* If filename starts with a '/', filename must exist. */
    /* If lib starts with a '/', lib/filename must exist. */
    /* Otherwise, libname/lib/filename must exist. */
    if (FILE_EXISTS(localname)) strcpy(realname, localname);
    else if ((lib[0] == '/') || (libname == NULL) || (libname[0] == '\0'))
      (void)sprintf( realname, "%s/%s", lib, localname );
    else (void)sprintf( realname, "%s/%s/%s", libname, lib, localname );
    /* make sure that the library version exists */
    if (FILE_EXISTS( realname )) add_completion(localname, realname);
  }
  return(completion_list != NULL);
}
Exemplo n.º 13
0
static void
test_one_element_completion(void)
{
    char *buf;

    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
}
Exemplo n.º 14
0
void add_elf_completion()
{
	int n,x;
	char s[255];
#ifdef HAVE_LIBREADLINE
	add_completion("elf",NULL,comp_discardable);
	add_completion("elf::e_ident",NULL,comp_discardable);
	add_completion("elf::e_type",NULL,comp_discardable);
	add_completion("elf::e_machine",NULL,comp_discardable);
	add_completion("elf::e_version",NULL,comp_discardable);
	add_completion("elf::e_entry",NULL,comp_discardable);
	add_completion("elf::e_phoff",NULL,comp_discardable);
	add_completion("elf::e_shoff",NULL,comp_discardable);
	add_completion("elf::e_flags",NULL,comp_discardable);
	add_completion("elf::e_ehsize",NULL,comp_discardable);
	add_completion("elf::e_phentsize",NULL,comp_discardable);
	add_completion("elf::e_phnum",NULL,comp_discardable);
	add_completion("elf::e_shentsize",NULL,comp_discardable);
	add_completion("elf::e_shnum",NULL,comp_discardable);
	add_completion("elf::e_shstrndx",NULL,comp_discardable);
	add_completion("sh",NULL,comp_discardable);
	add_completion("ph",NULL,comp_discardable);
	x=max_ph();
	for(n=0;n<=x;n++)
	{
		sprintf(s,"ph[%d]",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_type",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_offset",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_vaddr",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_paddr",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_filesz",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_memsz",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_flags",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"ph[%d]::p_align",n);
		add_completion(s,NULL,comp_discardable);
	}
	x=max_sh();
	for(n=0;n<=x;n++)
	{
		sprintf(s,"sh[%d]",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_name",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_type",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_flags",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_addr",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_offset",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_size",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_link",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_info",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_addralign",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sh[%d]::sh_entsize",n);
		add_completion(s,NULL,comp_discardable);
	}
#endif
}
Exemplo n.º 15
0
void add_pe_completion()
{
	int n,x;
	char s[255];
#ifdef HAVE_LIBREADLINE
	add_completion("mz",NULL,comp_discardable);
	add_completion("mz::e_magic",NULL,comp_discardable);
	add_completion("mz::e_cblp",NULL,comp_discardable);
	add_completion("mz::e_cp",NULL,comp_discardable);
	add_completion("mz::e_crlc",NULL,comp_discardable);
	add_completion("mz::e_cparhdr",NULL,comp_discardable);
	add_completion("mz::e_minalloc",NULL,comp_discardable);
	add_completion("mz::e_maxalloc",NULL,comp_discardable);
	add_completion("mz::e_ss",NULL,comp_discardable);
	add_completion("mz::e_sp",NULL,comp_discardable);
	add_completion("mz::e_csum",NULL,comp_discardable);
	add_completion("mz::e_ip",NULL,comp_discardable);
	add_completion("mz::e_cs",NULL,comp_discardable);
	add_completion("mz::e_lfarlc",NULL,comp_discardable);
	add_completion("mz::e_ovno",NULL,comp_discardable);
	add_completion("mz::e_res",NULL,comp_discardable);
	add_completion("mz::e_oemid",NULL,comp_discardable);
	add_completion("mz::e_oeminfo",NULL,comp_discardable);
	add_completion("mz::e_res2",NULL,comp_discardable);
	add_completion("mz::e_lfanew",NULL,comp_discardable);
	add_completion("pe",NULL,comp_discardable);
	add_completion("pe::Signature",NULL,comp_discardable);
	add_completion("pe::FileHeader",NULL,comp_discardable);
	add_completion("pe::OptionalHeader",NULL,comp_discardable);
	add_completion("pe::FileHeader::Machine",NULL,comp_discardable);
	add_completion("pe::FileHeader::NumberOfSections",NULL,comp_discardable);
	add_completion("pe::FileHeader::TimeDateStamp",NULL,comp_discardable);
	add_completion("pe::FileHeader::PointerToSymbolTable",NULL,comp_discardable);
	add_completion("pe::FileHeader::NumberOfSymbols",NULL,comp_discardable);
	add_completion("pe::FileHeader::SizeOfOptionalHeader",NULL,comp_discardable);
	add_completion("pe::FileHeader::Characteristics",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::Magic",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MajorLinkerVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MinorLinkerVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfCode",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfInitializedData",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfUninitializedData",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::AddressOfEntryPoint",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::BaseOfCode",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::BaseOfData",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::ImageBase",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SectionAlignment",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::FileAlignment",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MajorOperatingSystemVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MinorOperatingSystemVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MajorImageVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MinorImageVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MajorSubsystemVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::MinorSubsystemVersion",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::Reserved1",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfImage",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfHeaders",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::CheckSum",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::Subsystem",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::DllCharacteristics",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfStackReserve",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfStackCommit",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfHeapReserve",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::SizeOfHeapCommit",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::LoaderFlags",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::NumberOfRvaAndSizes",NULL,comp_discardable);
	add_completion("pe::OptionalHeader::Win32VersionValue",NULL,comp_discardable);
	add_completion("sect",NULL,comp_discardable);
	x=get_max_pesect();
	for(n=0;n<=x;n++)
	{
		sprintf(s,"sect[%d]",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::Name",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::PhysicalAddress",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::VirtualAddress",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::SizeOfRawData",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::PointerToRawData",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::PointerToRelocations",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::PointerToLinenumbers",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::NumberOfRelocations",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::NumberOfLinenumbers",n);
		add_completion(s,NULL,comp_discardable);
		sprintf(s,"sect[%d]::Characteristics",n);
		add_completion(s,NULL,comp_discardable);
	}
#endif
}
Exemplo n.º 16
0
/*
 *----------
 * main proc
 *----------
 */
static int file_parse(int fd, PGconn *conn, const char *abs_path)
{
    int ret = 0;
    int size = 0;
    int wlen = 0;

	char *buf  	= (char*)NULL;
	char *realcmd = (char *)NULL;
    char *rdlinecmd = (char *)NULL;

#define TM_LEN 25
    //char timebf[TM_LEN];
    char *timebf = NULL;

    //struct timeval stamp;
    struct rpldsk_packet packet;
    struct timeval stamp;
    enum CMD_STATUS cmd_s = CMD_UNKNOWN;

    if ((timebf = malloc(TM_LEN)) == NULL) {
        fprintf(stderr, "malloc failed.\n");
        return -1;
    } 
    memset(timebf, 0, TM_LEN);

    while ((ret = read(fd, &packet, 
        sizeof(struct rpldsk_packet))) == sizeof(struct rpldsk_packet))
    {
        //dbg("<-packet->\nsize: %x\nevent: %x\nmagic: %x\n", packet.size, packet.event, packet.magic);
        if (packet.magic != MAGIC_SIG) {
            fprintf(stderr, "\n<Packet inconsistency>\n");
            return -1;
        }

        size = packet.size;
        if (size <= 0) {
            fprintf(stderr, ("\n" "<Packet inconsistency>"
                            ": bad size" "\n"));
            return -1;
        }

        switch (packet.event) {
            case EVT_WRITE:
                dbg("case EVT_WRITE\n");
            
                /* read packet.size and store in outbuf */
                if ((buf = malloc(size+1)) == NULL) {
                    fprintf(stderr, "malloc error\n");
                    close(fd);
                    return -1;
                }
                
                read(fd, buf, size); 
                buf[size] = '\0';

#ifdef WALK_LOG
                dbg("\n[TTY_OUT]\n............\n%s\n............\n\n", buf);
                //break;
#endif

                last_outlen = strlen(buf); // size-1 : remove '\0' in packet.data

                if (s_cmd == CMD_BEGIN) { 
                    outlen += last_outlen;
                } else {
                    outlen = last_outlen+1;
                    outbuf[0] = '\0';
                }

                if (outlen >= OUT_BFMAX) {
                    fprintf(stderr, "BUG: OUT_BFMAX to small\n");
                    exit(1);
                }
               
                strncat(outbuf, buf, size);
                outbuf[outlen-1] = '\0';

                free(buf);
                buf = (char *)NULL;

                break;

            case EVT_READ:
                dbg("case EVT_RD: start\n");
                if (PS == NULL) {
                    if (outbuf[0] == '\0') {
                        fprintf(stderr, "BUG: No PS but outbuf is null.\n");
                        //lseek(fd, size, SEEK_CUR);
                        //break;
                    }
                }

                char *tmp = find_ps(outbuf);
                if (tmp && *tmp) {
                    //update_ps
                    if (PS != NULL) {
                        free(PS);
                        PS = NULL;
                    }
                    PS = tmp;
                    dbg("\nps found\n--\n%s\n--\n", PS);
                    clear_inbuf();

                    stamp = packet.time;
                    s_cmd = CMD_BEGIN;
                    dbg("\nCMD_BEGIN...\n");
                }

                if (s_cmd != CMD_BEGIN) {
                    lseek(fd, size, SEEK_CUR);

                    clear_inbuf();
                    clear_outbuf();
                    break;
                }

                //add_completion if last_inbuf is 'tab'
                buf = last_ttyio(inbuf, last_inlen);
                dbg("\n\n-inbuf-\n%s\n-lastin(%d)-\n%s\n-outbuf-\n%s\n\n", inbuf, last_inlen, buf, outbuf);
                if (is_last_tab(buf) == 0) {
                    str_rm_char(outbuf, CHR_BELL);    
                    add_completion(inbuf, outbuf);
                    dbg("**inbuf-updated:%s\n", inbuf);
                }

                myfree((void *)&buf);
                clear_outbuf();

                //read new tty_in
                if ((buf = malloc(size+1)) == NULL) {
                    fprintf(stderr, "malloc error\n");
                    close(fd);
                    return -1;
                }
                
                read(fd, buf, size); 
                buf[size] = '\0';

#ifdef WALK_LOG
                dbg("\n[TTY_IN]\n............\n%s\n............\n\n", buf);
                //break;
#endif

                last_inlen = strlen(buf); // size-1 : remove '\0' in packet.data

                inlen += last_inlen;
                if (inlen >= OUT_BFMAX) {
                    fprintf(stderr, "BUG: OUT_BFMAX to small\n");
                    exit(1);
                }

                strncat(inbuf, buf, size);
                inbuf[inlen-1] = '\0';

                if (is_cmdend(inbuf) == 0) {
                    dbg("\n...CMD_END.\n");
                    //get rdlinecmd from rd-pkt.data
                    getcmd(inbuf, &rdlinecmd, rl_name);

                    format_time(&timebf, &(stamp.tv_sec));
                    dbg("\n\nrdlinecmd(%s)\n-inbuf-\n%s\n--\n\n", rdlinecmd, inbuf);

                    //output dumped log
                    logdump(timebf, PS, rdlinecmd, abs_path, User);
                    //fprintf(stdout, "[%s]%s%s\n", timebf, PS, rdlinecmd);

                    if (rdlinecmd && *rdlinecmd)
                    {
                        if (!(PS[0] == '>'))
                            add_history(rdlinecmd);
                    }

                    free(rdlinecmd);
                    rdlinecmd = NULL;

                    clear_inbuf();
                    s_cmd = CMD_END;
                }

                free(buf);
                buf = (char *)NULL;


                //get rdlinecmd from rd-pkt.data
                //parse_rd_pkt(fd, &rdlinecmd, &packet, rl_name, &timebf); 
                break;

            case EVT_ID_USER:
                if ((User = malloc(size)) == NULL) {
                    fprintf(stderr, "malloc(User) error.\n");
                    close(fd);
                    exit(1);
                }
                read(fd, User, size); 
                //fprintf(stdout, "User: %s\n", User);
                break;

            case EVT_ID_TIME:
                if ((Time = malloc(size)) == NULL) {
                    fprintf(stderr, "malloc(User) error.\n");
                    close(fd);
                    exit(1);
                } 
                read(fd, Time, size);
                //fprintf(stdout, "Time: %s\n", Time);
                break;

            case EVT_LCLOSE:
                dbg("EVT_LCLOSE\n");
                fflush(stdout);
                clear_inbuf();
                clear_outbuf();
                return 0;

            default:
                dbg("EVT: %x, lseek\n", packet.event);
                lseek(fd, size, SEEK_CUR);
                break;
        }
 
    }
 
    free(timebf);

    return 0;
}