svn_error_t * svn_fs_fs__id_parse(const svn_fs_id_t **id_p, char *data, apr_pool_t *pool) { svn_fs_id_t *id = id_parse(data, pool); if (id == NULL) return svn_error_createf(SVN_ERR_FS_MALFORMED_NODEREV_ID, NULL, "Malformed node revision ID string '%s'", data); *id_p = id; return SVN_NO_ERROR; }
int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { #ifndef CFG_NO_FLASH flash_info_t *info; ulong bank; int i, n, sect_first, sect_last; #endif /* CFG_NO_FLASH */ ulong addr_first, addr_last; int p; #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) struct mtd_device *dev; struct part_info *part; u8 dev_type, dev_num, pnum; #endif int rcode = 0; #ifdef CONFIG_HAS_DATAFLASH int status; #endif if (argc < 3) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "off") == 0) { p = 0; } else if (strcmp(argv[1], "on") == 0) { p = 1; } else { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } #ifdef CONFIG_HAS_DATAFLASH if ((strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0)) { addr_first = simple_strtoul(argv[2], NULL, 16); addr_last = simple_strtoul(argv[3], NULL, 16); if (addr_dataflash(addr_first) && addr_dataflash(addr_last)) { status = dataflash_real_protect(p,addr_first,addr_last); if (status < 0){ puts ("Bad DataFlash sector specification\n"); return 1; } printf("%sProtect %d DataFlash Sectors\n", p ? "" : "Un-", status); return 0; } } #endif #ifndef CFG_NO_FLASH if (strcmp(argv[2], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { continue; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); for (i=0; i<info->sector_count; ++i) { #if defined(CFG_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CFG_FLASH_PROTECTION */ } #if defined(CFG_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CFG_FLASH_PROTECTION */ } return rcode; } if ((n = abbrev_spec(argv[2], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf("%sProtect Flash Sectors %d-%d in Bank # %zu\n", p ? "" : "Un-", sect_first, sect_last, (info-flash_info)+1); for (i = sect_first; i <= sect_last; i++) { #if defined(CFG_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CFG_FLASH_PROTECTION */ } #if defined(CFG_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CFG_FLASH_PROTECTION */ return rcode; } #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) /* protect on/off <part-id> */ if ((argc == 3) && (id_parse(argv[2], NULL, &dev_type, &dev_num) == 0)) { mtdparts_init(); if (find_dev_and_part(argv[2], &dev, &pnum, &part) == 0) { if (dev->id->type == MTD_DEV_TYPE_NOR) { bank = dev->id->num; info = &flash_info[bank]; addr_first = part->offset + info->start[0]; addr_last = addr_first + part->size - 1; printf ("%sProtect Flash Parition %s, " "bank %ld, 0x%08lx - 0x%08lx\n", p ? "" : "Un", argv[1], bank, addr_first, addr_last); rcode = flash_sect_protect (p, addr_first, addr_last); return rcode; } printf("cannot %sprotect, not a NOR device\n", p ? "" : "un"); return 1; } } #endif if (argc != 4) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[2], "bank") == 0) { bank = simple_strtoul(argv[3], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return 1; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { puts ("missing or unknown FLASH type\n"); return 1; } for (i=0; i<info->sector_count; ++i) { #if defined(CFG_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CFG_FLASH_PROTECTION */ } #if defined(CFG_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CFG_FLASH_PROTECTION */ return rcode; } if (addr_spec(argv[2], argv[3], &addr_first, &addr_last) < 0){ printf("Bad address format\n"); return 1; } if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } rcode = flash_sect_protect (p, addr_first, addr_last); #endif /* CFG_NO_FLASH */ return rcode; }
int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { #ifndef CFG_NO_FLASH flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) struct mtd_device *dev; struct part_info *part; u8 dev_type, dev_num, pnum; #endif int rcode = 0; if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); } return rcode; } if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf ("Erase Flash Sectors %d-%d in Bank # %zu ", sect_first, sect_last, (info-flash_info)+1); rcode = flash_erase(info, sect_first, sect_last); return rcode; } #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) /* erase <part-id> - erase partition */ if ((argc == 2) && (id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) { mtdparts_init(); if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) { if (dev->id->type == MTD_DEV_TYPE_NOR) { bank = dev->id->num; info = &flash_info[bank]; addr_first = part->offset + info->start[0]; addr_last = addr_first + part->size - 1; printf ("Erase Flash Parition %s, " "bank %ld, 0x%08lx - 0x%08lx ", argv[1], bank, addr_first, addr_last); rcode = flash_sect_erase(addr_first, addr_last); return rcode; } printf("cannot erase, not a NOR device\n"); return 1; } } #endif if (argc != 3) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return 1; } printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); return rcode; } if (addr_spec(argv[1], argv[2], &addr_first, &addr_last) < 0){ printf ("Bad address format\n"); return 1; } if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } rcode = flash_sect_erase(addr_first, addr_last); return rcode; #else return 0; #endif /* CFG_NO_FLASH */ }
void main __P2(int, argc, char **, argv) { struct sockaddr_in laddr, faddr; int len, res, lport, fport; ident_t *id; char *identifier, *opsys, *charset; puts("Welcome to the IDENT server tester, version 1.8\r\n"); printf("(Linked with libident-%s)\r\n\n", id_version); fflush(stdout); len = sizeof(faddr); getpeername(0, (struct sockaddr *)&faddr, &len); len = sizeof(laddr); getsockname(0, (struct sockaddr *)&laddr, &len); printf("Connecting to Ident server at %s...\r\n", inet_ntoa(faddr.sin_addr)); fflush(stdout); #ifdef LOG_LOCAL3 openlog("tidentd", 0, LOG_LOCAL3); #else openlog("tidentd", 0); #endif id = id_open(&laddr.sin_addr, &faddr.sin_addr, NULL); if (!id) { perror("id_open()"); fflush(stderr); syslog(LOG_ERR, "Error: id_open(): host=%s, error=%m", gethost(&faddr.sin_addr)); exit(1); } printf("Querying for lport %d, fport %d....\r\n", (int)ntohs(faddr.sin_port), (int)ntohs(laddr.sin_port)); fflush(stdout); if (id_query(id, ntohs(faddr.sin_port), ntohs(laddr.sin_port), 0) < 0) { perror("id_query()"); fflush(stderr); syslog(LOG_ERR, "Error: id_query(): host=%s, error=%m", gethost(&faddr.sin_addr)); exit(1); } printf("Reading response data...\r\n"); fflush(stdout); res = id_parse(id, NULL, &lport, &fport, &identifier, &opsys, &charset); switch (res) { default: perror("id_parse()"); syslog(LOG_ERR, "Error: id_parse(): host=%s, error=%m", gethost(&faddr.sin_addr)); break; case -2: syslog(LOG_ERR, "Error: id_parse(): host=%s, Parse Error: %s", gethost(&faddr.sin_addr), identifier ? identifier : "<no information available>"); if (identifier) printf("Parse error on reply:\n \"%s\"\n", identifier); else printf("Unidentifiable parse error on reply.\n"); break; case -3: syslog(LOG_ERR, "Error: id_parse(): host=%s, Illegal reply type: %s", gethost(&faddr.sin_addr), identifier); printf("Parse error in reply: Illegal reply type: %s\n", identifier); break; case 0: syslog(LOG_ERR, "Error: id_parse(): host=%s, NotReady", gethost(&faddr.sin_addr)); puts("Not ready. This should not happen...\r"); break; case 2: syslog(LOG_INFO, "Reply: Error: host=%s, error=%s", gethost(&faddr.sin_addr), identifier); printf("Error response is:\r\n"); printf(" Lport........ %d\r\n", lport); printf(" Fport........ %d\r\n", fport); printf(" Error........ %s\r\n", identifier); break; case 1: if (charset) syslog(LOG_INFO, "Reply: Userid: host=%s, opsys=%s, charset=%s, userid=%s", gethost(&faddr.sin_addr), opsys, charset, identifier); else syslog(LOG_INFO, "Reply: Userid: host=%s, opsys=%s, userid=%s", gethost(&faddr.sin_addr), opsys, identifier); printf("Userid response is:\r\n"); printf(" Lport........ %d\r\n", lport); printf(" Fport........ %d\r\n", fport); printf(" Opsys........ %s\r\n", opsys); printf(" Charset...... %s\r\n", charset ? charset : "<not specified>"); printf(" Identifier... %s\r\n", identifier); if (id_query(id, ntohs(faddr.sin_port), ntohs(laddr.sin_port), 0) >= 0) { if (id_parse(id, NULL, &lport, &fport, &identifier, &opsys, &charset) == 1) printf(" Multiquery... Enabled\r\n"); } } fflush(stdout); sleep(1); exit(0); }