コード例 #1
0
ファイル: w32g_c.c プロジェクト: Jberlinsky/LittleBands
static int ctl_load_files_and_play(argc_argv_t *argc_argv, int playflag)
{
    StringTable st;
    int i, n, len;
    char buffer[BUFSIZ];
    char **files;
    int prevnfiles;

    if(argc_argv==NULL)
        return RC_NONE;

    w32g_get_playlist_index(NULL, &prevnfiles, NULL);

    init_string_table(&st);
    n = argc_argv->argc;
    for(i = 0; i < n; i++)
    {
        strcpy(buffer,(argc_argv->argv)[i]);
        if(is_directory(buffer))
            directory_form(buffer);
        len = strlen(buffer);
        put_string_table(&st, buffer, strlen(buffer));
    }
#if 1
    for(i=0; i<argc_argv->argc; i++) {
        free(argc_argv->argv[i]);
    }
    free(argc_argv->argv);
    argc_argv->argv = NULL;
    argc_argv->argc = 0;
#endif
    if((files = make_string_array(&st)) == NULL)
        n = 0;
    else
    {
        n = w32g_add_playlist(n, files, 1,
                              ctl.flags & CTLF_AUTOUNIQ,
                              ctl.flags & CTLF_AUTOREFINE);
        free(files[0]);
        free(files);
    }
    if(n > 0)
    {
        ctl_panel_refresh();
        if(playflag)
        {
            w32g_goto_playlist(prevnfiles, !(ctl.flags & CTLF_NOT_CONTINUE));
            return RC_LOAD_FILE;
        }
    }
    return RC_NONE;
}
コード例 #2
0
ファイル: w32g_c.c プロジェクト: Jberlinsky/LittleBands
static int ctl_drop_file(HDROP hDrop)
{
    StringTable st;
    int i, n, len;
    char buffer[BUFSIZ];
    char **files;
    int prevnfiles;

    w32g_get_playlist_index(NULL, &prevnfiles, NULL);

    init_string_table(&st);
    n = DragQueryFile(hDrop,0xffffffffL, NULL, 0);
    for(i = 0; i < n; i++)
    {
        DragQueryFile(hDrop, i, buffer, sizeof(buffer));
        if(is_directory(buffer))
            directory_form(buffer);
        len = strlen(buffer);
        put_string_table(&st, buffer, strlen(buffer));
    }
    DragFinish(hDrop);

    if((files = make_string_array(&st)) == NULL)
        n = 0;
    else
    {
        n = w32g_add_playlist(n, files, 1,
                              ctl.flags & CTLF_AUTOUNIQ,
                              ctl.flags & CTLF_AUTOREFINE);
        free(files[0]);
        free(files);
    }
    if(n > 0)
    {
        ctl_panel_refresh();
        if(ctl.flags & CTLF_DRAG_START)
        {
            w32g_goto_playlist(prevnfiles, !(ctl.flags & CTLF_NOT_CONTINUE));
            return RC_LOAD_FILE;
        }
    }
    return RC_NONE;
}
コード例 #3
0
ファイル: handler.c プロジェクト: Ponty-/Past_Projects
/** print_map(char** map, int rows, int cols)
**      Takes the map and its dimensions, printing it out with
**      the agent positions.
*/
void print_map(char** map, int rows, int cols) {
    //Make a copy of the map to edit the agent positions in
    char** mapCopy = make_string_array(rows, cols);
    for (int i = 0; i < rows; i++) {
        strncpy(mapCopy[i], map[i], cols);
    }
    //Put the agents on the map
    for(int i = 0; i < numAgents; i++) {
        mapCopy[agents[i].currY-1][agents[i].currX-1] = agents[i].position;
    }
    //Print the map
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < cols; j++) {
            printf("%c", mapCopy[i][j]);
        }
        printf("\n");
    }
    //Print a blank line at the end
    printf("\n");
}
コード例 #4
0
ファイル: w32g_c.c プロジェクト: Jberlinsky/LittleBands
static int ctl_load_file(char *fileptr)
{
    StringTable st;
    int len, n;
    char **files;
    char buffer[BUFSIZ];
    char *basedir;

    init_string_table(&st);
    n = 0;
    basedir = fileptr;
    fileptr += strlen(fileptr) + 1;
    while(*fileptr)
    {
        snprintf(buffer, sizeof(buffer), "%s\\%s", basedir, fileptr);
        if(is_directory(buffer))
            directory_form(buffer);
        len = strlen(buffer);
        put_string_table(&st, buffer, len);
        n++;
        fileptr += strlen(fileptr) + 1;
    }

    if(n == 0)
    {
        put_string_table(&st, basedir, strlen(basedir));
        n++;
    }

    files = make_string_array(&st);
    n = w32g_add_playlist(n, files, 1,
                          ctl.flags & CTLF_AUTOUNIQ,
                          ctl.flags & CTLF_AUTOREFINE);
    free(files[0]);
    free(files);

    if(n > 0)
        ctl_panel_refresh();
    w32g_lock_open_file = 0;
    return RC_NONE;
}
コード例 #5
0
SLsearch_Type *SLsearch_new (SLuchar_Type *key, int flags)
{
   SLsearch_Type *st, *bf_st;
   SLuchar_Type *key_upper, *key_lower, *non_ascii;
   size_t len, upper_len, lower_len;

   if (Case_Tables_Ok == 0)
     SLang_init_case_tables ();

   if (key == NULL)
     return NULL;

   if ((0 == (flags & SLSEARCH_CASELESS))
       || (0 == (flags & SLSEARCH_UTF8)))
     return bm_open_search (key, flags);

   /* Otherwise the key is UTF-8 and the search is case-insensitive */
   len = strlen ((char *)key);
   key_upper = SLutf8_strup (key, key + len);
   if (key_upper == NULL)
     return NULL;

   upper_len = strlen ((char *)key_upper);

   if (is_bm_ok (key_upper, upper_len, &non_ascii))
     {
        st = bm_open_search (key_upper, flags);
        SLang_free_slstring ((char *)key_upper);
        return st;
     }

   /* Tricky part */

   if (NULL == (key_lower = SLutf8_strlo (key, key + len)))
     {
        SLang_free_slstring ((char *)key_upper);
        return NULL;
     }

   lower_len = strlen ((char *)key_lower);

   /* Try a case-less search */
   if ((lower_len == upper_len)
       && (0 == strcmp ((char *)key_upper, (char *)key_lower)))
     {
        flags &= ~SLSEARCH_CASELESS;
        st = bm_open_search (key_upper, flags);
        SLang_free_slstring ((char *)key_upper);
        SLang_free_slstring ((char *)key_lower);
        return st;
     }

   /* Now Perform a brute-force search. */

   /* If the first few characters of the search string are ascii, then
    * use BM for that portion
    */
   bf_st = NULL;
   if (non_ascii - key_upper >= 3)
     {
        SLuchar_Type *key1 = (SLuchar_Type *) SLmake_nstring ((char *)key_upper, non_ascii - key_upper);

        /* ok to propagate NULL below */
        bf_st = SLsearch_new (key1, flags);
        SLfree ((char *)key1);
        if (bf_st == NULL)
          {
             SLang_free_slstring ((char *)key_upper);
             SLang_free_slstring ((char *)key_lower);
             return NULL;
          }

        key1 = (SLuchar_Type *) SLang_create_slstring ((char *)non_ascii);
        non_ascii = key_lower + (non_ascii - key_upper);
        SLang_free_slstring ((char *)key_upper);
        key_upper = key1;

        key1 = (SLuchar_Type *)SLang_create_slstring ((char *)non_ascii);
        SLang_free_slstring ((char *)key_lower);
        key_lower = key1;

        if ((key_lower == NULL) || (key_upper == NULL))
          {
             SLang_free_slstring ((char *)key_upper);
             SLang_free_slstring ((char *)key_lower);
             SLsearch_delete (bf_st);
             return NULL;
          }
        upper_len = strlen ((char *)key_upper);
        lower_len = strlen ((char *)key_lower);
     }

   st = (SLsearch_Type *)SLcalloc (sizeof (SLsearch_Type), 1);
   if (st == NULL)
     goto return_error;
   st->free_fun = bf_free;
   st->flags = flags;
   st->search_fun = bf_search;

   st->s.bf.st = bf_st;  bf_st = NULL;

   if (NULL == (st->s.bf.lower_chars = make_string_array (key_lower, lower_len, &st->s.bf.nlower_chars)))
     goto return_error;

   if (NULL == (st->s.bf.upper_chars = make_string_array (key_upper, upper_len, &st->s.bf.nupper_chars)))
     goto return_error;

   SLang_free_slstring ((char *)key_upper);
   SLang_free_slstring ((char *)key_lower);
   return st;

   return_error:
   SLsearch_delete (st);
   SLsearch_delete (bf_st);
   SLang_free_slstring ((char *)key_upper);
   SLang_free_slstring ((char *)key_lower);
   return NULL;
}