void write_meta(const osmium::OSMObject& object) { oprintf(m_out, " id=\"%" PRId64 "\"", object.id()); if (object.version()) { oprintf(m_out, " version=\"%d\"", object.version()); } if (object.timestamp()) { m_out += " timestamp=\""; m_out += object.timestamp().to_iso(); m_out += "\""; } if (!object.user_is_anonymous()) { oprintf(m_out, " uid=\"%d\" user=\"", object.uid()); xml_string(m_out, object.user()); m_out += "\""; } if (object.changeset()) { oprintf(m_out, " changeset=\"%d\"", object.changeset()); } if (m_write_visible_flag) { if (object.visible()) { m_out += " visible=\"true\""; } else { m_out += " visible=\"false\""; } } }
void write_header(const osmium::io::Header& header) override final { std::string out = "<?xml version='1.0' encoding='UTF-8'?>\n"; if (m_file.is_true("xml_change_format")) { out += "<osmChange version=\"0.6\" generator=\""; xml_string(out, header.get("generator").c_str()); out += "\">\n"; } else { out += "<osm version=\"0.6\""; std::string xml_josm_upload = header.get("xml_josm_upload"); if (xml_josm_upload == "true" || xml_josm_upload == "false") { out += " upload=\""; out += xml_josm_upload; out += "\""; } out += " generator=\""; xml_string(out, header.get("generator").c_str()); out += "\">\n"; } for (const auto& box : header.boxes()) { out += " <bounds"; oprintf(out, " minlon=\"%.7f\"", box.bottom_left().lon()); oprintf(out, " minlat=\"%.7f\"", box.bottom_left().lat()); oprintf(out, " maxlon=\"%.7f\"", box.top_right().lon()); oprintf(out, " maxlat=\"%.7f\"/>\n", box.top_right().lat()); } std::promise<std::string> promise; m_output_queue.push(promise.get_future()); promise.set_value(std::move(out)); }
/* Rules which just flush the packet filter */ int flush_iptablesrestore(enum filtertype policy) { char *ostr; // FIXME: Should the nat table always have a default ACCEPT policy? oputs("*nat"); oputs(":PREROUTING ACCEPT [0:0]"); oputs(":POSTROUTING ACCEPT [0:0]"); oputs(":OUTPUT ACCEPT [0:0]"); oputs("COMMIT"); // filter table oputs("*filter"); switch (policy) { case T_ACCEPT: ostr = strdup("ACCEPT"); break; case DROP: ostr = strdup("DROP"); break; case T_REJECT: ostr = strdup("REJECT"); break; default: fprintf(stderr, "invalid filtertype %d\n", policy); abort(); } oprintf(":INPUT %s [0:0]\n", ostr); oprintf(":OUTPUT %s [0:0]\n", ostr); oprintf(":FORWARD %s [0:0]\n", ostr); oputs("COMMIT"); return 0; }
int main (void) { oprintf(func,"test"); oprintf(func_many,"test"); oprintf(main,"test"); return 0; }
static void etcsystem_add(void) { const char *mods[20]; int nmods, line; if ((g_ofp = fopen(g_ofile = g_etcfile, "a")) == NULL) fatal("failed to open output file '%s'", g_ofile); oprintf("%s\n", g_etcbegin); for (line = 0; g_etc[line] != NULL; line++) oprintf("%s\n", g_etc[line]); nmods = dtrace_provider_modules(g_dtp, mods, sizeof (mods) / sizeof (char *) - 1); if (nmods >= sizeof (mods) / sizeof (char *)) fatal("unexpectedly large number of modules!"); mods[nmods++] = "dtrace"; for (line = 0; line < nmods; line++) oprintf("forceload: drv/%s\n", mods[line]); oprintf("%s\n", g_etcend); if (fclose(g_ofp) == EOF) fatal("failed to close output file '%s'", g_ofile); error("added forceload directives to %s\n", g_ofile); }
void kernel_c(){ //init basic data&struct heap_init(); proc_init(); init_fs(); mem_entity[0]='G'; mem_entity[1]='M'; mem_entity[2]='K'; mem_entity[3]='B'; k_screen_reset(); detect_cpu(); oprintf("detecting cpu...cpu identify:%s\n",cpu_string); // oprintf("mm init..\nring0_pgdir:%x,ring0_pgtbl:%x,base_proc_pgdir:%x,addr_kernel_info:%x,pages:%x\n",RING0_PGDIR,RING0_PGTBL,BASE_PROC_PGDIR,ADDR_KERNEL_INFO,PAGES); global_equal_map(); __asm__("mov $0x101000,%eax\t\n" "mov %eax,%cr3\t\n" "mov %cr0,%eax\t\n" "or $0x80000000,%eax\t\n" "mov %eax,%cr0\t\n" ); oprintf("global page-mapping for kernel built..open MMU\n"); create_kernel_process((int)&idle,9,0xffff,"idle",0); //pid must =0 create_kernel_process((int)hs,2,0xffff,"hs",1);//hs的时间片要非常多,保证在下一轮时间片重置之前不会被挂起 ERR:pid must =1 create_kernel_process((int)fs_ext,4,10,"fs_ext",1);//pid must =2 create_kernel_process((int)mm,3,10,"mm",1);//ERR mm has great prio,because it shall run and prepare condition for other process create_kernel_process((int)tty,5,10,"tty",1); create_kernel_process((int)&p1,8,10,"p1",1); // ofork(t1,9,15,"t1",1); // ofork(t2,9,5,"t2",1); // ofork((int)&p2,7,5,"p2",3); oprintf("basic process ofork done..now open IRQ,proc-dispatch begin\n"); __asm__("sti"); while(1);//内核陷入死循环,等待第一次时钟中断 }
/* main routine */ int main(int argc, char **argv) { int32_t i, rv; g_progname = argv[0]; srand(time(NULL)); if (argc < 2) usage(); rv = 0; if (!strcmp(argv[1], "order")) { rv = runorder(argc, argv); } else if (!strcmp(argv[1], "index")) { rv = runindex(argc, argv); } else if (!strcmp(argv[1], "map")) { rv = runmap(argc, argv); } else if (!strcmp(argv[1], "list")) { rv = runlist(argc, argv); } else { usage(); } if (rv != 0) { oprintf("FAILED:"); for (i = 0; i < argc; i++) { oprintf(" %s", argv[i]); } oprintf("\n\n"); } return rv; }
static void print_bboard(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_bboard_t b; int chdl_cnt; (void) smbios_info_bboard(shp, id, &b); oprintf(fp, " Chassis: %u\n", (uint_t)b.smbb_chassis); flag_printf(fp, "Flags", b.smbb_flags, sizeof (b.smbb_flags) * NBBY, smbios_bboard_flag_name, smbios_bboard_flag_desc); desc_printf(smbios_bboard_type_desc(b.smbb_type), fp, " Board Type: 0x%x", b.smbb_type); chdl_cnt = b.smbb_contn; if (chdl_cnt != 0) { id_t *chdl; uint16_t hdl; int i, n, cnt; chdl = alloca(chdl_cnt * sizeof (id_t)); cnt = smbios_info_contains(shp, id, chdl_cnt, chdl); if (cnt > SMB_CONT_MAX) return; n = MIN(chdl_cnt, cnt); oprintf(fp, "\n"); for (i = 0; i < n; i++) { hdl = (uint16_t)chdl[i]; oprintf(fp, " Contained Handle: %u\n", hdl); } } }
static void disk(void){ oprintf("%10s%10s%8s%8s%10s%10s\n","device","boot","start","count","sys_id","sys_string"); int gmkb_start_lba[4]; int gmkb_size[4]; for(int i=1;i<MAX_PARTATION;i++){ DP*dp=g_dp[1]+i; if(dp->start_lba==0) continue;//empty dp int c=dp->count/2;//x kb int s=dp->start_lba/2;//s kb /** int x_scale_count=0; int s_scale_count=0; while(x>=1024){ x/=1024; x_scale_count++; } while(s>=1024){ s/=1024; s_scale_count++; } */ human_memsize_into(gmkb_start_lba,s,1); human_memsize_into(gmkb_size,c,1); int max0=0; int max1=0; while(gmkb_start_lba[max0]==0) max0++; while(gmkb_size[max1]==0) max1++; // oprintf("max0:%u,max1:%u\n",max0,max1); oprintf("%10u%10u%4u%4c%4u%4c%10u%10s\n",i,dp->boot,gmkb_start_lba[max0],mem_entity[max0],gmkb_size[max1],mem_entity[max1],dp->sys_id,sys_string[dp->sys_id]); } }
static int cb_iptablesrestore_group(const char *name) { oprintf("-N %s-INPUT\n", name); oprintf("-N %s-OUTPUT\n", name); oprintf("-N %s-FORWARD\n", name); oprintf("-N %s-FORW_OUT\n", name); return 4; }
int set_bootloader_to_winusb(int verbose) { int opt_silent = verbose; struct wdi_device_info *device, list; char* inf_name = NULL; int r; struct wdi_options_prepare_driver driver_opts = {0}; driver_opts.driver_type = WDI_WINUSB; driver_opts.vendor_name = NULL; driver_opts.device_guid = NULL; driver_opts.disable_cat = FALSE; driver_opts.disable_signing = FALSE; driver_opts.use_wcid_driver = FALSE; list = listDevices(verbose); if (&list != NULL) { oprintf("set_bootloader_to_winusb - valid list\n"); for (device = &list; device != NULL; device = device->next) { if ((device->vid == BOOTLOADER_VID) && (device->pid == BOOTLOADER_PID)) { oprintf("Installing using inf name: %s\n", INF_NAME); if ((wdi_prepare_driver(device, DEFAULT_DIR, INF_NAME, &driver_opts) == WDI_SUCCESS) & (device->driver != "WINUSB")) { oprintf("Prepared driver for install\n"); r=wdi_install_driver(device, DEFAULT_DIR, INF_NAME, NULL); oprintf("got return code: %d=%s \n", r,wdi_strerror(r)); } } } } return r; }
/*ARGSUSED*/ static int chew(const dtrace_probedata_t *data, void *arg) { dtrace_probedesc_t *pd = data->dtpda_pdesc; processorid_t cpu = data->dtpda_cpu; static int heading; if (g_impatient) { g_newline = 0; return (DTRACE_CONSUME_ABORT); } if (heading == 0) { if (!g_flowindent) { if (!g_quiet) { oprintf("%3s %6s %32s\n", "CPU", "ID", "FUNCTION:NAME"); } } else { oprintf("%3s %-41s\n", "CPU", "FUNCTION"); } heading = 1; } if (!g_flowindent) { if (!g_quiet) { char name[DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 2]; (void) snprintf(name, sizeof (name), "%s:%s", pd->dtpd_func, pd->dtpd_name); oprintf("%3d %6d %32s ", cpu, pd->dtpd_id, name); } } else { int indent = data->dtpda_indent; char *name; size_t len; if (data->dtpda_flow == DTRACEFLOW_NONE) { len = indent + DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 5; name = alloca(len); (void) snprintf(name, len, "%*s%s%s:%s", indent, "", data->dtpda_prefix, pd->dtpd_func, pd->dtpd_name); } else { len = indent + DTRACE_FUNCNAMELEN + 5; name = alloca(len); (void) snprintf(name, len, "%*s%s%s", indent, "", data->dtpda_prefix, pd->dtpd_func); } oprintf("%3d %-41s ", cpu, name); } return (DTRACE_CONSUME_THIS); }
char * SWFShape_dumpOutline(SWFShape s) { struct out o; int i; int x = 0, y = 0; o.len = 0; o.ptr = o.buf = (char *)malloc(1); *o.ptr = 0; for (i = 0; i < s->nRecords; i++) { ShapeRecord *record = s->records + i; switch(record->type) { case SHAPERECORD_STATECHANGE: { if(!record->record.stateChange->flags & SWF_SHAPE_MOVETOFLAG) continue; x = record->record.stateChange->moveToX; y = record->record.stateChange->moveToY; oprintf(&o, "moveto %d,%d\n", x, y); break; } case SHAPERECORD_LINETO: { x += record->record.lineTo->dx; y += record->record.lineTo->dy; oprintf(&o, "lineto %d,%d\n", x, y); break; } case SHAPERECORD_CURVETO: { int controlX = record->record.curveTo->controlx; int controlY = record->record.curveTo->controly; int anchorX = record->record.curveTo->anchorx; int anchorY = record->record.curveTo->anchory; oprintf(&o, "curveto %d,%d %d,%d\n", x+controlX, y+controlY, x+controlX+anchorX, y+controlY+anchorY); x += controlX + anchorX; y += controlY + anchorY; break; } default: break; } } *o.ptr = 0; return o.buf; }
static void PrintTemps(BITINT *modifiedBy) { int i; if (modifiedBy) { oprintf(icdFile, "["); for (i=1; i < cachedTempCount; i+=2) if (isset(modifiedBy, i)) oprintf(icdFile, "T%d ", i/2); oprintf(icdFile, "]"); } }
static void PrintTemps(BITINT *modifiedBy) { int i; if (modifiedBy) { oprintf(icdFile, "["); for (i=1; i < termCount; i++) if (isset(modifiedBy, i)) oprintf(icdFile, "T%d ", termMapUp[i]); oprintf(icdFile, "]"); } }
static void nl P0 (void) { if (outcol > 0) { if (gentype == stringgen) { oprintf ("\""); } oprintf ("%s", newline); gentype = nogen; outcol = 0; } }
PRIVATE void put_byte P1 (UVAL, val) { if (val >= (UVAL) 32 && val <= (UVAL) 126 && val != (UVAL) '\\' && val != (UVAL) '"') { put_header (stringgen, alignment_of_type (tp_char)); oprintf ("%c", (int) val); outcol++; } else { put_header (bytegen, alignment_of_type (tp_char)); oprintf ("0x%lx", val & OxffUL); outcol += 4; } }
static void print_pciexrc(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_pciexrc_t pcie; if (check_oem(shp) != 0) return; (void) smbios_info_pciexrc(shp, id, &pcie); oprintf(fp, " Component ID: %u\n", pcie.smbpcie_bb); oprintf(fp, " BDF: 0x%x\n", pcie.smbpcie_bdf); }
static void print_memarrmap(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_memarrmap_t ma; (void) smbios_info_memarrmap(shp, id, &ma); id_printf(fp, " Physical Memory Array: ", ma.smbmam_array); oprintf(fp, " Devices per Row: %u\n", ma.smbmam_width); oprintf(fp, " Physical Address: 0x%llx\n Size: %llu bytes\n", (u_longlong_t)ma.smbmam_addr, (u_longlong_t)ma.smbmam_size); }
static void DumpAliases(void) { int i; oprintf(icdFile, "Alias Dump:\n"); for (i=0; i < DAGSIZE; i++) { ALIASADDRESS *aa = addresses[i]; while (aa) { ALIASLIST *al; ALIASADDRESS *aa1 = aa; while (aa1->merge) aa1 = aa1->merge; al = aa1->pointsto; PrintName(aa->name, aa->offset); oprintf(icdFile, ": "); while (al) { PrintName(al->address->name, al->address->offset); oprintf(icdFile," "); al = al->next; } PrintTemps(aa1->modifiedBy); oprintf(icdFile, "\n"); aa = aa->next; } } for (i=0; i < cachedTempCount; i++) { if (tempInfo[i]->pointsto) { ALIASLIST *al = tempInfo[i]->pointsto; oprintf(icdFile, "T%d:", i); while (al) { PrintName(al->address->name, al->address->offset); oprintf(icdFile," "); al = al->next; } PrintTemps(tempInfo[i]->modifiedBy); oprintf(icdFile, "\n"); } } { ALIASLIST *al = parmList; oprintf(icdFile, "UIV: "); while (al) { ALIASADDRESS *aa1 = al->address; while (aa1->merge) aa1 = aa1->merge; PrintName(aa1->name, aa1->offset); oprintf(icdFile," "); al = al->next; } PrintTemps(uivBytes); } }
static void print_extmemarray(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_memarray_ext_t em; if (check_oem(shp) != 0) return; (void) smbios_info_extmemarray(shp, id, &em); oprintf(fp, " Physical Memory Array Handle: %u\n", em.smbmae_ma); oprintf(fp, " Component Parent Handle: %u\n", em.smbmae_comp); oprintf(fp, " BDF: 0x%x\n", em.smbmae_bdf); }
void another_hour(int mode) { if (DEBUG > 2) log_info("called %s with %d", __PRETTY_FUNCTION__, mode); time_info.hours++; if (time_info.hours >= HOURS_PER_MUD_DAY) { time_info.hours = 0; time_info.day++; weather_info.moon++; if (weather_info.moon > MAX_MOON_PHASES) weather_info.moon = 1; if (time_info.day >= DAYS_PER_MUD_MONTH) { time_info.day = 0; time_info.month++; GetMonth(time_info.month); if (time_info.month >= MONTHS_PER_MUD_YEAR) { time_info.month = 0; time_info.year++; } } } if (mode) { switch (time_info.hours) { case 0: oprintf("The moon rises high overhead.\r\n"); break; case 4: oprintf("The moon sets.\r\n"); break; case 6: weather_info.sunlight = SUN_RISE; oprintf("The sun rises in the east.\r\n"); break; case 7: weather_info.sunlight = SUN_LIGHT; oprintf("The day has begun.\r\n"); break; case 12: oprintf("It is noon.\r\n"); break; case 18: weather_info.sunlight = SUN_SET; oprintf("The sun slowly disappears in the west.\r\n"); break; case 19: weather_info.sunlight = SUN_DARK; oprintf("The night has begun.\r\n"); break; case 21: oprintf("A %s moon rises in the eastern sky.\r\n", moon_names[(weather_info.moon - 1) / 4]); break; default: break; } } }
static void id_printf(FILE *fp, const char *s, id_t id) { switch (id) { case SMB_ID_NONE: oprintf(fp, "%sNone\n", s); break; case SMB_ID_NOTSUP: oprintf(fp, "%sNot Supported\n", s); break; default: oprintf(fp, "%s%u\n", s, (uint_t)id); } }
static void print_lang(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_lang_t l; (void) smbios_info_lang(shp, &l); oprintf(fp, " Current Language: %s\n", l.smbla_cur); oprintf(fp, " Language String Format: %u\n", l.smbla_fmt); oprintf(fp, " Number of Installed Languages: %u\n", l.smbla_num); oprintf(fp, " Installed Languages:\n"); print_strtab(shp, id, fp); }
void GetMonth(int month) { if (DEBUG > 2) log_info("called %s with %d", __PRETTY_FUNCTION__, month); if (month < 0) return; switch (month) { case 0: case 1: oprintf(" It is bitterly cold outside\r\n"); break; case 2: oprintf(" It is very cold \r\n"); break; case 3: case 4: oprintf(" It is chilly outside \r\n"); break; case 5: oprintf(" The flowers start to bloom \r\n"); break; case 6: case 7: case 8: case 9: case 10: case 11: oprintf(" It is warm and humid. \r\n"); break; case 12: oprintf(" It starts to get a little windy \r\n"); break; case 13: oprintf(" The air is getting chilly \r\n"); break; case 14: oprintf(" The leaves start to change colors. \r\n"); break; case 15: oprintf(" It starts to get cold \r\n"); break; case 16: case 17: oprintf(" It is bitterly cold outside \r\n"); break; } }
/*ARGSUSED*/ static void print_evlog(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_evlog_t ev; uint32_t i; (void) smbios_info_eventlog(shp, &ev); oprintf(fp, " Log Area Size: %lu bytes\n", (ulong_t)ev.smbev_size); oprintf(fp, " Header Offset: %lu\n", (ulong_t)ev.smbev_hdr); oprintf(fp, " Data Offset: %lu\n", (ulong_t)ev.smbev_data); desc_printf(smbios_evlog_method_desc(ev.smbev_method), fp, " Data Access Method: %u", ev.smbev_method); flag_printf(fp, "Log Flags", ev.smbev_flags, sizeof (ev.smbev_flags) * NBBY, smbios_evlog_flag_name, smbios_evlog_flag_desc); desc_printf(smbios_evlog_format_desc(ev.smbev_format), fp, " Log Header Format: %u", ev.smbev_format); oprintf(fp, " Update Token: 0x%x\n", ev.smbev_token); oprintf(fp, " Data Access Address: "); switch (ev.smbev_method) { case SMB_EVM_1x1i_1x1d: case SMB_EVM_2x1i_1x1d: case SMB_EVM_1x2i_1x1d: oprintf(fp, "Index Address 0x%x, Data Address 0x%x\n", ev.smbev_addr.eva_io.evi_iaddr, ev.smbev_addr.eva_io.evi_daddr); break; case SMB_EVM_GPNV: oprintf(fp, "0x%x\n", ev.smbev_addr.eva_gpnv); break; default: oprintf(fp, "0x%x\n", ev.smbev_addr.eva_addr); } oprintf(fp, " Type Descriptors:\n"); for (i = 0; i < ev.smbev_typec; i++) { oprintf(fp, " %u: Log Type 0x%x, Data Type 0x%x\n", i, ev.smbev_typev[i].smbevt_ltype, ev.smbev_typev[i].smbevt_dtype); } }
/* visit a full record */ const char* visitfull(const char* kbuf, size_t ksiz, const char* vbuf, size_t vsiz, size_t* sp, void* opq) { VISARG* arg; const char* rv; arg = opq; arg->cnt++; rv = KCVISNOP; switch (arg->rnd ? myrand(7) : arg->cnt % 7) { case 0: { rv = arg->rbuf; *sp = arg->rnd ? (size_t)myrand(sizeof(arg->rbuf)) : sizeof(arg->rbuf) / (arg->cnt % 5 + 1); break; } case 1: { rv = KCVISREMOVE; break; } } if (arg->rnum > 250 && arg->cnt % (arg->rnum / 250) == 0) { oputchar('.'); if (arg->cnt == arg->rnum || arg->cnt % (arg->rnum / 10) == 0) oprintf(" (%08ld)\n", (long)arg->cnt); } return rv; }
/*ARGSUSED*/ static int chewrec(const dtrace_probedata_t *data, const dtrace_recdesc_t *rec, void *arg) { dtrace_actkind_t act; uintptr_t addr; if (rec == NULL) { /* * We have processed the final record; output the newline if * we're not in quiet mode. */ if (!g_quiet) oprintf("\n"); return (DTRACE_CONSUME_NEXT); } act = rec->dtrd_action; addr = (uintptr_t)data->dtpda_data; if (act == DTRACEACT_EXIT) { g_status = *((uint32_t *)addr); return (DTRACE_CONSUME_NEXT); } return (DTRACE_CONSUME_THIS); }
static void kmallocc(void){ char*hex_str=arg0; int byte; eat_hex(hex_str,byte); if(byte==-1){ oprintf("bad size format\n"); return; } else if(byte+4<sizeof(EMPTY_BLOCK)){//申请byte太少 oprintf("you are timid,can you ask for more?\n"); } else {//正常申请 kmalloc(byte); } info_heap(); }
void * ioremap(unsigned phys_addr, int size, unsigned flags){ if(phys_addr >> 30) { oprintf(" %x ", phys_addr); spin("too big IO physical address"); } return (void *)(phys_addr + PAGE_OFFSET); }