Back to index

indicator-appmenu  12.10.0
Functions
hud-verify-app-info.c File Reference
#include <unistd.h>
#include <glib-object.h>
#include <glib/gstdio.h>
#include "load-app-info.h"
#include "create-db.h"

Go to the source code of this file.

Functions

static void build_db (sqlite3 *db)
int main (int argv, char *argc[])

Function Documentation

static void build_db ( sqlite3 *  db) [static]

Definition at line 29 of file hud-verify-app-info.c.

{
       /* Create the table */
       int exec_status = SQLITE_OK;
       gchar * failstring = NULL;
       exec_status = sqlite3_exec(db,
                                  create_db,
                                  NULL, NULL, &failstring);
       if (exec_status != SQLITE_OK) {
              g_warning("Unable to create table: %s", failstring);
       }

       /* Import data from the system */

       return;
}

Here is the caller graph for this function:

int main ( int  argv,
char *  argc[] 
)

Definition at line 47 of file hud-verify-app-info.c.

{
       gboolean passed = TRUE;

       if (argv != 2) {
              g_printerr("Usage: %s <app-info file path>\n", argc[0]);
              return 1;
       }

       g_type_init();

       gchar * filename = NULL;
       gint tmpfile = g_file_open_tmp("hud-verify-app-info-temp-db-XXXXXX", &filename, NULL);

       if (tmpfile < 0) {
              passed = FALSE;
       } else {

              close(tmpfile);
              /* NOTE: there is a small security bug here in that we're closing the
                 file and reopening it, so the temp isn't really guaranteed to be
                 safe.  But, I don't think we're really worried about security in this
                 utility. */

              sqlite3 * db = NULL;
              int open_status = sqlite3_open(filename, &db); 

              if (open_status != SQLITE_OK) {
                     g_warning("Error opening usage DB: %s", filename);
                     passed = FALSE;
              } else {

                     /* Create the table in the DB */
                     build_db(db);

                     passed = load_app_info(argc[1], db);

                     sqlite3_close(db);
              }
       }

       if (filename != NULL) {
              if (g_getenv("HUD_VERIFY_NO_UNLINK") == NULL) {
                     g_unlink(filename);
              } else {
                     g_print("Temp db '%s' not deleted\n", filename);
              }
              g_free(filename);
       }

       if (passed) {
              return 0;
       } else {
              return 1;
       }
}

Here is the call graph for this function: