コード例 #1
0
ファイル: main.c プロジェクト: stas/-junk
void
*do_search(void *thread_id)
{
    int tid;
    int cur_queue = count_dirlist();
    int position = -1;
    tid = *((int *) thread_id);
    printf("Thread %d started with %d dirs in queue...\n", tid, cur_queue);
    while(cur_queue != 0)
    {
        // Catch a lock
        do {
            position = read_dirlist();
        } while (position < 0 && count_dirlist() != 0);

        if(position < 0)
            break;

        char *path = dirlist[position];
        if(path != NULL)
        {
            build_dirlist(path);
            printf("do_search: Thread %d found a new path: %s\n", tid, path);
            find_in_dir(path);
            del_dir(path);
        }
        if(position >= 0)
            pthread_mutex_unlock(&dirlist_acc[position]); 
        cur_queue = count_dirlist();
    }
    printf("do_search: Directory list is empty. Thread %d terminates.\n", tid);
    return NULL;
}
コード例 #2
0
ファイル: filereq.c プロジェクト: trapd00r/uberpaint
int
do_filereq(
        SDL_Surface * screen,
	char * title,
        char * button,
	char * dir_buffer,
	char * file_buffer,
	int buffersize
)
{
    filereq_dialog[0].x = 0;
    filereq_dialog[0].y = 0;
    filereq_dialog[0].d1 = JSUI_FRAME_CENTER;
    filereq_dialog[0].dp = title;

    filereq_dialog[1].d1 = -1;
    filereq_dialog[1].d2 = 0;

    filereq_dialog[4].dp = dir_buffer;
    filereq_dialog[4].d1 = buffersize;
    filereq_dialog[5].dp = file_buffer;
    filereq_dialog[5].d1 = buffersize;

    filereq_dialog[7].dp = button;
    filereq_value = -1;

    build_dirlist( dir_buffer );
    jsui_dialog_run_modal( filereq_dialog );

    while ( jsui_is_running( filereq_dialog ) ) 
    {
	SDL_Delay(10);
	jsui_poll(screen);
    }

    if ( (dir_buffer[0] != '\0')
	&&
         (dir_buffer[strlen(dir_buffer) -1] != '/')
       )
    {
	strcat(dir_buffer, "/");
    }

    return( filereq_value );
}