int main(int argc, char *argv[]) { dbhead_t *dbh; int rec_num; if (argc < 2) { printf(USAGE); exit(1); } argv++; argc--; if ((dbh = dbf_open(*argv, O_RDWR)) == NULL) { fprintf(stderr, "unable to open database file %s\n", *argv); exit(1); } argv++; argc--; while (argc-- > 0) { rec_num = strtol(*argv++, NULL, 0); if (del_dbf_record(dbh, rec_num) < 0) { if (rec_num > dbh->db_records) { fprintf(stderr, "record %d out of bounds\n", rec_num); continue; } else { fprintf(stderr, "unable to delete record %d\n", rec_num); } } } put_dbf_info(dbh); exit(0); }
static bool HHVM_FUNCTION(dbase_delete_record, int64_t dbase_identifier, int64_t record_number) { open_db_map::iterator it = dbase_find_connection(dbase_identifier); if (it != open_dbases->end()) { dbhead_t* dbh = it->second->dbh; assert(dbh != nullptr); if (record_number > dbh->db_records) { raise_warning("record %" PRId64 " out of bounds", record_number); return false; } if (del_dbf_record(dbh, record_number) < 0) { raise_warning("unable to delete record %" PRId64, record_number); return false; } put_dbf_info(dbh); return true; } else { return false; } }