QByteArray ElfReader::readCoreName(bool *isCore) { *isCore = false; readIt(); ElfMapper mapper(this); if (!mapper.map()) return QByteArray(); if (m_elfData.elftype != Elf_ET_CORE) return QByteArray(); *isCore = true; for (int i = 0, n = m_elfData.sectionHeaders.size(); i != n; ++i) if (m_elfData.sectionHeaders.at(i).type == Elf_SHT_NOTE) { const ElfSectionHeader &header = m_elfData.sectionHeaders.at(i); return cutout(mapper.start + header.offset + 0x40); } for (int i = 0, n = m_elfData.programHeaders.size(); i != n; ++i) if (m_elfData.programHeaders.at(i).type == Elf_PT_NOTE) { const ElfProgramHeader &header = m_elfData.programHeaders.at(i); return cutout(mapper.start + header.offset + 0xec); } return QByteArray(); }
void main(int argc, char **argv) { int n; extern long nph; int doundef = 0; int dow = 0; char *chname = 0; char *pkname = 0; extern int optind; extern char *optarg; extern Signal *maxsig; while((n = getopt(argc, argv, "uwp:c:")) != -1) switch(n) { case 'u': doundef = 1; break; case 'w': dow = 1; break; case 'c': chname = optarg; break; case 'p': pkname = optarg; break; case '?': break; } fizzinit(); f_init(&b); if(optind == argc) argv[--optind] = "/dev/stdin"; for(; optind < argc; optind++) if(n = f_crack(argv[optind], &b)){ fprint(1, "%s: %d errors\n", argv[optind], n); exit(1); } if(b.name) fprint(1, "Board %s:\n", b.name); else fprint(1, "Warning: no board name\n"); if(n = fizzplace()){ fprint(1, "%d chips unplaced\n", n); if(doundef) symtraverse(S_CHIP, prundef); exit(1); } cutout(&b); fizzplane(&b); if(pkname) prpkg((Package *)symlook(pkname, S_PACKAGE, (void *)0)); if(chname) prchip((Chip *)symlook(chname, S_CHIP, (void *)0)); if(dow){ if(fizzprewrap()) exit(1); symtraverse(S_SIGNAL, netlen); if(maxsig && ((maxsig->type & VSIG) != VSIG) && (maxsig->n >= MAXNET)){ fprint(1, "net %s is too big (%d>=%d)\n", maxsig->name, maxsig->n, MAXNET); exit(1); } setup(); symtraverse(S_CHIP, chkpins); } symtraverse(S_PACKAGE, chkpkgpins); exit(0); }
void main(int argc, char **argv) { int n; extern long nph; int doundef = 0; int dow = 0; int dosignal = 0; float ratio; extern int optind; extern char *optarg; extern Signal *maxsig; while((n = getopt(argc, argv, "lqsuvz:adkw:c:")) != -1) switch(n) { case 'k': konstant = atof(optarg); break; case 'a': width = AWG(atof(optarg)); break; case 'd': epsilon = atof(optarg); break; case 'l': dolength = 1; break; case 'q': quiet = 1; break; case 's': dosignal = 1; break; case 'u': doundef = 1; break; case 'v': dow = 1; break; case 'w': width = atof(optarg); break; case 'z': Z0 = atof(optarg); break; case '?': break; } fizzinit(); f_init(&b); if(optind == argc) argv[--optind] = "/dev/stdin"; for(; optind < argc; optind++) if(n = f_crack(argv[optind], &b)){ fprint(1, "%s: %d errors\n", argv[optind], n); exit(1); } if(b.name) fprint(1, "Board %s:\n", b.name); else fprint(1, "Warning: no board name\n"); if(n = fizzplace()){ fprint(1, "%d chips unplaced\n", n); if(doundef) symtraverse(S_CHIP, prundef); exit(1); } cutout(&b); fizzplane(&b); if (fizzprewrap()) exit(1); if (dow) symtraverse(S_SIGNAL, prwires); symtraverse(S_SIGNAL, calclength); if (dosignal) symtraverse(S_SIGNAL, prsignal); pininit(); symtraverse(S_SIGNAL, insertpins); /* * ratio is 2 * h / d from Shibata & Ryuiti; * L0 is from Terman's classic, but neglects skin effect (in microhenries / ft) */ ratio = exp((Z0 - 17.08) / 34.83); L0 = 0.1404 * log10(2.0 * ratio) * 83.3333; C0 = L0 / square(Z0); fprint(2, "Capacitance=%f, inductance=%f, ns/ft=%f\n", C0, L0, 12.0*sqrt(C0*L0)); symtraverse(S_SIGNAL, cksignal); exit(0); }
void main(int argc, char *argv[]) { if(argc > 1) { FILE *file = 0; FILE *file_w = 0; int opt = 0, start = 0, end = 0; int longIndex = 0, i, flag = 0, amount = 0; opt = getopt_long(argc, argv, optString, longOpts, &longIndex); while(opt != -1) { switch(opt) { case 'h': puts("--file -f Имя вашего файла"); puts("--start -s Начало удаления"); puts("--end -e Конец удаления"); return; case 'f': if (!file) { file = fopen(optarg, "rb+"); file_w = fopen(optarg, "r"); } else { puts("Файл уже используется"); break; } if (!file) { puts("Ошибка файла"); return; } flag += M; break; case 's': if (start != 0) { puts("Данные для начала удаления уже введены"); break; } for (i = 0; i < N; i++) { if (optarg[i] - 48 > 9 || start < 0) { puts("Ошибка ввода данных для начала удаления"); start = 0; break; } if (!optarg[i]) { break; } else { start *= M; } start += optarg[i] - 48; } flag++; break; case 'e': if (end != 0) { puts("Данные для конца удаления уже введены"); break; } for (i = 0; i < N; i++) { if (optarg[i] - 48 > 9 || end < 0) { puts("Ошибка ввода данных для конца удаления"); end = 0; break; } if (!optarg[i]) { break; } else { end *= M; } end += optarg[i] - 48; } flag++; break; } opt = getopt_long(argc, argv, optString, longOpts, &longIndex); } amount = number(file, amount); if (flag == 12) { if (start > end || start == 0 || end == 0 || end > amount) //|| start == end) { puts("Проверьте введенные данные"); printf("В файле %d чисел\n", amount); fclose(file_w); fclose(file); } else { cutout(file, file_w, start, end); ftruncate(fileno(file), (amount - end + start - 1) * 4); fclose(file_w); fclose(file); } } else { puts("Введены не все параметры"); } } else { menu(); } return; }