Exemple #1
0
void
evfs_token_list_free(Ecore_DList * tokens)
{
   evfs_uri_token *token;

   ecore_dlist_first_goto(tokens);
   while ((token = ecore_dlist_next(tokens)))
     {
        free(token->token_s);
        free(token);
     }
   ecore_dlist_destroy(tokens);
}
static void
help_reader_window_cb_destroy(Ewl_Widget * w, void * ev, void * data)
{
    help_reader_win = NULL;
    ecore_dlist_destroy(HELP_READER_WINDOW(w)->history);
}
Exemple #3
0
Ecore_DList *
evfs_tokenize_uri(char *uri)
{
   Ecore_DList *tokens = ecore_dlist_new();
   Ecore_DList *reserved = ecore_dlist_new();
   Ecore_DList *plugin = ecore_dlist_new();

   char *dup_uri = malloc(strlen(uri) + 2);

   /*dup_uri = realloc(dup_uri, strlen(uri)+2); 
    * strcat(dup_uri," "); */

   char *l_uri = dup_uri;
   int solid_alpha = 0;
   int new_alpha = 0;
   evfs_uri_token *token;
   char *cmp;
   char tmp_tok[255];           /*This need to be longer? */
   int i = 0;
   int j = 1;
   int len = 0;
   char tagged = 0;

   snprintf(dup_uri, strlen(uri) + 1, "%s ", uri);

   ecore_dlist_append(plugin, "smb");    /*Shift these to register when a plugin registers */
   ecore_dlist_append(plugin, "file");
   ecore_dlist_append(plugin, "tar");
   ecore_dlist_append(plugin, "bzip2");
   ecore_dlist_append(plugin, "ftp");
   ecore_dlist_append(plugin, "gzip");
   ecore_dlist_append(plugin, "sftp");
   ecore_dlist_append(plugin, "posix");
   ecore_dlist_append(plugin, "vfolder");
   ecore_dlist_append(plugin, "trash");

   ecore_dlist_append(reserved, "://");
   ecore_dlist_append(reserved, "@");
   ecore_dlist_append(reserved, "/");
   ecore_dlist_append(reserved, ":");
   ecore_dlist_append(reserved, "#");
   ecore_dlist_append(reserved, ";");

   //printf ("Lexing '%s'\n", dup_uri);
   //printf("Strlen(uri): %d\n", strlen(uri));

   while (j <= strlen(dup_uri))
     {
	new_alpha = (isalnum(l_uri[i]) || l_uri[i] == '.');

        len = 0;
	tagged = 0;

        strncpy(tmp_tok, l_uri, 3);
        tmp_tok[3] = '\0';
        //printf("Current token is: '%s'\n", tmp_tok);

        /*Check if it's an operator */
        ecore_dlist_first_goto(reserved);
        while ((cmp = ecore_dlist_next(reserved)))
          {
             if (!strncmp(tmp_tok, cmp, strlen(cmp)))
               {
                  //printf("Found token (operator) %s, added %d to l_uri\n", cmp, strlen(cmp));
                  l_uri += strlen(cmp);
                  len = strlen(cmp);
		  tagged = 1;

                  //printf("L_URI becomes '%s'\n", l_uri);
                  token = NEW(evfs_uri_token);
                  token->token_s = strdup(cmp);
                  token->type = EVFS_URI_TOKEN_OPERATOR;
                  ecore_dlist_append(tokens, token);
                  bzero(tmp_tok, 255);

                  goto cont_loop;
               }
          }

        /*Check if it's a keyword */
        strncpy(tmp_tok, l_uri, i);
        tmp_tok[i] = '\0';
        //printf("Current token (keyword match) is: '%s'\n", tmp_tok);

        ecore_dlist_first_goto(plugin);
        while ((cmp = ecore_dlist_next(plugin)))
          {
             if (!strncmp(tmp_tok, cmp, strlen(cmp)))
               {
                  //printf("Found token (keyword) %s, added %d to l_uri\n", cmp, strlen(cmp));

                  l_uri += strlen(cmp);
		  tagged = 2;

                  token = NEW(evfs_uri_token);
                  token->token_s = strdup(cmp);
                  token->type = EVFS_URI_TOKEN_KEYWORD;
                  ecore_dlist_append(tokens, token);
                  bzero(tmp_tok, 255);

                  goto cont_loop;       /*Eww goto - but we're in two while loops */
               }

          }

        if (solid_alpha && !new_alpha)
          {
             strncpy(tmp_tok, l_uri, i);

             /*There is a lexer position bug for now- this will fix it FIXME */
             if (tmp_tok[0] == '\0')
                goto lexer_done;

             tmp_tok[i] = '\0';

             token = NEW(evfs_uri_token);
             token->token_s = strdup(tmp_tok);
             token->type = EVFS_URI_TOKEN_STRING;
             ecore_dlist_append(tokens, token);
             bzero(tmp_tok, 255);

             l_uri += i;
	     tagged = 3;
          }

        solid_alpha = new_alpha;

      cont_loop:

	if (tagged > 0) {
		if (tagged == 1 || tagged == 2)
			j += strlen(cmp);
		else
			j += i;

		i = 0;
		
     	}
	
        i++;
        //printf("i:J (%d:%d) - %d\n", i,j,strlen(dup_uri));
     }

 lexer_done:

   /*This is really evil - we assume the last token is a string */
   /*There is something wrong with the offsets above if this is
    * the case*/
   if (strlen(tmp_tok) > 0)
     {
	printf("libevfs.c evil - FIXME\n");
        token = NEW(evfs_uri_token);
        token->token_s = strdup(tmp_tok);
        token->type = EVFS_URI_TOKEN_STRING;
        ecore_dlist_append(tokens, token);
     }

   ecore_dlist_destroy(plugin);
   ecore_dlist_destroy(reserved);

   free(dup_uri);
   return tokens;
}