daemon.c
static int method_delete(sd_bus_message *m, void *userdata,
                         sd_bus_error *ret_error) {
  (void)ret_error;
  (void)userdata;
  int r;
  char *path;

  r = sd_bus_message_read(m, "s", &path);
  if (r < 0) {
    fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r));
    return r;
  }

  sqlite3 *db;
  char *err_msg = 0;

  int rc = sqlite3_open("extensions.db", &db);

  if (rc != SQLITE_OK) {
    fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);

    return 1;
  }

  char *del = "DELETE from Programs where program_path=";
  char *add_sep1 = concat(del, "'");
  char *add_path = concat(add_sep1, path);
  char *delete = concat(add_path, "';");

  rc = sqlite3_exec(db, delete, 0, 0, &err_msg);

  if (rc != SQLITE_OK) {
    fprintf(stderr, "SQL error: %s\n", err_msg);

    sqlite3_free(err_msg);
    sqlite3_close(db);

    return 1;
  }

  sqlite3_close(db);

  return sd_bus_reply_method_return(m, "x", 0);
}
/* Returns 0 if success, other value if failure" */
Returns 0 if success, other value if failure"
Returns 0 if success other value if failure "
static int method_delete(sd_bus_message *m, void *userdata,
                         sd_bus_error *ret_error) {
  (void)ret_error;
  (void)userdata;
  int r;
  char *path;
  r = sd_bus_message_read(m, "s", &path);
  if (r < 0) {
    fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r));
    return r;
  }
  sqlite3 *db;
  char *err_msg = 0;
  int rc = sqlite3_open("extensions.db", &db);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    return 1;
  }
  char *del = "DELETE from Programs where program_path=";
  char *add_sep1 = concat(del, "'");
  char *add_path = concat(add_sep1, path);
  char *delete = concat(add_path, "';");
  rc = sqlite3_exec(db, delete, 0, 0, &err_msg);
  if (rc != SQLITE_OK) {
    fprintf(stderr, "SQL error: %s\n", err_msg);
    sqlite3_free(err_msg);
    sqlite3_close(db);
    return 1;
  }
  sqlite3_close(db);
  return sd_bus_reply_method_return(m, "x", 0);
}
static int method_delete ( sd_bus_message * m , void * userdata , sd_bus_error * ret_error ) { ( void ) ret_error ; ( void ) userdata ; int r ; char * path ; r = sd_bus_message_read ( m , " " , & path ) ; if ( r < 0 ) { fprintf ( stderr , " \n " , strerror ( - r ) ) ; return r ; } sqlite3 * db ; char * err_msg = 0 ; int rc = sqlite3_open ( " " , & db ) ; if ( rc != SQLITE_OK ) { fprintf ( stderr , " \n " , sqlite3_errmsg ( db ) ) ; sqlite3_close ( db ) ; return 1 ; } char * del = " " ; char * add_sep1 = concat ( del , " " ) ; char * add_path = concat ( add_sep1 , path ) ; char * delete = concat ( add_path , " " ) ; rc = sqlite3_exec ( db , delete , 0 , 0 , & err_msg ) ; if ( rc != SQLITE_OK ) { fprintf ( stderr , " \n " , err_msg ) ; sqlite3_free ( err_msg ) ; sqlite3_close ( db ) ; return 1 ; } sqlite3_close ( db ) ; return sd_bus_reply_method_return ( m , " " , 0 ) ; }
Returns 0 if success, other value if failure"
Returns 0 if success other value if failure "