static void file_completion(const char *input)

{

    DIR *ffs;

    struct dirent *d;

    char path[1024];

    char file[1024], file_prefix[1024];

    int input_path_len;

    const char *p;



    p = strrchr(input, '/');

    if (!p) {

        input_path_len = 0;

        pstrcpy(file_prefix, sizeof(file_prefix), input);

        pstrcpy(path, sizeof(path), ".");

    } else {

        input_path_len = p - input + 1;

        memcpy(path, input, input_path_len);

        if (input_path_len > sizeof(path) - 1)

            input_path_len = sizeof(path) - 1;

        path[input_path_len] = '\0';

        pstrcpy(file_prefix, sizeof(file_prefix), p + 1);

    }

#ifdef DEBUG_COMPLETION

    monitor_printf(cur_mon, "input='%s' path='%s' prefix='%s'\n",

                   input, path, file_prefix);

#endif

    ffs = opendir(path);

    if (!ffs)

        return;

    for(;;) {

        struct stat sb;

        d = readdir(ffs);

        if (!d)

            break;



        if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) {

            continue;

        }



        if (strstart(d->d_name, file_prefix, NULL)) {

            memcpy(file, input, input_path_len);

            if (input_path_len < sizeof(file))

                pstrcpy(file + input_path_len, sizeof(file) - input_path_len,

                        d->d_name);

            /* stat the file to find out if it's a directory.

             * In that case add a slash to speed up typing long paths

             */

            stat(file, &sb);

            if(S_ISDIR(sb.st_mode))

                pstrcat(file, sizeof(file), "/");

            readline_add_completion(cur_mon->rs, file);

        }

    }

    closedir(ffs);

}

static void file_completion(const char *input)

{

    DIR *ffs;

    struct dirent *d;

    char path[1024];

    char file[1024], file_prefix[1024];

    int input_path_len;

    const char *p;



    p = strrchr(input, '/');

    if (!p) {

        input_path_len = 0;

        pstrcpy(file_prefix, sizeof(file_prefix), input);

        pstrcpy(path, sizeof(path), ".");

    } else {

        input_path_len = p - input + 1;

        memcpy(path, input, input_path_len);

        if (input_path_len > sizeof(path) - 1)

            input_path_len = sizeof(path) - 1;

        path[input_path_len] = '\0';

        pstrcpy(file_prefix, sizeof(file_prefix), p + 1);

    }

#ifdef DEBUG_COMPLETION

    monitor_printf(cur_mon, "input='%s' path='%s' prefix='%s'\n",

                   input, path, file_prefix);

#endif

    ffs = opendir(path);

    if (!ffs)

        return;

    for(;;) {

        struct stat sb;

        d = readdir(ffs);

        if (!d)

            break;



        if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) {

            continue;

        }



        if (strstart(d->d_name, file_prefix, NULL)) {

            memcpy(file, input, input_path_len);

            if (input_path_len < sizeof(file))

                pstrcpy(file + input_path_len, sizeof(file) - input_path_len,

                        d->d_name);

            





            stat(file, &sb);

            if(S_ISDIR(sb.st_mode))

                pstrcat(file, sizeof(file), "/");

            readline_add_completion(cur_mon->rs, file);

        }

    }

    closedir(ffs);

}

            stat(file, &sb);             if(S_ISDIR(sb.st_mode))
static void FUNC_0(const char *VAR_0)

{

    DIR *ffs;

    struct dirent *VAR_1;

    char VAR_2[1024];

    char VAR_3[1024], VAR_4[1024];

    int VAR_5;

    const char *VAR_6;



    VAR_6 = strrchr(VAR_0, '/');

    if (!VAR_6) {

        VAR_5 = 0;

        pstrcpy(VAR_4, sizeof(VAR_4), VAR_0);

        pstrcpy(VAR_2, sizeof(VAR_2), ".");

    } else {

        VAR_5 = VAR_6 - VAR_0 + 1;

        memcpy(VAR_2, VAR_0, VAR_5);

        if (VAR_5 > sizeof(VAR_2) - 1)

            VAR_5 = sizeof(VAR_2) - 1;

        VAR_2[VAR_5] = '\0';

        pstrcpy(VAR_4, sizeof(VAR_4), VAR_6 + 1);

    }

#ifdef DEBUG_COMPLETION

    monitor_printf(cur_mon, "VAR_0='%s' VAR_2='%s' prefix='%s'\n",

                   VAR_0, VAR_2, VAR_4);

#endif

    ffs = opendir(VAR_2);

    if (!ffs)

        return;

    for(;;) {

        struct stat VAR_7;

        VAR_1 = readdir(ffs);

        if (!VAR_1)

            break;



        if (strcmp(VAR_1->d_name, ".") == 0 || strcmp(VAR_1->d_name, "..") == 0) {

            continue;

        }



        if (strstart(VAR_1->d_name, VAR_4, NULL)) {

            memcpy(VAR_3, VAR_0, VAR_5);

            if (VAR_5 < sizeof(VAR_3))

                pstrcpy(VAR_3 + VAR_5, sizeof(VAR_3) - VAR_5,

                        VAR_1->d_name);

            





            stat(VAR_3, &VAR_7);

            if(S_ISDIR(VAR_7.st_mode))

                pstrcat(VAR_3, sizeof(VAR_3), "/");

            readline_add_completion(cur_mon->rs, VAR_3);

        }

    }

    closedir(ffs);

}

static void FUNC_0(const char *VAR_0)
{ DIR *ffs; struct dirent *VAR_1; char VAR_2[1024]; char VAR_3[1024], VAR_4[1024]; int VAR_5; const char *VAR_6; VAR_6 = strrchr(VAR_0, '/'); if (!VAR_6) { VAR_5 = 0; pstrcpy(VAR_4, sizeof(VAR_4), VAR_0); pstrcpy(VAR_2, sizeof(VAR_2), "."); } else { VAR_5 = VAR_6 - VAR_0 + 1; memcpy(VAR_2, VAR_0, VAR_5); if (VAR_5 > sizeof(VAR_2) - 1)
VAR_5 = sizeof(VAR_2) - 1; VAR_2[VAR_5] = '\0'; pstrcpy(VAR_4, sizeof(VAR_4), VAR_6 + 1); } #ifdef DEBUG_COMPLETION
monitor_printf(cur_mon, "VAR_0='%s' VAR_2='%s' prefix='%s'\n",
VAR_0, VAR_2, VAR_4); #endif
ffs = opendir(VAR_2); if (!ffs)
return; for(;;) { struct stat VAR_7; VAR_1 = readdir(ffs); if (!VAR_1)
break; if (strcmp(VAR_1->d_name, ".") == 0 || strcmp(VAR_1->d_name, "..") == 0) { continue; } if (strstart(VAR_1->d_name, VAR_4, NULL)) { memcpy(VAR_3, VAR_0, VAR_5); if (VAR_5 < sizeof(VAR_3))
pstrcpy(VAR_3 + VAR_5, sizeof(VAR_3) - VAR_5,
VAR_1->d_name); stat(VAR_3, &VAR_7); if(S_ISDIR(VAR_7.st_mode))
pstrcat(VAR_3, sizeof(VAR_3), "/"); readline_add_completion(cur_mon->rs, VAR_3); } } closedir(ffs); }