rem: if (strcmp(argv[1],"flash")==0) {
add: l = strlen(argv[1]); if (strncasecmp(argv[1],"flash",l)==0) {
context: int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] ){  char * e;  int i, j;  int len, maxsize;  AVRMEM memtype;  unsigned short addr, daddr;  char * buf;  int rc;  if (argc < 4) {    fprintf(stderr,             "Usage: write flash|eeprom <addr> <byte1> <byte2> ... byteN>\n");    return -1;  }  if (strcmp(argv[1],"flash")==0) {    memtype = AVR_FLASH;    maxsize = p->flash_size;  }  else if (strcmp(argv[1],"eeprom")==0) {    memtype = AVR_EEPROM;    maxsize = p->eeprom_size;  }  else {    fprintf(stderr, "%s (write): invalid memory type \"%s\"\n",            progname, argv[1]);    return -1;  }  addr = strtoul(argv[2], &e, 0);  if (*e || (e == argv[2])) {    fprintf(stderr, "%s (write): can't parse address \"%s\"\n",            progname, argv[2]);    return -1;  }  if (addr > maxsize) {    fprintf(stderr,             "%s (write): address 0x%04x is out of range for %s memory\n",            progname, addr, avr_memtstr(memtype));    return -1;  }  /* number of bytes to write at the specified address */  len = argc - 3;  if ((addr + len) > maxsize) {    fprintf(stderr,             "%s (write): selected address and # bytes exceed "            "range for %s memory\n",             progname, avr_memtstr(memtype));    return -1;  }  buf = malloc(len);  if (buf == NULL) {    fprintf(stderr, "%s (write): out of memory\n", progname);    return -1;  }  for (i=3; i<argc; i++) {    buf[i-3] = strtoul(argv[i], &e, 0);    if (*e || (e == argv[i])) {      fprintf(stderr, "%s (write): can't parse byte \"%s\"\n",              progname, argv[i]);      return -1;    }  }  j     = 0;  daddr = addr;  if (memtype == AVR_FLASH) {    daddr = addr / 2;    if (addr & 0x01) {      /* handle odd numbered memory locations in the flash area */      rc = avr_write_byte(fd, p, AVR_FLASH_HI, daddr, buf[j++]);      if (rc) {        fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",                progname, buf[j-1], daddr*2+1);      }      daddr++;    }  }  i = daddr;  while (j < len) {    if (memtype == AVR_FLASH) {      rc = avr_write_byte( fd, p, AVR_FLASH_LO, i, buf[j++]);      if (rc) {        fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",                progname, buf[j-1], i*2);      }      if (j < len) {        rc = avr_write_byte( fd, p, AVR_FLASH_HI, i, buf[j++]);        if (rc) {          fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",                  progname, buf[j-1], i*2+1);        }      }    }    else {      rc = avr_write_byte( fd, p, AVR_EEPROM, i, buf[j++]);      if (rc) {        fprintf(stderr, "%s (write): error writing 0x%02x at 0x%04x\n",                progname, buf[j-1], i);      }    }    i++;  }  free(buf);  fprintf(stdout, "\n");  return 0;}