static int ram_remove(Store *store, const char *filename) { RAMFile *rf = (RAMFile *)h_rem(store->dir.ht, filename, false); if (rf != NULL) { DEREF(rf); rf_close(rf); return true; } else { return false; } }
int main(int argc, char **argv) { int fd, res; unsigned char buf[MSG_MAX_LEN] = { 0 }; fd = rf_open(); if (fd < 0) { printf("Can't find device."); exit(1); } /* 0x02 0x55 0x01 0x00 0x01 */ buf[0] = 0x00; res = send_data(fd, buf, 1, buf, sizeof(buf)); if (res < 0) { printf("send data ERROR.\n"); exit(1); } #ifdef DEBUG debug(buf, res); #endif memset(buf, 0, sizeof(buf)); sleep(1); /* 02 55 05 81 00 10 00 00 94 */ buf[0] = 0x81; buf[1] = 0x00; buf[2] = 0x10; buf[3] = 0x00; buf[4] = 0x00; res = send_data(fd, buf, 5, buf, sizeof(buf)); if (res < 0) { printf("send data ERROR.\n"); exit(1); } #ifdef DEBUG debug(buf, res); #endif rf_close(fd); exit(0); }
void ram_destroy_buffer(OutStream *os) { rf_close(os->file.rf); free(os); }
static void rami_close_i(InStream *is) { RAMFile *rf = is->file.rf; DEREF(rf); rf_close(rf); }
static void ramo_close_i(OutStream *os) { RAMFile *rf = os->file.rf; DEREF(rf); rf_close(rf); }