/* Dump contents of registers */ void dump_registers(registers* regs) { int i; /* to iterate through general-purpose registers */ if (regs == NULL) { fprintf(stderr, "dump_registers: null pointer!!"); return; } /* Dump general-purpose registers */ fprintf(stdout, "General purpose:\n"); for (i = 0; i < N_REGIS; i++) { if (i < sizeof(reg_names)) { printf("Register %s: ", reg_names[i]); } DUMPINT(stdout, regs->general[i]); } /* Dump various special-purpose registers */ printf("Program counter:\n"); DUMPINT(stdout, regs->prog_counter); printf("Memory address:\n"); DUMPINT(stdout, regs->mem_addr); printf("Memory data:\n"); DUMPINT(stdout, regs->mem_data); printf("Flags:\n"); DUMPINT(stdout, regs->flags); }
static int sendFile(const char* path, const MABtAddr* address, int port, int maxPacketSize) { FILE* file = fopen(path, "rb"); if(!file) { printf("Couldn't open file \"%s\"!\n", path); return -__COUNTER__; } const char* filename = MAX(MAX(path, strrchr(path, '\\')), strrchr(path, '/')); Array<u16> unicode_buf(strlen(filename)); //Big Endian Unicode for(uint i=0; i<unicode_buf.size(); i++) { unicode_buf[i] = filename[i] << 8; } if(fseek(file, 0, SEEK_END)) { printf("Couldn't scan file \"%s\"!\n", filename); return -__COUNTER__; } int file_len = ftell(file); if(fseek(file, 0, SEEK_SET)) { printf("Couldn't scan file \"%s\"!\n", filename); return -__COUNTER__; } Array<char> file_buf(file_len); int res = fread(file_buf, 1, file_len, file); if(res != file_len) { DUMPINT(res); printf("Couldn't read file \"%s\"!\n", filename); return -__COUNTER__; } return sendObject(*address, file_buf, unicode_buf, port, maxPacketSize); }
static int sendFile(const char* path, const MABtAddr* address, int port, int maxPacketSize) { FILE* file = fopen(path, "rb"); if(!file) { printf("Couldn't open file \"%s\"!\n", path); return -__COUNTER__; } const char* filename = MAX(MAX(path, strrchr(path, '\\')), strrchr(path, '/')); Array<u16> unicode_buf(strlen(filename)); //Big Endian Unicode for(uint i=0; i<unicode_buf.size(); i++) { unicode_buf[i] = filename[i] << 8; } if(fseek(file, 0, SEEK_END)) { printf("Couldn't scan file \"%s\"!\n", filename); return -__COUNTER__; } int file_len = ftell(file); if(fseek(file, 0, SEEK_SET)) { printf("Couldn't scan file \"%s\"!\n", filename); return -__COUNTER__; } Array<char> file_buf(file_len); int res = fread(file_buf, 1, file_len, file); if(res != file_len) { DUMPINT(res); printf("Couldn't read file \"%s\"!\n", filename); return -__COUNTER__; } if(port < 0) { printf("OBEX Object Push port not specified, querying remote device...\n"); port = findObexPort(address); if(port < 0) { printf("Query failed (%i). File not sent.\n", port); return port; } else { printf("Port found: %i\n", port); } } return sendObject(*address, file_buf, unicode_buf, port, maxPacketSize); }