Re: How to use global and user related files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Absolutilly correct your anwser to yourself ;)

(APPNAMEDIR="path1:path2").
> 
> There exist function g_getenv (); But does there exist simple and common
> way to parse PATH variable?

    #include <string.h>
    #include <stddef.h>
   
    gchar *env = PR_GetEnv("ENV_VARIABLE");
 
     ...
     /* as env variable follow a "standart format", like paths
separated by ':' */
     const char delimiters[] = ":";
     char *token, *cp;

     cp = strdupa (env);                /* Make writable copy.  */
     token = strtok (cp, delimiters);      /* token => "words" */
     token = strtok (NULL, delimiters);    /* token => "separated" */
     token = strtok (NULL, delimiters);    /* token => "by" */
     token = strtok (NULL, delimiters);    /* token => "spaces" */
     token = strtok (NULL, delimiters);    /* token => "and" */
     token = strtok (NULL, delimiters);    /* token => "punctuation" */
     token = strtok (NULL, delimiters);    /* token => NULL */

====> or a loop like this 
....
     while (token = strtok (cp, delimiters) != NULL ) {
             /* handle each 'token' as you want */
     };
....

I hope this help, I did something like this some time ago, but you can
try 'man strtok' to more details ..

Best Regards 

-- 
Antonio Gomes
E-mail: antonio.gomes@xxxxxxxxxxx
Embedded Linux Lab - 10LE
INdT - Instituto Nokia de Tecnologia (Manaus/Br)
NOKIA's Technology Institute
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux