All pastes #613703 Raw Edit

savsender source

public c v1 · immutable
·published 2007-07-11 03:55 UTC
rendered paste body
void recv_eeprom_contents(){  u8 *buffer;  u8 *tmp;  int size, type;  int fd;  /*   * First, determine the EEPROM type.   */  type = cardEepromGetType();  size = cardEepromGetSize();  if ((type < 0) || (size <= 0)) {    iprintf("Error determining EEPROM size!\n");    return;  }  iprintf("Detected EEPROM of type %d, size %d\n", type, size);  buffer = (u8 *)malloc(size);  /*   * Now read the data from the server.   */  fd = connect_to_server();  tmp = buffer;  iprintf("Reading data from server\n");  while (tmp < (buffer + size)) {    int count = recv(fd, tmp, MAX(buffer - tmp, 256), 0);    if (count < 0) {      iprintf("\nError during recv!\n");      closesocket(fd);      free(buffer);      return;    } else if (((buffer - tmp) % 1024) == 0) {      iprintf(".");    }    tmp += count;    swiWaitForVBlank();    swiWaitForVBlank();  }  closesocket(fd);  /*   * Finally, write the data to the EEPROM.   */  cardEepromChipErase();  cardWriteEeprom(0, buffer, size, type);  free(buffer);}