Ubuntu Pastebin

Paste from slvn_ at Mon, 29 Feb 2016 18:58:11 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 101    char        app_pkgname[128] = {};
 102    const char *app_id           = NULL;
 103    int         len_app_pkgname  = 0;
 104    int         found            = 0;
 105 
 106    buffer[0] = '\0';
 107 
 108    app_home = getenv("XDG_CONFIG_HOME");
 109 
 111    app_id = getenv("APP_ID");
 112 
 113    if (app_home == NULL || app_id == NULL)
 114    {
 115       return;
 116    }
 117 
 118    // Strip the '_' to get the APP_PKGNAME
 119    strncpy(app_pkgname, app_id, sizeof (app_pkgname) - 1);
 120    len_app_pkgname = strlen(app_pkgname);
 121    for (int i = 0; i < len_app_pkgname; i++)
 122    {
 123       if (app_pkgname[i] == '_')
 124       {
 125          app_pkgname[i] = '\0';
 126          found = 1;
 127          break;
 128       }
 129    }
 130 
 131    if (! found)
 132    {
 133       // Something goes Wrongs :/
 134       ERROR_PRINTF("Error with APP_ID");
 135       return;
 136    }
 137 
 138    // Build the path
 139    snprintf(buffer, len - 1, "%s/%s/", app_home, app_pkgname);
 140       
 141    // Create directory if needed
 142    mkdir(buffer, 0755);
Download as text