summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Miodrag Milanovic <mmicko@gmail.com>2013-09-17 06:47:03 +0000
committerGravatarGravatar Miodrag Milanovic <mmicko@gmail.com>2013-09-17 06:47:03 +0000
commit96aa5e1c086b4927456dc88b925d8ec112f0482e (patch)
treef59d136c51d4a065f39e3ab0d73981526c4d156b
parenta7d12daf5b4c3374e8ad47a003ac7fff73d5c8fc (diff)
Cleanups and version bumpmame0150
-rw-r--r--hash/a800_flop.xml16
-rw-r--r--hash/amigaocs_flop.xml2
-rw-r--r--hash/apple2.xml2
-rw-r--r--hash/c64_cart.xml4
-rw-r--r--hash/c64_flop.xml2
-rw-r--r--hash/copera.xml16
-rw-r--r--hash/famicom_cass.xml2
-rw-r--r--hash/ibm5140.xml2
-rw-r--r--hash/ibm5170.xml2
-rw-r--r--hash/megadriv.xml38
-rw-r--r--hash/megaduck.xml10
-rw-r--r--hash/pc98.xml394
-rw-r--r--hash/visicom.xml2
-rw-r--r--src/emu/clifront.c4
-rw-r--r--src/emu/cpu/cpu.mak4
-rw-r--r--src/emu/cpu/cubeqcpu/cubeqcpu.c15
-rw-r--r--src/emu/cpu/es5510/es5510.c12
-rw-r--r--src/emu/cpu/es5510/es5510.h8
-rw-r--r--src/emu/cpu/f8/f8.c14
-rw-r--r--src/emu/cpu/i8085/i8085.c1
-rw-r--r--src/emu/cpu/i8089/i8089.h14
-rw-r--r--src/emu/cpu/i8089/i8089_channel.c20
-rw-r--r--src/emu/cpu/i8089/i8089_ops.c2
-rw-r--r--src/emu/cpu/i86/i186.c4
-rw-r--r--src/emu/cpu/i86/i286.c1
-rw-r--r--src/emu/cpu/i86/i286.h2
-rw-r--r--src/emu/cpu/i860/i860.c7
-rw-r--r--src/emu/cpu/i860/i860dec.c10
-rw-r--r--src/emu/cpu/i960/i960.c2
-rw-r--r--src/emu/cpu/jaguar/jaguar.c3
-rw-r--r--src/emu/cpu/lh5801/lh5801.c1
-rw-r--r--src/emu/cpu/m37710/m37710.h2
-rw-r--r--src/emu/cpu/m6800/m6800.c15
-rw-r--r--src/emu/cpu/m6800/m6800.h2
-rw-r--r--src/emu/cpu/m68000/m68k_in.c12
-rw-r--r--src/emu/cpu/mb86233/mb86233.c3
-rw-r--r--src/emu/cpu/mb88xx/mb88xx.c9
-rw-r--r--src/emu/cpu/mb88xx/mb88xx.h16
-rw-r--r--src/emu/cpu/mc68hc11/mc68hc11.c1
-rw-r--r--src/emu/cpu/mcs48/mcs48.c1
-rw-r--r--src/emu/cpu/mcs48/mcs48.h12
-rw-r--r--src/emu/cpu/mcs51/mcs51.c1
-rw-r--r--src/emu/cpu/minx/minx.c1
-rw-r--r--src/emu/cpu/minx/minx.h4
-rw-r--r--src/emu/cpu/mips/mips3drc.c3
-rw-r--r--src/emu/cpu/mn10200/mn10200.c2
-rw-r--r--src/emu/cpu/nec/v25.c2
-rw-r--r--src/emu/cpu/pic16c5x/pic16c5x.c69
-rw-r--r--src/emu/cpu/pic16c62x/pic16c62x.c1
-rw-r--r--src/emu/cpu/pic16c62x/pic16c62x.h4
-rw-r--r--src/emu/cpu/pps4/pps4.c1
-rw-r--r--src/emu/cpu/psx/rcnt.h2
-rw-r--r--src/emu/cpu/rsp/rspdrc.c1
-rw-r--r--src/emu/cpu/s2650/s2650.c1
-rw-r--r--src/emu/cpu/sh2/sh2comn.c8
-rw-r--r--src/emu/cpu/sh2/sh2comn.h2
-rw-r--r--src/emu/cpu/sh2/sh2fe.c1
-rw-r--r--src/emu/cpu/tlcs900/tlcs900.c1
-rw-r--r--src/emu/cpu/tms32082/dis_mp.c230
-rw-r--r--src/emu/cpu/tms32082/dis_pp.c142
-rw-r--r--src/emu/cpu/tms32082/mp_ops.c264
-rw-r--r--src/emu/cpu/tms32082/tms32082.c46
-rw-r--r--src/emu/cpu/tms32082/tms32082.h8
-rw-r--r--src/emu/cpu/tms34010/tms34010.c1
-rw-r--r--src/emu/cpu/tms34010/tms34010.h4
-rw-r--r--src/emu/cpu/tms9900/99xxcore.h2
-rw-r--r--src/emu/debug/debugcmd.c4
-rw-r--r--src/emu/debug/debugcpu.c58
-rw-r--r--src/emu/debug/debugcpu.h26
-rw-r--r--src/emu/debug/dvwpoints.c6
-rw-r--r--src/emu/divideo.c4
-rw-r--r--src/emu/divideo.h8
-rw-r--r--src/emu/emuopts.c8
-rw-r--r--src/emu/emuopts.h8
-rw-r--r--src/emu/machine.c2
-rw-r--r--src/emu/machine/40105.c4
-rw-r--r--src/emu/machine/40105.h2
-rw-r--r--src/emu/machine/74148.c5
-rw-r--r--src/emu/machine/74153.c8
-rw-r--r--src/emu/machine/74153.h4
-rw-r--r--src/emu/machine/74181.h3
-rw-r--r--src/emu/machine/aicartc.c6
-rw-r--r--src/emu/machine/aicartc.h2
-rw-r--r--src/emu/machine/atahle.c2
-rw-r--r--src/emu/machine/ataintf.c2
-rw-r--r--src/emu/machine/eeprom.c18
-rw-r--r--src/emu/machine/eeprom.h24
-rw-r--r--src/emu/machine/eeprompar.c57
-rw-r--r--src/emu/machine/eeprompar.h3
-rw-r--r--src/emu/machine/eepromser.c283
-rw-r--r--src/emu/machine/eepromser.h64
-rw-r--r--src/emu/machine/generic.c1
-rw-r--r--src/emu/machine/mb87078.h4
-rw-r--r--src/emu/machine/s2636.c6
-rw-r--r--src/emu/machine/s2636.h8
-rw-r--r--src/emu/machine/smc91c9x.h6
-rw-r--r--src/emu/machine/wd_fdc.c2
-rw-r--r--src/emu/mame.c8
-rw-r--r--src/emu/memarray.h20
-rw-r--r--src/emu/profiler.h2
-rw-r--r--src/emu/screen.h4
-rw-r--r--src/emu/sound/aica.c4
-rw-r--r--src/emu/sound/cdp1864.h2
-rw-r--r--src/emu/sound/esqpump.c11
-rw-r--r--src/emu/sound/esqpump.h5
-rw-r--r--src/emu/sound/multipcm.h2
-rw-r--r--src/emu/sound/okim6376.h4
-rw-r--r--src/emu/sound/s14001a.h4
-rw-r--r--src/emu/sound/sound.mak2
-rw-r--r--src/emu/sound/sp0250.c6
-rw-r--r--src/emu/sound/sp0250.h6
-rw-r--r--src/emu/sound/t6721a.h2
-rw-r--r--src/emu/sound/tms5220.c4
-rw-r--r--src/emu/sound/upd7752.c11
-rw-r--r--src/emu/sound/upd7752.h4
-rw-r--r--src/emu/tilemap.h2
-rw-r--r--src/emu/video/315_5124.h2
-rw-r--r--src/emu/video/dl1416.c2
-rw-r--r--src/emu/video/hd63484.h8
-rw-r--r--src/emu/video/huc6260.c2
-rw-r--r--src/emu/video/huc6261.c2
-rw-r--r--src/emu/video/i8275.h2
-rw-r--r--src/emu/video/i8275x.h6
-rw-r--r--src/emu/video/polynew.h2
-rw-r--r--src/emu/video/v9938.h14
-rw-r--r--src/emu/webengine.c105
-rw-r--r--src/emu/webengine.h18
-rw-r--r--src/lib/formats/cpis_dsk.c1
-rw-r--r--src/lib/formats/g64_dsk.c14
-rw-r--r--src/lib/web/json/config.h22
-rw-r--r--src/lib/web/json/features.h63
-rw-r--r--src/lib/web/json/forwards.h47
-rw-r--r--src/lib/web/json/json_batchallocator.h176
-rw-r--r--src/lib/web/json/json_tool.h96
-rw-r--r--src/lib/web/json/reader.h383
-rw-r--r--src/lib/web/json/value.h1885
-rw-r--r--src/lib/web/json/writer.h319
-rw-r--r--src/lib/web/mongoose.c7923
-rw-r--r--src/lib/web/mongoose.h202
-rw-r--r--src/lib/zlib/adler32.c246
-rw-r--r--src/lib/zlib/compress.c70
-rw-r--r--src/lib/zlib/crc32.c486
-rw-r--r--src/lib/zlib/crc32.h864
-rw-r--r--src/lib/zlib/deflate.c2919
-rw-r--r--src/lib/zlib/deflate.h408
-rw-r--r--src/lib/zlib/gzclose.c14
-rw-r--r--src/lib/zlib/gzguts.h72
-rw-r--r--src/lib/zlib/gzlib.c892
-rw-r--r--src/lib/zlib/gzread.c962
-rw-r--r--src/lib/zlib/gzwrite.c940
-rw-r--r--src/lib/zlib/infback.c998
-rw-r--r--src/lib/zlib/inffast.c482
-rw-r--r--src/lib/zlib/inffixed.h182
-rw-r--r--src/lib/zlib/inflate.c2136
-rw-r--r--src/lib/zlib/inflate.h144
-rw-r--r--src/lib/zlib/inftrees.c534
-rw-r--r--src/lib/zlib/inftrees.h16
-rw-r--r--src/lib/zlib/trees.c1529
-rw-r--r--src/lib/zlib/trees.h13
-rw-r--r--src/lib/zlib/uncompr.c66
-rw-r--r--src/lib/zlib/zconf.h70
-rw-r--r--src/lib/zlib/zlib.h224
-rw-r--r--src/lib/zlib/zutil.c260
-rw-r--r--src/lib/zlib/zutil.h62
-rw-r--r--src/mame/audio/decobsmt.h2
-rw-r--r--src/mame/audio/exidy.c4
-rw-r--r--src/mame/audio/exidy.h44
-rw-r--r--src/mame/audio/exidy440.c4
-rw-r--r--src/mame/audio/galaxian.c8
-rw-r--r--src/mame/audio/leland.c2
-rw-r--r--src/mame/audio/segam1audio.c7
-rw-r--r--src/mame/audio/seibu.c14
-rw-r--r--src/mame/audio/seibu.h50
-rw-r--r--src/mame/audio/t5182.c6
-rw-r--r--src/mame/audio/t5182.h4
-rw-r--r--src/mame/audio/taito_en.c2
-rw-r--r--src/mame/audio/taito_en.h10
-rw-r--r--src/mame/audio/taitosnd.c10
-rw-r--r--src/mame/audio/targ.c4
-rw-r--r--src/mame/drivers/20pacgal.c14
-rw-r--r--src/mame/drivers/3x3puzzl.c16
-rw-r--r--src/mame/drivers/arcadecl.c4
-rw-r--r--src/mame/drivers/atarig42.c2
-rw-r--r--src/mame/drivers/atarigt.c2
-rw-r--r--src/mame/drivers/atarigx2.c2
-rw-r--r--src/mame/drivers/atarisy1.c4
-rw-r--r--src/mame/drivers/atarisy2.c4
-rw-r--r--src/mame/drivers/badlands.c6
-rw-r--r--src/mame/drivers/batman.c2
-rw-r--r--src/mame/drivers/berzerk.c4
-rw-r--r--src/mame/drivers/bfm_sc1.c4
-rw-r--r--src/mame/drivers/blstroid.c2
-rw-r--r--src/mame/drivers/cabal.c2
-rw-r--r--src/mame/drivers/cave.c34
-rw-r--r--src/mame/drivers/cdi.c2
-rw-r--r--src/mame/drivers/crystal.c2
-rw-r--r--src/mame/drivers/cupidon.c14
-rw-r--r--src/mame/drivers/cyberbal.c4
-rw-r--r--src/mame/drivers/dambustr.c2
-rw-r--r--src/mame/drivers/dblewing.c4
-rw-r--r--src/mame/drivers/ddealer.c22
-rw-r--r--src/mame/drivers/ddragon.c24
-rw-r--r--src/mame/drivers/de_3.c84
-rw-r--r--src/mame/drivers/de_3b.c8
-rw-r--r--src/mame/drivers/eprom.c6
-rw-r--r--src/mame/drivers/exprraid.c8
-rw-r--r--src/mame/drivers/firebeat.c8
-rw-r--r--src/mame/drivers/freekick.c2
-rw-r--r--src/mame/drivers/galaxia.c2
-rw-r--r--src/mame/drivers/galaxold.c6
-rw-r--r--src/mame/drivers/galpani2.c38
-rw-r--r--src/mame/drivers/galpani3.c8
-rw-r--r--src/mame/drivers/galpanic.c38
-rw-r--r--src/mame/drivers/gticlub.c6
-rw-r--r--src/mame/drivers/harddriv.c2
-rw-r--r--src/mame/drivers/klax.c2
-rw-r--r--src/mame/drivers/ksys573.c2
-rw-r--r--src/mame/drivers/laserbas.c94
-rw-r--r--src/mame/drivers/malzak.c2
-rw-r--r--src/mame/drivers/maygay1b.c8
-rw-r--r--src/mame/drivers/mjkjidai.c2
-rw-r--r--src/mame/drivers/mlanding.c144
-rw-r--r--src/mame/drivers/model2.c2
-rw-r--r--src/mame/drivers/mpu5hw.c2
-rw-r--r--src/mame/drivers/mustache.c6
-rw-r--r--src/mame/drivers/namcond1.c2
-rw-r--r--src/mame/drivers/namcos22.c42
-rw-r--r--src/mame/drivers/naomi.c4
-rw-r--r--src/mame/drivers/nmk16.c22
-rw-r--r--src/mame/drivers/offtwall.c2
-rw-r--r--src/mame/drivers/panicr.c8
-rw-r--r--src/mame/drivers/polepos.c54
-rw-r--r--src/mame/drivers/r2dx_v33.c4
-rw-r--r--src/mame/drivers/raiden2.c8
-rw-r--r--src/mame/drivers/rampart.c2
-rw-r--r--src/mame/drivers/relief.c2
-rw-r--r--src/mame/drivers/renegade.c2
-rw-r--r--src/mame/drivers/sandscrp.c16
-rw-r--r--src/mame/drivers/seabattl.c2
-rw-r--r--src/mame/drivers/sfbonus.c2
-rw-r--r--src/mame/drivers/shanghai.c2
-rw-r--r--src/mame/drivers/skimaxx.c2
-rw-r--r--src/mame/drivers/skullxbo.c2
-rw-r--r--src/mame/drivers/snk68.c82
-rw-r--r--src/mame/drivers/stfight.c4
-rw-r--r--src/mame/drivers/taito_b.c4
-rw-r--r--src/mame/drivers/taito_f3.c2
-rw-r--r--src/mame/drivers/taito_x.c4
-rw-r--r--src/mame/drivers/taitoair.c6
-rw-r--r--src/mame/drivers/taitotx.c2
-rw-r--r--src/mame/drivers/taitotz.c2
-rw-r--r--src/mame/drivers/tapatune.c102
-rw-r--r--src/mame/drivers/thunderj.c2
-rw-r--r--src/mame/drivers/toaplan2.c3
-rw-r--r--src/mame/drivers/toobin.c4
-rw-r--r--src/mame/drivers/topspeed.c38
-rw-r--r--src/mame/drivers/trvmadns.c2
-rw-r--r--src/mame/drivers/tumbleb.c10
-rw-r--r--src/mame/drivers/vamphalf.c4
-rw-r--r--src/mame/drivers/vegas.c4
-rw-r--r--src/mame/drivers/vicdual.c2
-rw-r--r--src/mame/drivers/vindictr.c4
-rw-r--r--src/mame/drivers/xybots.c2
-rw-r--r--src/mame/includes/amiga.h2
-rw-r--r--src/mame/includes/arcadecl.h2
-rw-r--r--src/mame/includes/atarisy1.h2
-rw-r--r--src/mame/includes/cabal.h4
-rw-r--r--src/mame/includes/carpolo.h2
-rw-r--r--src/mame/includes/cd32.h14
-rw-r--r--src/mame/includes/darkmist.h4
-rw-r--r--src/mame/includes/ddragon3.h4
-rw-r--r--src/mame/includes/deadang.h4
-rw-r--r--src/mame/includes/dynduke.h2
-rw-r--r--src/mame/includes/exidy.h10
-rw-r--r--src/mame/includes/exprraid.h8
-rw-r--r--src/mame/includes/galaxia.h2
-rw-r--r--src/mame/includes/gauntlet.h8
-rw-r--r--src/mame/includes/harddriv.h2
-rw-r--r--src/mame/includes/klax.h2
-rw-r--r--src/mame/includes/macrossp.h5
-rw-r--r--src/mame/includes/micro3d.h2
-rw-r--r--src/mame/includes/mjkjidai.h4
-rw-r--r--src/mame/includes/model1.h2
-rw-r--r--src/mame/includes/model2.h4
-rw-r--r--src/mame/includes/mustache.h4
-rw-r--r--src/mame/includes/namcos22.h20
-rw-r--r--src/mame/includes/pgm.h2
-rw-r--r--src/mame/includes/raiden2.h2
-rw-r--r--src/mame/includes/segas32.h2
-rw-r--r--src/mame/includes/snes.h2
-rw-r--r--src/mame/includes/snk6502.h6
-rw-r--r--src/mame/includes/stfight.h4
-rw-r--r--src/mame/includes/taito_b.h2
-rw-r--r--src/mame/includes/taito_x.h4
-rw-r--r--src/mame/includes/toki.h2
-rw-r--r--src/mame/includes/topspeed.h18
-rw-r--r--src/mame/includes/vicdual.h12
-rw-r--r--src/mame/includes/wolfpack.h4
-rw-r--r--src/mame/includes/xybots.h6
-rw-r--r--src/mame/includes/zac2650.h4
-rw-r--r--src/mame/machine/atarigen.c6
-rw-r--r--src/mame/machine/atarigen.h13
-rw-r--r--src/mame/machine/cd32.c2
-rw-r--r--src/mame/machine/deco104.c2058
-rw-r--r--src/mame/machine/deco146.c2
-rw-r--r--src/mame/machine/decocass_tape.h8
-rw-r--r--src/mame/machine/decopincpu.c30
-rw-r--r--src/mame/machine/gaelco3d.c2
-rw-r--r--src/mame/machine/gaelco3d.h6
-rw-r--r--src/mame/machine/maple-dc.c3
-rw-r--r--src/mame/machine/megavdp.c6
-rw-r--r--src/mame/machine/namco62.h4
-rw-r--r--src/mame/machine/naomi.c32
-rw-r--r--src/mame/machine/neoprot.c12
-rw-r--r--src/mame/machine/nmk004.c6
-rw-r--r--src/mame/machine/nmk004.h6
-rw-r--r--src/mame/machine/pgmprot_igs025_igs028.c84
-rw-r--r--src/mame/machine/pgmprot_igs027a_type1.c192
-rw-r--r--src/mame/machine/pgmprot_igs027a_type2.c2
-rw-r--r--src/mame/machine/stfight.c2
-rw-r--r--src/mame/mame.lst26
-rw-r--r--src/mame/video/8080bw.c2
-rw-r--r--src/mame/video/atarimo.c60
-rw-r--r--src/mame/video/atarimo.h137
-rw-r--r--src/mame/video/atarirle.c54
-rw-r--r--src/mame/video/atarirle.h76
-rw-r--r--src/mame/video/bfm_adr2.c12
-rw-r--r--src/mame/video/bfm_adr2.h20
-rw-r--r--src/mame/video/bfm_dm01.c6
-rw-r--r--src/mame/video/bfm_dm01.h8
-rw-r--r--src/mame/video/cave.c6
-rw-r--r--src/mame/video/ddragon3.c3
-rw-r--r--src/mame/video/deco16ic.c2
-rw-r--r--src/mame/video/deco16ic.h2
-rw-r--r--src/mame/video/gticlub.c2
-rw-r--r--src/mame/video/k001005.c4
-rw-r--r--src/mame/video/k001005.h8
-rw-r--r--src/mame/video/k037122.h2
-rw-r--r--src/mame/video/kaneko_spr.c2
-rw-r--r--src/mame/video/mcd212.c2
-rw-r--r--src/mame/video/namcos2.c4
-rw-r--r--src/mame/video/namcos22.c32
-rw-r--r--src/mame/video/powervr2.c59
-rw-r--r--src/mame/video/powervr2.h2
-rw-r--r--src/mame/video/segaic16.c2
-rw-r--r--src/mame/video/segaic16.h2
-rw-r--r--src/mame/video/snes.c2
-rw-r--r--src/mame/video/tia.c2
-rw-r--r--src/mame/video/tia.h12
-rw-r--r--src/mame/video/toobin.c1
-rw-r--r--src/mame/video/vrender0.c2
-rw-r--r--src/mame/video/vrender0.h4
-rw-r--r--src/mame/video/ygv608.c8
-rw-r--r--src/mame/video/ygv608.h14
-rw-r--r--src/mess/drivers/a7800.c264
-rw-r--r--src/mess/drivers/abc1600.c4
-rw-r--r--src/mess/drivers/apple2.c17
-rw-r--r--src/mess/drivers/apricot.c4
-rw-r--r--src/mess/drivers/cat.c4
-rw-r--r--src/mess/drivers/cosmicos.c4
-rw-r--r--src/mess/drivers/dccons.c466
-rw-r--r--src/mess/drivers/dsb46.c2
-rw-r--r--src/mess/drivers/esq5505.c22
-rw-r--r--src/mess/drivers/kaypro.c4
-rw-r--r--src/mess/drivers/kyocera.c18
-rw-r--r--src/mess/drivers/lola8a.c111
-rw-r--r--src/mess/drivers/mac.c2
-rw-r--r--src/mess/drivers/megadriv.c1
-rw-r--r--src/mess/drivers/mtx.c42
-rw-r--r--src/mess/drivers/octopus.c48
-rw-r--r--src/mess/drivers/onyx.c6
-rw-r--r--src/mess/drivers/pc9801.c36
-rw-r--r--src/mess/drivers/rainbow.c246
-rw-r--r--src/mess/drivers/sbc6510.c2
-rw-r--r--src/mess/drivers/segapico.c41
-rw-r--r--src/mess/drivers/studio2.c20
-rw-r--r--src/mess/drivers/supracan.c4
-rw-r--r--src/mess/drivers/v1050.c40
-rw-r--r--src/mess/drivers/zaurus.c26
-rw-r--r--src/mess/includes/aim65.h2
-rw-r--r--src/mess/includes/amstr_pc.h4
-rw-r--r--src/mess/includes/dccons.h8
-rw-r--r--src/mess/includes/md_cons.h2
-rw-r--r--src/mess/includes/osi.h2
-rw-r--r--src/mess/includes/rmnimbus.h28
-rw-r--r--src/mess/includes/studio2.h2
-rw-r--r--src/mess/layout/rainbow.lay6
-rw-r--r--src/mess/machine/64h156.c2
-rw-r--r--src/mess/machine/a2applicard.c20
-rw-r--r--src/mess/machine/abc1600mac.c2
-rw-r--r--src/mess/machine/abc1600mac.h2
-rw-r--r--src/mess/machine/c2040.c16
-rw-r--r--src/mess/machine/c64/magic_voice.c104
-rw-r--r--src/mess/machine/c64/magic_voice.h2
-rw-r--r--src/mess/machine/c64/music64.h2
-rw-r--r--src/mess/machine/c64_nl10.h2
-rw-r--r--src/mess/machine/comx_fd.c4
-rw-r--r--src/mess/machine/dccons.c4
-rw-r--r--src/mess/machine/e05a03.c1
-rw-r--r--src/mess/machine/e05a03.h4
-rw-r--r--src/mess/machine/hardbox.c59
-rw-r--r--src/mess/machine/hardbox.h2
-rw-r--r--src/mess/machine/isa_wd1002a_wx1.c2
-rw-r--r--src/mess/machine/isa_xtide.c4
-rw-r--r--src/mess/machine/mac.c16
-rw-r--r--src/mess/machine/mackbd.c21
-rw-r--r--src/mess/machine/mackbd.h22
-rw-r--r--src/mess/machine/micropolis.c2
-rw-r--r--src/mess/machine/micropolis.h10
-rw-r--r--src/mess/machine/mpu401.c73
-rw-r--r--src/mess/machine/mpu401.h2
-rw-r--r--src/mess/machine/pc_lpt.h4
-rw-r--r--src/mess/machine/rmnimbus.c4
-rw-r--r--src/mess/machine/ti99/spchsyn.c4
-rw-r--r--src/mess/machine/ti99/videowrp.c4
-rw-r--r--src/mess/mess.lst2
-rw-r--r--src/mess/video/733_asr.h2
-rw-r--r--src/mess/video/911_vdt.h2
-rw-r--r--src/mess/video/abc1600.c18
-rw-r--r--src/mess/video/abc1600.h2
-rw-r--r--src/mess/video/cirrus.h2
-rw-r--r--src/mess/video/gb_lcd.h2
-rw-r--r--src/mess/video/k1ge.h6
-rw-r--r--src/mess/video/nubus_m2video.c4
-rw-r--r--src/mess/video/pds30_procolor816.c2
-rw-r--r--src/mess/video/vtvideo.c102
-rw-r--r--src/osd/osdcomm.h6
-rw-r--r--src/osd/portmedia/pmmidi.c14
-rw-r--r--src/osd/sdl/debugqtbreakpointswindow.c2
-rw-r--r--src/osd/windows/d3dhlsl.h111
-rw-r--r--src/osd/windows/d3dintf.h2
-rw-r--r--src/osd/windows/drawd3d.h2
-rw-r--r--src/osd/windows/winmain.c2
-rw-r--r--src/osd/windows/winmain.h2
-rw-r--r--src/osd/windows/winptty.c4
-rw-r--r--src/tools/jedutil.c600
-rw-r--r--src/version.c2
437 files changed, 17649 insertions, 17765 deletions
diff --git a/hash/a800_flop.xml b/hash/a800_flop.xml
index 3c5cb6df128..091e16709b0 100644
--- a/hash/a800_flop.xml
+++ b/hash/a800_flop.xml
@@ -2,12 +2,12 @@
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
<!--
- Atari 400 / 800 floppies
- (skeleton list)
-
- note: many 'original' floppy images are in .atx format, whereas cracked / unprotected ones are .atr format
- .atx is unsupported, although apparently has been reverse engineered (insert info link here)
- There are also images in .xex format?
+ Atari 400 / 800 floppies
+ (skeleton list)
+
+ note: many 'original' floppy images are in .atx format, whereas cracked / unprotected ones are .atr format
+ .atx is unsupported, although apparently has been reverse engineered (insert info link here)
+ There are also images in .xex format?
-->
@@ -23,6 +23,6 @@
</dataarea>
</part>
</software>
-
-
+
+
</softwarelist>
diff --git a/hash/amigaocs_flop.xml b/hash/amigaocs_flop.xml
index 1200cc5f449..2a6c70b9cc9 100644
--- a/hash/amigaocs_flop.xml
+++ b/hash/amigaocs_flop.xml
@@ -20935,7 +20935,7 @@
<dataarea name="flop" size="1049612">
<rom name="hugo - pa nye eventyr 2 (denmark) (disk 1 of 6).ipf" size="1049612" crc="47ebcd60" sha1="e7689d9fab1d1eabb204121633ad0fad87100e86" offset="0"/>
</dataarea>
- </part>
+ </part>
<part name="flop2" interface="floppy_3_5">
<feature name="part_id" value="Disk 2" />
<dataarea name="flop" size="1049612">
diff --git a/hash/apple2.xml b/hash/apple2.xml
index 423ad5f055c..f2e22474ce4 100644
--- a/hash/apple2.xml
+++ b/hash/apple2.xml
@@ -2766,7 +2766,7 @@
<software name="breakout">
<description>Breakout</description>
<year>19??</year>
- <publisher>Apple Computer, Inc.</publisher> <!-- programmed by Steve Wozniak -->
+ <publisher>Apple Computer, Inc.</publisher> <!-- programmed by Steve Wozniak -->
<part name="flop11" interface="floppy_5_25">
<dataarea name="flop1" size="143360">
diff --git a/hash/c64_cart.xml b/hash/c64_cart.xml
index d02e4c86c2a..ea8171018f4 100644
--- a/hash/c64_cart.xml
+++ b/hash/c64_cart.xml
@@ -6903,11 +6903,11 @@
<publisher>Commodore</publisher>
<info name="serial" value="C-64320" />
<sharedfeat name="compatibility" value="NTSC,PAL"/>
-
+
<part name="cart" interface="c64_cart">
<feature name="game" value="0" />
<feature name="exrom" value="0" />
-
+
<dataarea name="roml" size="0x4000">
<rom name="a-bee-c.rom" size="0x4000" crc="5cfe999c" sha1="57202c3829f1d668c445ae7e792ae80245682a99" offset="0" />
</dataarea>
diff --git a/hash/c64_flop.xml b/hash/c64_flop.xml
index 615e223e15e..3feb643665c 100644
--- a/hash/c64_flop.xml
+++ b/hash/c64_flop.xml
@@ -1085,7 +1085,7 @@
<rom name="cmk49.d64" size="174848" crc="5ef6645a" sha1="c9afd892731ebd68bc67bd8c6c84cbb1aa5e874d" offset="0" />
</dataarea>
</part>
- </software>
+ </software>
<!-- Test -->
diff --git a/hash/copera.xml b/hash/copera.xml
index d7e208d1409..c199f65c655 100644
--- a/hash/copera.xml
+++ b/hash/copera.xml
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
- <!--
+ <!--
Games for the MIXT BOOK PLAYER COPERA
* メロディランド - Melody Land (Yamaha - 199312xx - MMGS-1)
@@ -16,9 +16,9 @@ not dumped?
* コペラのちきゅうだいすき - Copera no Chikyuu Daisuki (Yamaha - ???? - MMGS-9)
* 冒険!メロリン島 - Bouken! Merorin Shima (Yamaha - ???? - MMGS-10)
- -->
-
- <softwarelist name="copera" description="Yamaha / Sega Copera cartridges">
+ -->
+
+ <softwarelist name="copera" description="Yamaha / Sega Copera cartridges">
<software name="melody">
@@ -68,7 +68,7 @@ not dumped?
</dataarea>
</part>
</software>
-
+
<software name="outacanv">
<description>Outa no Canvas (Jpn)</description>
<year>1994</year>
@@ -83,8 +83,8 @@ not dumped?
</dataarea>
</part>
</software>
-
- <software name="copekono">
+
+ <software name="copekono">
<description>Copera no Kono Otonaani (Jpn)</description>
<year>1994</year>
<publisher>Yamaha</publisher>
@@ -98,7 +98,7 @@ not dumped?
</dataarea>
</part>
</software>
-
+
<software name="mikeatmw">
<description>Mike to Asobou Tobidase Milky Way (Jpn)</description>
<year>1994</year>
diff --git a/hash/famicom_cass.xml b/hash/famicom_cass.xml
index bab4db6bac9..55dda55ecaa 100644
--- a/hash/famicom_cass.xml
+++ b/hash/famicom_cass.xml
@@ -2,7 +2,7 @@
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
<softwarelist name="famicom_cass" description="Nintendo Famicom Family BASIC cassettes">
-<!--
+<!--
This list is a bit peculiar, since it contains cassette images obtained on a FC
by saving BASIC programs typed in from magazines, books, or homebrew
diff --git a/hash/ibm5140.xml b/hash/ibm5140.xml
index 4c7a3b193b6..af79581dbed 100644
--- a/hash/ibm5140.xml
+++ b/hash/ibm5140.xml
@@ -52,5 +52,5 @@
</dataarea>
</part>
</software>
-
+
</softwarelist>
diff --git a/hash/ibm5170.xml b/hash/ibm5170.xml
index d13845fcd6a..47f0a4cec65 100644
--- a/hash/ibm5170.xml
+++ b/hash/ibm5170.xml
@@ -13,7 +13,7 @@ Missing files come here
<description>Advanced Diagnostics for the IBM AT (v2.07)</description>
<year>1985</year>
<publisher>IBM</publisher>
-
+
<part name="flop1" interface="floppy_5_25">
<dataarea name="flop" size="368640">
<rom name="atad_207.img" size="368640" crc="43d0783b" sha1="63a48f7dd92382356222ed2030cd4b900d09de3d" offset="0" />
diff --git a/hash/megadriv.xml b/hash/megadriv.xml
index 0a9dc0976de..3af9614b6be 100644
--- a/hash/megadriv.xml
+++ b/hash/megadriv.xml
@@ -31027,16 +31027,16 @@ This dump is either a bad dump or a wrongly patched one.
-->
- <!-- Software below is test / demo software for the purpose of validating our emulation
- where possible any information / additional files provided with the software has been included in extra data areas
- in order to mirror the original release packages and possibly provide useful references
-
- If no additional materials are listed then the results of a successful run should be mentioned here for future reference.
- -->
-
- <!-- most effects currently fail -->
- <!-- titan-overdrivemegademo.zip -->
- <!-- http://www.pouet.net/prod.php?which=61724 -->
+ <!-- Software below is test / demo software for the purpose of validating our emulation
+ where possible any information / additional files provided with the software has been included in extra data areas
+ in order to mirror the original release packages and possibly provide useful references
+
+ If no additional materials are listed then the results of a successful run should be mentioned here for future reference.
+ -->
+
+ <!-- most effects currently fail -->
+ <!-- titan-overdrivemegademo.zip -->
+ <!-- http://www.pouet.net/prod.php?which=61724 -->
<software name="d_titovr">
<description>Overdrive (Demo) (Euro)</description>
<year>2013</year>
@@ -31045,19 +31045,19 @@ This dump is either a bad dump or a wrongly patched one.
<dataarea name="rom" size="0x400000">
<rom name="titan-overdrivemegademo.bin" size="0x3f01be" crc="3deb19a9" sha1="6085182099d6a9ad2c8242eae263507e42269b66" offset="0x000000" loadflag="load16_word_swap"/>
</dataarea>
- <!-- non-rom extras (should be marked as optional?) -->
- <dataarea name="misc" size="0x7af9">
+ <!-- non-rom extras (should be marked as optional?) -->
+ <dataarea name="misc" size="0x7af9">
<rom name="titan-overdrivemegademo.nfo" size="0x7af9" crc="d560530a" sha1="f3a130881878e95a1db6e32268e7b1b001965c1a" offset="0x000000"/>
</dataarea>
- <dataarea name="misc2" size="0x13489c0">
- <rom name="titan-overdrivemegademo_inlay.pdf" size="0x13489c0" crc="ae55e12d" sha1="620fcba1600563b87543b027c42687da7d876b03" offset="0x000000"/>
+ <dataarea name="misc2" size="0x13489c0">
+ <rom name="titan-overdrivemegademo_inlay.pdf" size="0x13489c0" crc="ae55e12d" sha1="620fcba1600563b87543b027c42687da7d876b03" offset="0x000000"/>
</dataarea>
- <dataarea name="misc3" size="0xa68cf">
- <rom name="titan-overdrivemegademo_label.pdf" size="0xa68cf" crc="a527c826" sha1="449c945a0ddcbb145c7c92bc01fac543fc1352da" offset="0x000000"/>
+ <dataarea name="misc3" size="0xa68cf">
+ <rom name="titan-overdrivemegademo_label.pdf" size="0xa68cf" crc="a527c826" sha1="449c945a0ddcbb145c7c92bc01fac543fc1352da" offset="0x000000"/>
</dataarea>
- <dataarea name="misc4" size="0x1c985d">
- <rom name="titan-overdrivemegademo_poster.png" size="0x1c985d" crc="0dfeac10" sha1="cdfd4ff93e199da66cab3ef49d39828f3eb6040c" offset="0x000000"/>
- </dataarea>
+ <dataarea name="misc4" size="0x1c985d">
+ <rom name="titan-overdrivemegademo_poster.png" size="0x1c985d" crc="0dfeac10" sha1="cdfd4ff93e199da66cab3ef49d39828f3eb6040c" offset="0x000000"/>
+ </dataarea>
</part>
</software>
diff --git a/hash/megaduck.xml b/hash/megaduck.xml
index 8b752623610..6ff9812a745 100644
--- a/hash/megaduck.xml
+++ b/hash/megaduck.xml
@@ -193,7 +193,7 @@
</dataarea>
</part>
</software>
-
+
<software name="2ndspace">
<description>2nd Space</description>
<year>1993</year>
@@ -206,7 +206,7 @@
</dataarea>
</part>
</software>
-
+
<software name="trapturn">
<description>Trap &amp; Turn</description>
<year>1993</year>
@@ -219,7 +219,7 @@
</dataarea>
</part>
</software>
-
+
<software name="bombdisp">
<description>Bomb Disposer</description>
<year>1993</year>
@@ -232,7 +232,7 @@
</dataarea>
</part>
</software>
-
+
<software name="mmaze">
<description>Magic Maze</description>
<year>1993</year>
@@ -245,7 +245,7 @@
</dataarea>
</part>
</software>
-
+
<software name="vex">
<description>Vex</description>
<year>1993</year>
diff --git a/hash/pc98.xml b/hash/pc98.xml
index f3d63d915eb..0c4af0b8939 100644
--- a/hash/pc98.xml
+++ b/hash/pc98.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE softwarelist SYSTEM "softwarelist.dtd">
-<softwarelist name="pc98" description="NEC PC-9801 disk images">
+<softwarelist name="pc98" description="NEC PC-9801 disk images">
<software name="pc98dosd">
<description>PC-98DO+ System Disk</description>
@@ -98,7 +98,7 @@ only have some part of Windows file and a Video driver(CLGD?).
<!--
PC-98xx NEW (as per 31 July 2013) software list starts here.
TODO:
-- Manually parse the list, add publisher / year where possible, fix floppy order (i.e. if a floppy is labeled opening.fdi or system.fdi is the one
+- Manually parse the list, add publisher / year where possible, fix floppy order (i.e. if a floppy is labeled opening.fdi or system.fdi is the one
required at PC-98xx boot), label ALL userX.fdi images as bad dump, test all games and double check support status, fix zipnames (most sucks right now),
identify anything that has a size different than 1265664 (== 3'5" floppy image), document any unorthodox way for running a given sw.
@@ -145,12 +145,12 @@ TODO:
<dataarea name="flop" size="1265664">
<rom name="2069ad_b.fdi" size="1265664" crc="3e596802" sha1="05633e7847be623f1fdc8e4c4cbaa91dd7ac8a68" offset="0" />
</dataarea>
- </part>
+ </part>
<part name="flop3" interface="floppy_5_25">
<dataarea name="flop" size="1265664">
<rom name="2069ad_c.fdi" size="1265664" crc="25c601a5" sha1="a6b6b7096fedf6a0536fee0b380e976ebd0eb63b" offset="0" />
</dataarea>
- </part>
+ </part>
</software>
<software name="31iwayu" supported="yes">
@@ -162,7 +162,7 @@ TODO:
<rom name="disk a.fdi" size="1265664" crc="7131e56e" sha1="2070ebdd0acb1a50d77cc73368b448fe05096a3e" offset="0" />
</dataarea>
</part>
-
+
<part name="flop2" interface="floppy_5_25">
<dataarea name="flop" size="1265664">
<rom name="disk b.fdi" size="1265664" crc="54ed018b" sha1="69aaf92e5545a26fe62e4acd5334249173b0e06b" offset="0" />
@@ -209,7 +209,7 @@ TODO:
</dataarea>
</part>
<!--
- Note: all of these are expansions (and have no clue about how to load them either)
+ Note: all of these are expansions (and have no clue about how to load them either)
-->
<part name="flop2" interface="floppy_5_25">
<dataarea name="flop" size="1265664">
@@ -833,24 +833,24 @@ TODO:
<software name="add_pdrk">
<description>AD&amp;D Pools of Darkness</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="diska.fdi" size="1265664" crc="a40becba" sha1="3c65e5ab1f95d5f9863681c472b8c73927e0a2c2" offset="0" />
- </dataarea>
- </part>
- <part name="flop2" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="diskb.fdi" size="1265664" crc="2fb75bcb" sha1="78df14162d4fbd9e6c8f6a67e00d3aed3dd02bc7" offset="0" />
- </dataarea>
- </part>
- <part name="flop3" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="opening.fdi" size="1265664" crc="11cf2229" sha1="abf3bed693797d9bfecb1b7dc42eadcfb8a14641" offset="0" />
- </dataarea>
- </part>
- </software>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="diska.fdi" size="1265664" crc="a40becba" sha1="3c65e5ab1f95d5f9863681c472b8c73927e0a2c2" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop2" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="diskb.fdi" size="1265664" crc="2fb75bcb" sha1="78df14162d4fbd9e6c8f6a67e00d3aed3dd02bc7" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop3" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="opening.fdi" size="1265664" crc="11cf2229" sha1="abf3bed693797d9bfecb1b7dc42eadcfb8a14641" offset="0" />
+ </dataarea>
+ </part>
+ </software>
<software name="add_ssil" supported="no">
<description>AD&amp;D Secret of the Silver Blades</description>
@@ -882,7 +882,7 @@ TODO:
<rom name="user.d88" size="0x138fb0" crc="efd89d91" sha1="c243ec20af65ea9f612926c2c8ce868750a076e4" offset="0" status="baddump" />
</dataarea>
</part>
- </software>
+ </software>
<software name="advanp2p">
<description>Advanced Power Dolls 2 Premium Disk</description>
@@ -912,9 +912,9 @@ TODO:
</part>
<!-- hacked (and working since it's 2hd floppy) set, not going to be supported however
<part name="flop3" interface="floppy_5_25">
- <dataarea name="flop" size="0x1093f0">
- <rom name="adventureland 2hd.d88" size="0x1093f0" crc="dfe46669" sha1="ee0e6fae3553f8b60d515ba5c0bfdbe56cb7df16" offset="0" />
- </dataarea>
+ <dataarea name="flop" size="0x1093f0">
+ <rom name="adventureland 2hd.d88" size="0x1093f0" crc="dfe46669" sha1="ee0e6fae3553f8b60d515ba5c0bfdbe56cb7df16" offset="0" />
+ </dataarea>
</part>
-->
</software>
@@ -1645,16 +1645,16 @@ TODO:
</part>
</software>
<!--
- <software name="applec4">
- <description> Apple Club - Data Shuu #04 - Tonari no Oneesan Hen</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="?pc98????????1 ????#4.fdi" size="1265664" crc=" ***" sha1="20e87b43 ?CRC32*Apple Club 1\aplclub1.FD" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="applec4">
+ <description> Apple Club - Data Shuu #04 - Tonari no Oneesan Hen</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="?pc98????????1 ????#4.fdi" size="1265664" crc=" ***" sha1="20e87b43 ?CRC32*Apple Club 1\aplclub1.FD" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="applecl">
<description>Apple Club 1 - Kinjirareta Asobi Series</description>
@@ -2041,7 +2041,7 @@ TODO:
</dataarea>
</part>
</software>
-
+
<software name="asokono">
<description>Asoko no Koufuku - Yamamoto-san-chi no Baai ni Okeru Asoko no Fukou ni Tsuite</description>
<year>19??</year>
@@ -2638,7 +2638,7 @@ TODO:
</dataarea>
</part>
</software>
-
+
<software name="bodyins">
<description>Body Inspection in Belloncho</description>
<year>19??</year>
@@ -2664,7 +2664,7 @@ TODO:
<rom name="bokosuka.d88" size="0x10f760" crc="d5da4869" sha1="1fd6124180be8f20acd188702e3b9f9c2d128428" offset="0" />
</dataarea>
</part>
- </software>
+ </software>
<software name="bomberq">
<description>Bomber Quest</description>
@@ -3093,7 +3093,7 @@ TODO:
</dataarea>
</part>
</software>
-
+
<software name="burningd">
<description>Burning Dragon</description>
<year>19??</year>
@@ -3257,7 +3257,7 @@ TODO:
</dataarea>
</part>
</software>
-
+
<software name="carata" cloneof="carat">
<description>Carat - Magical Blocks(another)</description>
<year>19??</year>
@@ -4275,7 +4275,7 @@ TODO:
</part>
</software>
-<!--
+<!--
Presumably copy protection floppy, to be used with CD-Rom
-->
<software name="debut">
@@ -5098,7 +5098,7 @@ Presumably copy protection floppy, to be used with CD-Rom
</part>
</software>
-
+
<software name="dragone">
<description>Dragon Egg</description>
<year>19??</year>
@@ -5527,16 +5527,16 @@ Presumably copy protection floppy, to be used with CD-Rom
<!--
TODO: missing install disks
- <software name="eveber">
- <description>Eve - Burst Error</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="dos62.fdi" size="1265664" crc="678b88a7" sha1="480dee4a4df0c588416b0895057caeba862eea7f" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="eveber">
+ <description>Eve - Burst Error</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="dos62.fdi" size="1265664" crc="678b88a7" sha1="480dee4a4df0c588416b0895057caeba862eea7f" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="f14fd">
@@ -5873,30 +5873,30 @@ TODO: missing install disks
<!-- same as all bishoujo extra disk 2 -->
<!--
- <software name="floppyb2">
- <description>Floppy Bunko 17 - All Bishoujo Art Graphics Vol. 2</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="disk_2.fdi" size="1265664" crc="ee12585b" sha1="941abd888e3ce84c072a28f4cd73b15cb6c8945b" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="floppyb2">
+ <description>Floppy Bunko 17 - All Bishoujo Art Graphics Vol. 2</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="disk_2.fdi" size="1265664" crc="ee12585b" sha1="941abd888e3ce84c072a28f4cd73b15cb6c8945b" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<!-- same as all bishoujo extra disk 3 -->
<!--
- <software name="floppyb3">
- <description>Floppy Bunko 20 - All Bishoujo Art Graphics Vol. 3</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="disk_3.fdi" size="1265664" crc="30ae9567" sha1="e46a1cd8fa82a99a497048001b2e6d0268c4a5d6" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="floppyb3">
+ <description>Floppy Bunko 20 - All Bishoujo Art Graphics Vol. 3</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="disk_3.fdi" size="1265664" crc="30ae9567" sha1="e46a1cd8fa82a99a497048001b2e6d0268c4a5d6" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="foxy">
@@ -6429,16 +6429,16 @@ TODO: missing install disks
<!--
Fake disk?
- <software name="golflin">
- <description>Golf Links 386 Pro</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="golf links 386 pro anex86 cd & hd boot disk.fdi" size="1265664" crc="05559a9e" sha1="77510219ec879af55a90da092e268c5fa4b0257c" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="golflin">
+ <description>Golf Links 386 Pro</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="golf links 386 pro anex86 cd & hd boot disk.fdi" size="1265664" crc="05559a9e" sha1="77510219ec879af55a90da092e268c5fa4b0257c" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="golflpr">
<description>Golf Links Champion Course Pinehurst Resort and Country Ciub</description>
@@ -6814,7 +6814,7 @@ Fake disk?
</software>
<!--
-Game is named "image", with lowercase i on title screen
+Game is named "image", with lowercase i on title screen
-->
<software name="image">
<description>image</description>
@@ -7310,16 +7310,16 @@ Game is named "image", with lowercase i on title screen
<!--
TODO: other two disks, in .nfd format
- <software name="kawaisou">
- <description>Kawaisou Monogatari</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="user.fdi" size="1265664" crc="6c424c81" sha1="5feb465c5178534a575b555eeeabacae36b9f650" offset="0" status="baddump" />
- </dataarea>
- </part>
- </software>
+ <software name="kawaisou">
+ <description>Kawaisou Monogatari</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="user.fdi" size="1265664" crc="6c424c81" sha1="5feb465c5178534a575b555eeeabacae36b9f650" offset="0" status="baddump" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="kerakera">
<description>Kerakera-sei</description>
@@ -8279,7 +8279,7 @@ TODO: other two disks, in .nfd format
</dataarea>
</part>
</software>
-
+
<software name="madouars">
<description>Madou Monogatari A-R-S</description>
<year>19??</year>
@@ -8465,16 +8465,16 @@ TODO: other two disks, in .nfd format
</software>
<!-- TODO: another .nfd floppy used
- <software name="mtaikai">
- <description>Mahjong Taikai</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="user.fdi" size="1265664" crc="fca4122d" sha1="6797330e0237af84f1f4f112704034281834c97b" offset="0" status="baddump" />
- </dataarea>
- </part>
- </software>
+ <software name="mtaikai">
+ <description>Mahjong Taikai</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="user.fdi" size="1265664" crc="fca4122d" sha1="6797330e0237af84f1f4f112704034281834c97b" offset="0" status="baddump" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="mahoush">
<description>Mahou Shoujo Rina</description>
@@ -8736,16 +8736,16 @@ TODO: other two disks, in .nfd format
</software>
<!-- same as disk 02 fugasel1
- <software name="mazeque">
- <description>Maze Quest</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="maze quest.fdi" size="1265664" crc="3949e01a" sha1="9ee3c3dac883036375c69192fd98af11695ffea8" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="mazeque">
+ <description>Maze Quest</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="maze quest.fdi" size="1265664" crc="3949e01a" sha1="9ee3c3dac883036375c69192fd98af11695ffea8" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="meikyuu">
@@ -9072,16 +9072,16 @@ TODO: other two disks, in .nfd format
<!--
Omake disk?
- <software name="mime">
- <description>Mime</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="special.fdi" size="1265664" crc="7a3b8749" sha1="2ed561501500af290bd09e09e523d934c9ba7b5c" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="mime">
+ <description>Mime</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="special.fdi" size="1265664" crc="7a3b8749" sha1="2ed561501500af290bd09e09e523d934c9ba7b5c" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="mink01">
@@ -9222,7 +9222,7 @@ Omake disk?
</part>
</software>
-<!--
+<!--
Requires MS-DOS 5.00H plus an unknown procedure (HDD install?)
-->
<software name="gundamao" supported="no">
@@ -9753,18 +9753,18 @@ Requires MS-DOS 5.00H plus an unknown procedure (HDD install?)
</part>
</software>
-<!--
+<!--
Other three disks, in nfd format
- <software name="n88bas61">
- <description>N88 BASIC v6.1</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="rx_train.fdi" size="1265664" crc="607b85f8" sha1="0d2fdf6f0550e50127b27b42b470ba25b305239c" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="n88bas61">
+ <description>N88 BASIC v6.1</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="rx_train.fdi" size="1265664" crc="607b85f8" sha1="0d2fdf6f0550e50127b27b42b470ba25b305239c" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="nadiamw">
@@ -9780,16 +9780,16 @@ Other three disks, in nfd format
<!--
other two disks
- <software name="narumah">
- <description>Naru Mahjong</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="disk01.fdi" size="1265664" crc="d2db97c6" sha1="06910b3812d6efbac4f0b6adb9767397f2b590d7" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="narumah">
+ <description>Naru Mahjong</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="disk01.fdi" size="1265664" crc="d2db97c6" sha1="06910b3812d6efbac4f0b6adb9767397f2b590d7" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="natsudam">
@@ -9834,7 +9834,7 @@ other two disks
</dataarea>
</part>
</software>
-
+
<software name="nazopds7">
<description>Nazo Puyo (off DS7)</description>
<year>19??</year>
@@ -12152,16 +12152,16 @@ other two disks
</part>
</software>
<!--
- <software name="rougeno">
- <description>Rouge no Densetsu (hdi)</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="kidou.fdi" size="1265664" crc="e0b52ce7" sha1="00ed12fdff1986986e347343d9176f6205d5d87c" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="rougeno">
+ <description>Rouge no Densetsu (hdi)</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="kidou.fdi" size="1265664" crc="e0b52ce7" sha1="00ed12fdff1986986e347343d9176f6205d5d87c" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="roundwar">
<description>Round Warrior</description>
@@ -12763,41 +12763,41 @@ other two disks
<!--
Same as Police Quest 2 - Quest for Glory stand-alone disks
- <software name="sierradp">
- <description>Sierra 3D AVG Double Pack - Quest for Glory &amp; Police Quest 2</description>
- <year>19??</year>
- <publisher>&lt;unknown&gt;</publisher>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="police quest ii disk 01.fdi" size="1265664" crc="18f51678" sha1="49b137412230d20df0dec0c1236866003a3f1f15" offset="0" />
- </dataarea>
- </part>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="police quest ii disk 02.fdi" size="1265664" crc="3fd79ed8" sha1="6893264fd7ecdbf8ceb14d2e62d76bb548fb344e" offset="0" />
- </dataarea>
- </part>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="police quest ii disk 03.fdi" size="1265664" crc="4c6f0d6a" sha1="442e4f2074087b5d8401f808153a12ffef9a6e7c" offset="0" />
- </dataarea>
- </part>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="quest for glory disk 01.fdi" size="1265664" crc="695c079e" sha1="93195094944af1d88338c4a2ce82f9188a7f3898" offset="0" />
- </dataarea>
- </part>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="quest for glory disk 02.fdi" size="1265664" crc="b8cdbf73" sha1="d6048c691963d159ce29c9e90b0f33a60e71c29d" offset="0" />
- </dataarea>
- </part>
- <part name="flop1" interface="floppy_5_25">
- <dataarea name="flop" size="1265664">
- <rom name="quest for glory disk 03.fdi" size="1265664" crc="10f50bfa" sha1="7aab2821b8a18ef3ec4811d6c8e50767f96f0108" offset="0" />
- </dataarea>
- </part>
- </software>
+ <software name="sierradp">
+ <description>Sierra 3D AVG Double Pack - Quest for Glory &amp; Police Quest 2</description>
+ <year>19??</year>
+ <publisher>&lt;unknown&gt;</publisher>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="police quest ii disk 01.fdi" size="1265664" crc="18f51678" sha1="49b137412230d20df0dec0c1236866003a3f1f15" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="police quest ii disk 02.fdi" size="1265664" crc="3fd79ed8" sha1="6893264fd7ecdbf8ceb14d2e62d76bb548fb344e" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="police quest ii disk 03.fdi" size="1265664" crc="4c6f0d6a" sha1="442e4f2074087b5d8401f808153a12ffef9a6e7c" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="quest for glory disk 01.fdi" size="1265664" crc="695c079e" sha1="93195094944af1d88338c4a2ce82f9188a7f3898" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="quest for glory disk 02.fdi" size="1265664" crc="b8cdbf73" sha1="d6048c691963d159ce29c9e90b0f33a60e71c29d" offset="0" />
+ </dataarea>
+ </part>
+ <part name="flop1" interface="floppy_5_25">
+ <dataarea name="flop" size="1265664">
+ <rom name="quest for glory disk 03.fdi" size="1265664" crc="10f50bfa" sha1="7aab2821b8a18ef3ec4811d6c8e50767f96f0108" offset="0" />
+ </dataarea>
+ </part>
+ </software>
-->
<software name="simcity">
@@ -14988,7 +14988,7 @@ Same as Police Quest 2 - Quest for Glory stand-alone disks
</dataarea>
</part>
</software>
-
+
<software name="vg2">
<description>Variable Geo 2 - The Bout of Cabalistic Goddess</description>
<year>19??</year>
@@ -16508,7 +16508,7 @@ Same as Police Quest 2 - Quest for Glory stand-alone disks
</dataarea>
</part>
</software>
-
+
<software name="artemis">
<description>Artemis</description>
<year>19??</year>
diff --git a/hash/visicom.xml b/hash/visicom.xml
index 14e014fd681..3b25d710897 100644
--- a/hash/visicom.xml
+++ b/hash/visicom.xml
@@ -8,7 +8,7 @@ _________________________________________________________________
CAS-110 Arithmetic Drill (Math Fun & Fun with Numbers) no 算数ドリル
CAS-130 Sports Fan (Baseball & Sumo Wrestling) yes スポーツファン
-CAS-140 Gambler I (Blackjack) no ギャンブラーI
+CAS-140 Gambler I (Blackjack) no ギャンブラーI
CAS-141 Gambler II (Slot Machine and Dice) no ギャンブラーII
CAS-160 Space Command (Space War) no スペースコマンド
CAS-190 Inspiration (Bagua and Biorhythm) no 霊感
diff --git a/src/emu/clifront.c b/src/emu/clifront.c
index 244762c9f4f..03fb7648d21 100644
--- a/src/emu/clifront.c
+++ b/src/emu/clifront.c
@@ -619,7 +619,7 @@ void cli_frontend::listdevices(const char *gamename)
// sort them by tag
qsort(&device_list[0], device_list.count(), sizeof(device_list[0]), compare_devices);
-
+
// dump the results
for (int index = 0; index < device_list.count(); index++)
{
@@ -629,7 +629,7 @@ void cli_frontend::listdevices(const char *gamename)
const char *tag = device->tag();
if (*tag == ':')
tag++;
-
+
// determine the depth
int depth = 1;
if (*tag == 0)
diff --git a/src/emu/cpu/cpu.mak b/src/emu/cpu/cpu.mak
index 7bfbe9cdf91..8b5ab207e92 100644
--- a/src/emu/cpu/cpu.mak
+++ b/src/emu/cpu/cpu.mak
@@ -726,8 +726,8 @@ $(CPUOBJ)/i8085/i8085.o: $(CPUSRC)/i8085/i8085.c \
ifneq ($(filter I8089,$(CPUS)),)
OBJDIRS += $(CPUOBJ)/i8089
CPUOBJS += $(CPUOBJ)/i8089/i8089.o \
- $(CPUOBJ)/i8089/i8089_channel.o \
- $(CPUOBJ)/i8089/i8089_ops.o
+ $(CPUOBJ)/i8089/i8089_channel.o \
+ $(CPUOBJ)/i8089/i8089_ops.o
DASMOBJS += $(CPUOBJ)/i8089/i8089_dasm.o
endif
diff --git a/src/emu/cpu/cubeqcpu/cubeqcpu.c b/src/emu/cpu/cubeqcpu/cubeqcpu.c
index 63f7dded5e2..157a53218f3 100644
--- a/src/emu/cpu/cubeqcpu/cubeqcpu.c
+++ b/src/emu/cpu/cubeqcpu/cubeqcpu.c
@@ -111,8 +111,8 @@ offs_t cquestrot_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const U
cquestlin_cpu_device::cquestlin_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : cpu_device(mconfig, CQUESTLIN, "Cube Quest Line CPU", tag, owner, clock, "cquestlin", __FILE__)
- , m_program_config("program", ENDIANNESS_BIG, 64, 8, -3)
+ : cpu_device(mconfig, CQUESTLIN, "Cube Quest Line CPU", tag, owner, clock, "cquestlin", __FILE__)
+ , m_program_config("program", ENDIANNESS_BIG, 64, 8, -3)
, m_linedata_r(*this)
, m_flags(0)
, m_curpc(0)
@@ -358,8 +358,8 @@ void cquestrot_cpu_device::state_string_export(const device_state_entry &entry,
{
case STATE_GENFLAGS:
string.printf( "%c%c%c", m_cflag ? 'C' : '.',
- m_vflag ? 'V' : '.',
- m_f ? '.' : 'Z');
+ m_vflag ? 'V' : '.',
+ m_f ? '.' : 'Z');
break;
}
}
@@ -488,9 +488,9 @@ void cquestlin_cpu_device::state_string_export(const device_state_entry &entry,
{
case STATE_GENFLAGS:
string.printf( "%c%c%c|%cG", m_cflag ? 'C' : '.',
- m_vflag ? 'V' : '.',
- m_f ? '.' : 'Z',
- ( m_clkcnt & 3 ) ? 'B' : 'F');
+ m_vflag ? 'V' : '.',
+ m_f ? '.' : 'Z',
+ ( m_clkcnt & 3 ) ? 'B' : 'F');
break;
}
}
@@ -1551,4 +1551,3 @@ void cquestlin_cpu_device::execute_run()
m_clkcnt++;
} while (m_icount > 0);
}
-
diff --git a/src/emu/cpu/es5510/es5510.c b/src/emu/cpu/es5510/es5510.c
index 0786fcb36c0..1e6fbf6968c 100644
--- a/src/emu/cpu/es5510/es5510.c
+++ b/src/emu/cpu/es5510/es5510.c
@@ -168,7 +168,7 @@ es5510_device::es5510_device(const machine_config &mconfig, const char *tag, dev
instr_latch = 0;
ram_sel = 0;
host_control = 0;
-
+
pc = 0;
memset(&alu, 0, sizeof(alu));
memset(&mulacc, 0, sizeof(mulacc));
@@ -606,7 +606,7 @@ void es5510_device::list_program(void(p)(const char *, ...)) {
is_written[i] = is_read[i] = false;
name[i][0] = '\0';
}
-
+
for (addr = 0; addr < 0xa0; addr++) {
DESCRIBE_INSTR(buf, instr[addr], gpr[addr], NULL, NULL, NULL, NULL);
UINT64 inst = instr[addr];
@@ -621,7 +621,7 @@ void es5510_device::list_program(void(p)(const char *, ...)) {
}
UINT8 operandSelect = (UINT8)((inst >> 8) & 0x0f);
- const op_select_t &opSelect = OPERAND_SELECT[operandSelect];
+ const op_select_t &opSelect = OPERAND_SELECT[operandSelect];
if (opSelect.mac_src == SRC_DST_REG) {
is_read[cReg] = true;
@@ -630,7 +630,7 @@ void es5510_device::list_program(void(p)(const char *, ...)) {
if (opSelect.mac_dst != SRC_DST_DELAY) { // either REG or BOTH
is_written[cReg] = true;
}
-
+
alu_op_t aluOp = ALU_OPS[alu_op];
if (aluOp.operands == 1) {
if (opSelect.alu_src == SRC_DST_REG) {
@@ -663,7 +663,7 @@ void es5510_device::list_program(void(p)(const char *, ...)) {
for (int i = 0xc0; i < 0x100; i++) {
name[i][0] = 0;
}
-
+
for (addr = 0; addr < 0xa0; addr++) {
UINT8 aReg = (UINT8)((instr[addr] >> 16) & 0xff);
UINT8 bReg = (UINT8)((instr[addr] >> 24) & 0xff);
@@ -830,7 +830,7 @@ void es5510_device::execute_run() {
// *** T2, clock high
LOG_EXEC(("- T2.1\n"));
-
+
// --- Write ALU Result N-1
LOG_EXEC((". write ALU:\n"));
if (alu.write_result) {
diff --git a/src/emu/cpu/es5510/es5510.h b/src/emu/cpu/es5510/es5510.h
index 6e73e4e1542..974c8511705 100644
--- a/src/emu/cpu/es5510/es5510.h
+++ b/src/emu/cpu/es5510/es5510.h
@@ -152,8 +152,8 @@ private:
INT16 ser2l;
INT16 ser3r;
INT16 ser3l;
- INT64 machl; // 48 bits, right justified and sign extended
- bool mac_overflow; // whether reading the MAC register should return a saturated replacement value
+ INT64 machl; // 48 bits, right justified and sign extended
+ bool mac_overflow; // whether reading the MAC register should return a saturated replacement value
INT32 dil;
INT32 memsiz;
INT32 memmask;
@@ -165,8 +165,8 @@ private:
INT32 dbase;
INT32 sigreg;
int mulshift;
- INT8 ccr; // really, 5 bits, left justified
- INT8 cmr; // really, 6 bits, left justified
+ INT8 ccr; // really, 5 bits, left justified
+ INT8 cmr; // really, 6 bits, left justified
INT32 dol[2];
int dol_count;
diff --git a/src/emu/cpu/f8/f8.c b/src/emu/cpu/f8/f8.c
index 00ca393bee4..c5c1dee0a0b 100644
--- a/src/emu/cpu/f8/f8.c
+++ b/src/emu/cpu/f8/f8.c
@@ -1601,7 +1601,7 @@ void f8_cpu_device::device_reset()
m_irq_vector = 0;
memset(m_r, 0, sizeof(m_r));
m_irq_request = 0;
-
+
m_w&=~I;
/* save PC0 to PC1 and reset PC0 */
@@ -2054,11 +2054,11 @@ void f8_cpu_device::state_string_export(const device_state_entry &entry, astring
{
case STATE_GENFLAGS:
string.printf("%c%c%c%c%c",
- m_w & 0x10 ? 'I':'.',
- m_w & 0x08 ? 'O':'.',
- m_w & 0x04 ? 'Z':'.',
- m_w & 0x02 ? 'C':'.',
- m_w & 0x01 ? 'S':'.');
+ m_w & 0x10 ? 'I':'.',
+ m_w & 0x08 ? 'O':'.',
+ m_w & 0x04 ? 'Z':'.',
+ m_w & 0x02 ? 'C':'.',
+ m_w & 0x01 ? 'S':'.');
break;
}
}
@@ -2075,5 +2075,3 @@ void f8_cpu_device::execute_set_input( int inptnum, int state )
{
m_irq_request = state;
}
-
-
diff --git a/src/emu/cpu/i8085/i8085.c b/src/emu/cpu/i8085/i8085.c
index 64b2fa268e3..732a03cf349 100644
--- a/src/emu/cpu/i8085/i8085.c
+++ b/src/emu/cpu/i8085/i8085.c
@@ -1133,4 +1133,3 @@ offs_t i8085a_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT
extern CPU_DISASSEMBLE( i8085 );
return CPU_DISASSEMBLE_NAME(i8085)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/i8089/i8089.h b/src/emu/cpu/i8089/i8089.h
index c5d3d62a453..adcc945f765 100644
--- a/src/emu/cpu/i8089/i8089.h
+++ b/src/emu/cpu/i8089/i8089.h
@@ -121,14 +121,14 @@ private:
SOC,
DIVIDER1,
CH1_GA, CH1_GB, CH1_GC,
- CH1_TP, CH1_BC, CH1_IX,
- CH1_CC, CH1_MC, CH1_CP,
- CH1_PP, CH1_PSW,
+ CH1_TP, CH1_BC, CH1_IX,
+ CH1_CC, CH1_MC, CH1_CP,
+ CH1_PP, CH1_PSW,
DIVIDER2,
- CH2_GA, CH2_GB, CH2_GC,
- CH2_TP, CH2_BC, CH2_IX,
- CH2_CC, CH2_MC, CH2_CP,
- CH2_PP, CH2_PSW
+ CH2_GA, CH2_GB, CH2_GC,
+ CH2_TP, CH2_BC, CH2_IX,
+ CH2_CC, CH2_MC, CH2_CP,
+ CH2_PP, CH2_PSW
};
// system configuration
diff --git a/src/emu/cpu/i8089/i8089_channel.c b/src/emu/cpu/i8089/i8089_channel.c
index 8e9e2833b46..b8d93c7e0bf 100644
--- a/src/emu/cpu/i8089/i8089_channel.c
+++ b/src/emu/cpu/i8089/i8089_channel.c
@@ -19,16 +19,16 @@
#define VERBOSE_DMA 1
// channel control register fields
-#define CC_TMC ((m_r[CC].w >> 0) & 0x07) // terminate on masked compare
-#define CC_TBC ((m_r[CC].w >> 3) & 0x03) // terminate on byte count
-#define CC_TX ((m_r[CC].w >> 5) & 0x03) // terminate on external signal
-#define CC_TS ((m_r[CC].w >> 7) & 0x01) // terminate on single transfer
-#define CC_CHAIN ((m_r[CC].w >> 8) & 0x01) // chaining
-#define CC_LOCK ((m_r[CC].w >> 9) & 0x01) // actuate lock
-#define CC_SOURCE ((m_r[CC].w >> 10) & 0x01) // source register
-#define CC_SYNC ((m_r[CC].w >> 11) & 0x03) // synchronization
-#define CC_TRANS ((m_r[CC].w >> 13) & 0x01) // translation
-#define CC_FUNC ((m_r[CC].w >> 14) & 0x03) // function
+#define CC_TMC ((m_r[CC].w >> 0) & 0x07) // terminate on masked compare
+#define CC_TBC ((m_r[CC].w >> 3) & 0x03) // terminate on byte count
+#define CC_TX ((m_r[CC].w >> 5) & 0x03) // terminate on external signal
+#define CC_TS ((m_r[CC].w >> 7) & 0x01) // terminate on single transfer
+#define CC_CHAIN ((m_r[CC].w >> 8) & 0x01) // chaining
+#define CC_LOCK ((m_r[CC].w >> 9) & 0x01) // actuate lock
+#define CC_SOURCE ((m_r[CC].w >> 10) & 0x01) // source register
+#define CC_SYNC ((m_r[CC].w >> 11) & 0x03) // synchronization
+#define CC_TRANS ((m_r[CC].w >> 13) & 0x01) // translation
+#define CC_FUNC ((m_r[CC].w >> 14) & 0x03) // function
//**************************************************************************
diff --git a/src/emu/cpu/i8089/i8089_ops.c b/src/emu/cpu/i8089/i8089_ops.c
index 4ceff35ddc8..f65cae7986c 100644
--- a/src/emu/cpu/i8089/i8089_ops.c
+++ b/src/emu/cpu/i8089/i8089_ops.c
@@ -2,7 +2,7 @@
Intel 8089 I/O Processor
- Opcode implementations
+ Opcode implementations
***************************************************************************/
diff --git a/src/emu/cpu/i86/i186.c b/src/emu/cpu/i86/i186.c
index 5850c157330..a36b8bcfad2 100644
--- a/src/emu/cpu/i86/i186.c
+++ b/src/emu/cpu/i86/i186.c
@@ -1284,8 +1284,8 @@ void i80186_cpu_device::drq_callback(int which)
update_interrupt_state();
}
-// dma->finish_timer->adjust(attotime::from_hz(clock()/8), 0);
-// dma->drq_delay = true;
+// dma->finish_timer->adjust(attotime::from_hz(clock()/8), 0);
+// dma->drq_delay = true;
}
READ16_MEMBER(i80186_cpu_device::internal_port_r)
diff --git a/src/emu/cpu/i86/i286.c b/src/emu/cpu/i86/i286.c
index efd37afe402..00b4df6be99 100644
--- a/src/emu/cpu/i86/i286.c
+++ b/src/emu/cpu/i86/i286.c
@@ -1956,4 +1956,3 @@ void i80286_cpu_device::check_permission(UINT8 check_seg, UINT32 offset, UINT16
throw TRAP(trap, 0);
}
}
-
diff --git a/src/emu/cpu/i86/i286.h b/src/emu/cpu/i86/i286.h
index f869c20ad4a..543f023fb50 100644
--- a/src/emu/cpu/i86/i286.h
+++ b/src/emu/cpu/i86/i286.h
@@ -7,7 +7,7 @@
extern const device_type I80286;
enum
-{ // same order as I8086 registers
+{ // same order as I8086 registers
I286_PC = 0,
I286_IP,
diff --git a/src/emu/cpu/i860/i860.c b/src/emu/cpu/i860/i860.c
index 0ea1be31177..f3aab4f7289 100644
--- a/src/emu/cpu/i860/i860.c
+++ b/src/emu/cpu/i860/i860.c
@@ -139,9 +139,9 @@ void i860_cpu_device::device_start()
void i860_cpu_device::state_import(const device_state_entry &entry)
{
#define I860_SET_INFO_F(fnum) m_frg[0+(4*fnum)] = (m_freg[fnum] & 0x000000ff); \
- m_frg[1+(4*fnum)] = (m_freg[fnum] & 0x0000ff00) >> 8; \
- m_frg[2+(4*fnum)] = (m_freg[fnum] & 0x00ff0000) >> 16; \
- m_frg[3+(4*fnum)] = (m_freg[fnum] & 0xff000000) >> 24;
+ m_frg[1+(4*fnum)] = (m_freg[fnum] & 0x0000ff00) >> 8; \
+ m_frg[2+(4*fnum)] = (m_freg[fnum] & 0x00ff0000) >> 16; \
+ m_frg[3+(4*fnum)] = (m_freg[fnum] & 0xff000000) >> 24;
switch (entry.index())
{
@@ -238,4 +238,3 @@ offs_t i860_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8
* The actual decode and execute code.
**************************************************************************/
#include "i860dec.c"
-
diff --git a/src/emu/cpu/i860/i860dec.c b/src/emu/cpu/i860/i860dec.c
index 286e4a9f893..ac036a1f124 100644
--- a/src/emu/cpu/i860/i860dec.c
+++ b/src/emu/cpu/i860/i860dec.c
@@ -285,11 +285,11 @@ void i860_cpu_device::set_fregval_d (int fr, double d)
int i860_cpu_device::has_delay_slot(UINT32 insn)
{
- int opc = (insn >> 26) & 0x3f;
- if (opc == 0x10 || opc == 0x1a || opc == 0x1b || opc == 0x1d ||
- opc == 0x1f || opc == 0x2d || (opc == 0x13 && (insn & 3) == 2))
- return 1;
- return 0;
+ int opc = (insn >> 26) & 0x3f;
+ if (opc == 0x10 || opc == 0x1a || opc == 0x1b || opc == 0x1d ||
+ opc == 0x1f || opc == 0x2d || (opc == 0x13 && (insn & 3) == 2))
+ return 1;
+ return 0;
}
/* This is the external interface for asserting/deasserting pins on
diff --git a/src/emu/cpu/i960/i960.c b/src/emu/cpu/i960/i960.c
index 05c9f768d38..b30f9dc865a 100644
--- a/src/emu/cpu/i960/i960.c
+++ b/src/emu/cpu/i960/i960.c
@@ -2077,7 +2077,6 @@ void i960_cpu_device::device_start()
void i960_cpu_device::state_string_export(const device_state_entry &entry, astring &string)
{
-
static const char *const conditions[8] =
{
"no", "g", "e", "ge", "l", "ne", "le", "o"
@@ -2116,4 +2115,3 @@ offs_t i960_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8
extern CPU_DISASSEMBLE( i960 );
return CPU_DISASSEMBLE_NAME(i960)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/jaguar/jaguar.c b/src/emu/cpu/jaguar/jaguar.c
index 3ac6d1fffe2..44a24f78b8d 100644
--- a/src/emu/cpu/jaguar/jaguar.c
+++ b/src/emu/cpu/jaguar/jaguar.c
@@ -416,7 +416,7 @@ void jaguar_cpu_device::state_string_export(const device_state_entry &entry, ast
FLAGS & 0x0008 ? 'I':'.',
FLAGS & 0x0004 ? 'N':'.',
FLAGS & 0x0002 ? 'C':'.',
- FLAGS & 0x0001 ? 'Z':'.');
+ FLAGS & 0x0001 ? 'Z':'.');
break;
}
}
@@ -1447,4 +1447,3 @@ offs_t jaguardsp_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const U
extern CPU_DISASSEMBLE( jaguardsp );
return CPU_DISASSEMBLE_NAME(jaguardsp)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/lh5801/lh5801.c b/src/emu/cpu/lh5801/lh5801.c
index 5c2151dbc87..bfaf8c7ec79 100644
--- a/src/emu/cpu/lh5801/lh5801.c
+++ b/src/emu/cpu/lh5801/lh5801.c
@@ -264,4 +264,3 @@ offs_t lh5801_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT
extern CPU_DISASSEMBLE( lh5801 );
return CPU_DISASSEMBLE_NAME(lh5801)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/m37710/m37710.h b/src/emu/cpu/m37710/m37710.h
index 32f33a81067..1aa492f99cb 100644
--- a/src/emu/cpu/m37710/m37710.h
+++ b/src/emu/cpu/m37710/m37710.h
@@ -161,7 +161,7 @@ private:
address_space *m_program;
address_space *m_io;
UINT32 m_stopped; /* Sets how the CPU is stopped */
-
+
// on-board peripheral stuff
UINT8 m_m37710_regs[128];
attotime m_reload[8];
diff --git a/src/emu/cpu/m6800/m6800.c b/src/emu/cpu/m6800/m6800.c
index 1c5ad8e2598..aed01bf45c3 100644
--- a/src/emu/cpu/m6800/m6800.c
+++ b/src/emu/cpu/m6800/m6800.c
@@ -1708,17 +1708,17 @@ WRITE8_MEMBER( m6800_cpu_device::m6801_io_w )
}
}
-void m6801_cpu_device::m6801_clock_serial()
-{
+void m6801_cpu_device::m6801_clock_serial()
+{
if (m_use_ext_serclock)
{
- m_ext_serclock++;
+ m_ext_serclock++;
if (m_ext_serclock >= 8)
- {
- m_ext_serclock = 0;
- serial_transmit();
- serial_receive();
+ {
+ m_ext_serclock = 0;
+ serial_transmit();
+ serial_receive();
}
}
}
@@ -1777,4 +1777,3 @@ offs_t nsc8105_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UIN
extern CPU_DISASSEMBLE( nsc8105 );
return CPU_DISASSEMBLE_NAME(nsc8105)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/m6800/m6800.h b/src/emu/cpu/m6800/m6800.h
index 6560f738e99..d5d790e0151 100644
--- a/src/emu/cpu/m6800/m6800.h
+++ b/src/emu/cpu/m6800/m6800.h
@@ -139,7 +139,7 @@ protected:
int m_clock_divider;
UINT8 m_trcsr, m_rmcr, m_rdr, m_tdr, m_rsr, m_tsr;
int m_rxbits, m_txbits, m_txstate, m_trcsr_read_tdre, m_trcsr_read_orfe, m_trcsr_read_rdrf, m_tx, m_ext_serclock;
- bool m_use_ext_serclock;
+ bool m_use_ext_serclock;
int m_port2_written;
int m_icount;
diff --git a/src/emu/cpu/m68000/m68k_in.c b/src/emu/cpu/m68000/m68k_in.c
index 793137fa1e7..19af7dde3c9 100644
--- a/src/emu/cpu/m68000/m68k_in.c
+++ b/src/emu/cpu/m68000/m68k_in.c
@@ -3897,9 +3897,9 @@ M68KMAKE_OP(clr, 8, ., .)
{
UINT32 ea = M68KMAKE_GET_EA_AY_8;
- if(CPU_TYPE_IS_010_LESS((mc68kcpu)->cpu_type))
+ if(CPU_TYPE_IS_010_LESS((mc68kcpu)->cpu_type))
{
- m68ki_read_8((mc68kcpu), ea); /* the 68000 (and 010?) does a dummy read, the value is discarded */
+ m68ki_read_8((mc68kcpu), ea); /* the 68000 (and 010?) does a dummy read, the value is discarded */
}
m68ki_write_8((mc68kcpu), ea, 0);
@@ -3926,9 +3926,9 @@ M68KMAKE_OP(clr, 16, ., .)
{
UINT32 ea = M68KMAKE_GET_EA_AY_16;
- if(CPU_TYPE_IS_010_LESS((mc68kcpu)->cpu_type))
+ if(CPU_TYPE_IS_010_LESS((mc68kcpu)->cpu_type))
{
- m68ki_read_16((mc68kcpu), ea); /* the 68000 (and 010?) does a dummy read, the value is discarded */
+ m68ki_read_16((mc68kcpu), ea); /* the 68000 (and 010?) does a dummy read, the value is discarded */
}
m68ki_write_16((mc68kcpu), ea, 0);
@@ -3955,9 +3955,9 @@ M68KMAKE_OP(clr, 32, ., .)
{
UINT32 ea = M68KMAKE_GET_EA_AY_32;
- if(CPU_TYPE_IS_010_LESS((mc68kcpu)->cpu_type))
+ if(CPU_TYPE_IS_010_LESS((mc68kcpu)->cpu_type))
{
- m68ki_read_32((mc68kcpu), ea); /* the 68000 (and 010?) does a dummy read, the value is discarded */
+ m68ki_read_32((mc68kcpu), ea); /* the 68000 (and 010?) does a dummy read, the value is discarded */
}
m68ki_write_32((mc68kcpu), ea, 0);
diff --git a/src/emu/cpu/mb86233/mb86233.c b/src/emu/cpu/mb86233/mb86233.c
index 67e2d388330..f1a4738d1e4 100644
--- a/src/emu/cpu/mb86233/mb86233.c
+++ b/src/emu/cpu/mb86233/mb86233.c
@@ -96,7 +96,7 @@ void mb86233_cpu_device::device_start()
m_fifo_read_cb.resolve_safe(0);
m_fifo_read_ok_cb.resolve_safe(0);
m_fifo_write_cb.resolve_safe();
-
+
m_program = &space(AS_PROGRAM);
m_direct = &m_program->direct();
@@ -1582,4 +1582,3 @@ void mb86233_cpu_device::execute_run()
}
}
}
-
diff --git a/src/emu/cpu/mb88xx/mb88xx.c b/src/emu/cpu/mb88xx/mb88xx.c
index 44a8393a71c..d613c7a989e 100644
--- a/src/emu/cpu/mb88xx/mb88xx.c
+++ b/src/emu/cpu/mb88xx/mb88xx.c
@@ -114,25 +114,25 @@ mb88_cpu_device::mb88_cpu_device(const machine_config &mconfig, device_type type
mb8841_cpu_device::mb8841_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mb88_cpu_device(mconfig, MB8841, "MB8841", tag, owner, clock, "mb8841", __FILE__, 11, 7)
+ : mb88_cpu_device(mconfig, MB8841, "MB8841", tag, owner, clock, "mb8841", __FILE__, 11, 7)
{
}
mb8842_cpu_device::mb8842_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mb88_cpu_device(mconfig, MB8842, "MB8842", tag, owner, clock, "mb8842", __FILE__, 11, 7)
+ : mb88_cpu_device(mconfig, MB8842, "MB8842", tag, owner, clock, "mb8842", __FILE__, 11, 7)
{
}
mb8843_cpu_device::mb8843_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mb88_cpu_device(mconfig, MB8843, "MB8843", tag, owner, clock, "mb8843", __FILE__, 10, 6)
+ : mb88_cpu_device(mconfig, MB8843, "MB8843", tag, owner, clock, "mb8843", __FILE__, 10, 6)
{
}
mb8844_cpu_device::mb8844_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : mb88_cpu_device(mconfig, MB8844, "MB8844", tag, owner, clock, "mb8844", __FILE__, 10, 6)
+ : mb88_cpu_device(mconfig, MB8844, "MB8844", tag, owner, clock, "mb8844", __FILE__, 10, 6)
{
}
@@ -946,4 +946,3 @@ void mb88_cpu_device::execute_run()
update_pio(oc);
}
}
-
diff --git a/src/emu/cpu/mb88xx/mb88xx.h b/src/emu/cpu/mb88xx/mb88xx.h
index 3e0103b1c5c..254df96f266 100644
--- a/src/emu/cpu/mb88xx/mb88xx.h
+++ b/src/emu/cpu/mb88xx/mb88xx.h
@@ -158,32 +158,32 @@ private:
class mb8841_cpu_device : public mb88_cpu_device
{
public:
- // construction/destruction
- mb8841_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ // construction/destruction
+ mb8841_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
class mb8842_cpu_device : public mb88_cpu_device
{
public:
- // construction/destruction
- mb8842_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ // construction/destruction
+ mb8842_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
class mb8843_cpu_device : public mb88_cpu_device
{
public:
- // construction/destruction
- mb8843_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ // construction/destruction
+ mb8843_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
class mb8844_cpu_device : public mb88_cpu_device
{
public:
- // construction/destruction
- mb8844_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ // construction/destruction
+ mb8844_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};
diff --git a/src/emu/cpu/mc68hc11/mc68hc11.c b/src/emu/cpu/mc68hc11/mc68hc11.c
index 4ed5b4e76af..243157eeb19 100644
--- a/src/emu/cpu/mc68hc11/mc68hc11.c
+++ b/src/emu/cpu/mc68hc11/mc68hc11.c
@@ -595,4 +595,3 @@ void mc68hc11_cpu_device::execute_run()
(this->*hc11_optable[op])();
}
}
-
diff --git a/src/emu/cpu/mcs48/mcs48.c b/src/emu/cpu/mcs48/mcs48.c
index ce3783120f4..36156cbf7b0 100644
--- a/src/emu/cpu/mcs48/mcs48.c
+++ b/src/emu/cpu/mcs48/mcs48.c
@@ -1330,4 +1330,3 @@ void mcs48_cpu_device::execute_set_input(int inputnum, int state)
break;
}
}
-
diff --git a/src/emu/cpu/mcs48/mcs48.h b/src/emu/cpu/mcs48/mcs48.h
index b95ea95b405..c1d19bc6c30 100644
--- a/src/emu/cpu/mcs48/mcs48.h
+++ b/src/emu/cpu/mcs48/mcs48.h
@@ -484,9 +484,9 @@ public:
i8021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
- // device_execute_interface overrides
- virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 30 - 1) / 30; }
- virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 30); }
+ // device_execute_interface overrides
+ virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 30 - 1) / 30; }
+ virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 30); }
};
class i8022_device : public mcs48_cpu_device
@@ -496,9 +496,9 @@ public:
i8022_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
protected:
- // device_execute_interface overrides
- virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 30 - 1) / 30; }
- virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 30); }
+ // device_execute_interface overrides
+ virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const { return (clocks + 30 - 1) / 30; }
+ virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const { return (cycles * 30); }
};
class i8035_device : public mcs48_cpu_device
diff --git a/src/emu/cpu/mcs51/mcs51.c b/src/emu/cpu/mcs51/mcs51.c
index 69369cbc8af..fc6bee9cfd7 100644
--- a/src/emu/cpu/mcs51/mcs51.c
+++ b/src/emu/cpu/mcs51/mcs51.c
@@ -2506,4 +2506,3 @@ offs_t ds5002fp_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8
extern CPU_DISASSEMBLE( ds5002fp );
return CPU_DISASSEMBLE_NAME(ds5002fp)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/minx/minx.c b/src/emu/cpu/minx/minx.c
index 6c02873a54b..f33dcadc26a 100644
--- a/src/emu/cpu/minx/minx.c
+++ b/src/emu/cpu/minx/minx.c
@@ -236,4 +236,3 @@ offs_t minx_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8
extern CPU_DISASSEMBLE( minx );
return CPU_DISASSEMBLE_NAME(minx)(this, buffer, pc, oprom, opram, options);
}
-
diff --git a/src/emu/cpu/minx/minx.h b/src/emu/cpu/minx/minx.h
index 34d61dcd519..90217e973ac 100644
--- a/src/emu/cpu/minx/minx.h
+++ b/src/emu/cpu/minx/minx.h
@@ -880,8 +880,8 @@ private:
static const op_func insnminx_CE[256];
static const int insnminx_cycles_CE[256];
- static const op_func insnminx_CF[256];
- static const int insnminx_cycles_CF[256];
+ static const op_func insnminx_CF[256];
+ static const int insnminx_cycles_CF[256];
};
diff --git a/src/emu/cpu/mips/mips3drc.c b/src/emu/cpu/mips/mips3drc.c
index bc0bb9c485d..f226b4c924f 100644
--- a/src/emu/cpu/mips/mips3drc.c
+++ b/src/emu/cpu/mips/mips3drc.c
@@ -3934,7 +3934,7 @@ CPU_GET_INFO( r4700le_drc )
/* --- the following bits of info are returned as NULL-terminated strings --- */
case CPUINFO_STR_NAME: strcpy(info->s, "R4700 (little) DRC"); break;
case CPUINFO_STR_SHORTNAME: strcpy(info->s, "r4700le_drc"); break;
-
+
/* --- everything else is handled generically --- */
default: CPU_GET_INFO_CALL(mips3); break;
}
@@ -4124,4 +4124,3 @@ DEFINE_LEGACY_CPU_DEVICE(QED5271LE_DRC, qed5271le_drc);
DEFINE_LEGACY_CPU_DEVICE(RM7000BE_DRC, rm7000be_drc);
DEFINE_LEGACY_CPU_DEVICE(RM7000LE_DRC, rm7000le_drc);
-
diff --git a/src/emu/cpu/mn10200/mn10200.c b/src/emu/cpu/mn10200/mn10200.c
index 33cbeabc7ef..662183241d4 100644
--- a/src/emu/cpu/mn10200/mn10200.c
+++ b/src/emu/cpu/mn10200/mn10200.c
@@ -2436,5 +2436,3 @@ offs_t mn10200_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *
extern CPU_DISASSEMBLE( mn10200 );
return CPU_DISASSEMBLE_NAME(mn10200)(this, buffer, pc, oprom, opram, options);
}
-
-
diff --git a/src/emu/cpu/nec/v25.c b/src/emu/cpu/nec/v25.c
index 5ccb57fdfd0..e302dccc0ca 100644
--- a/src/emu/cpu/nec/v25.c
+++ b/src/emu/cpu/nec/v25.c
@@ -711,7 +711,7 @@ static CPU_GET_INFO( v25v35 )
case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &nec_state->icount; break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case CPUINFO_STR_NAME: strcpy(info->s, "NEC"); break;
+ case CPUINFO_STR_NAME: strcpy(info->s, "NEC"); break;
case CPUINFO_STR_FAMILY: strcpy(info->s, "NEC V-Series"); break;
case CPUINFO_STR_VERSION: strcpy(info->s, "2.0"); break;
case CPUINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
diff --git a/src/emu/cpu/pic16c5x/pic16c5x.c b/src/emu/cpu/pic16c5x/pic16c5x.c
index 3ab526f9a28..6dca0b2fe20 100644
--- a/src/emu/cpu/pic16c5x/pic16c5x.c
+++ b/src/emu/cpu/pic16c5x/pic16c5x.c
@@ -703,78 +703,78 @@ void pic16c5x_device::xorwf()
const pic16c5x_device::pic16c5x_opcode pic16c5x_device::s_opcode_main[256]=
{
/*00*/ {1, &pic16c5x_device::nop },{0, &pic16c5x_device::illegal },{1, &pic16c5x_device::movwf },{1, &pic16c5x_device::movwf },
- {1, &pic16c5x_device::clrw },{0, &pic16c5x_device::illegal },{1, &pic16c5x_device::clrf },{1, &pic16c5x_device::clrf },
+ {1, &pic16c5x_device::clrw },{0, &pic16c5x_device::illegal },{1, &pic16c5x_device::clrf },{1, &pic16c5x_device::clrf },
/*08*/ {1, &pic16c5x_device::subwf },{1, &pic16c5x_device::subwf },{1, &pic16c5x_device::subwf },{1, &pic16c5x_device::subwf },
- {1, &pic16c5x_device::decf },{1, &pic16c5x_device::decf },{1, &pic16c5x_device::decf },{1, &pic16c5x_device::decf },
+ {1, &pic16c5x_device::decf },{1, &pic16c5x_device::decf },{1, &pic16c5x_device::decf },{1, &pic16c5x_device::decf },
/*10*/ {1, &pic16c5x_device::iorwf },{1, &pic16c5x_device::iorwf },{1, &pic16c5x_device::iorwf },{1, &pic16c5x_device::iorwf },
- {1, &pic16c5x_device::andwf },{1, &pic16c5x_device::andwf },{1, &pic16c5x_device::andwf },{1, &pic16c5x_device::andwf },
+ {1, &pic16c5x_device::andwf },{1, &pic16c5x_device::andwf },{1, &pic16c5x_device::andwf },{1, &pic16c5x_device::andwf },
/*18*/ {1, &pic16c5x_device::xorwf },{1, &pic16c5x_device::xorwf },{1, &pic16c5x_device::xorwf },{1, &pic16c5x_device::xorwf },
- {1, &pic16c5x_device::addwf },{1, &pic16c5x_device::addwf },{1, &pic16c5x_device::addwf },{1, &pic16c5x_device::addwf },
+ {1, &pic16c5x_device::addwf },{1, &pic16c5x_device::addwf },{1, &pic16c5x_device::addwf },{1, &pic16c5x_device::addwf },
/*20*/ {1, &pic16c5x_device::movf },{1, &pic16c5x_device::movf },{1, &pic16c5x_device::movf },{1, &pic16c5x_device::movf },
- {1, &pic16c5x_device::comf },{1, &pic16c5x_device::comf },{1, &pic16c5x_device::comf },{1, &pic16c5x_device::comf },
+ {1, &pic16c5x_device::comf },{1, &pic16c5x_device::comf },{1, &pic16c5x_device::comf },{1, &pic16c5x_device::comf },
/*28*/ {1, &pic16c5x_device::incf },{1, &pic16c5x_device::incf },{1, &pic16c5x_device::incf },{1, &pic16c5x_device::incf },
- {1, &pic16c5x_device::decfsz },{1, &pic16c5x_device::decfsz },{1, &pic16c5x_device::decfsz },{1, &pic16c5x_device::decfsz },
+ {1, &pic16c5x_device::decfsz },{1, &pic16c5x_device::decfsz },{1, &pic16c5x_device::decfsz },{1, &pic16c5x_device::decfsz },
/*30*/ {1, &pic16c5x_device::rrf },{1, &pic16c5x_device::rrf },{1, &pic16c5x_device::rrf },{1, &pic16c5x_device::rrf },
- {1, &pic16c5x_device::rlf },{1, &pic16c5x_device::rlf },{1, &pic16c5x_device::rlf },{1, &pic16c5x_device::rlf },
+ {1, &pic16c5x_device::rlf },{1, &pic16c5x_device::rlf },{1, &pic16c5x_device::rlf },{1, &pic16c5x_device::rlf },
/*38*/ {1, &pic16c5x_device::swapf },{1, &pic16c5x_device::swapf },{1, &pic16c5x_device::swapf },{1, &pic16c5x_device::swapf },
- {1, &pic16c5x_device::incfsz },{1, &pic16c5x_device::incfsz },{1, &pic16c5x_device::incfsz },{1, &pic16c5x_device::incfsz },
+ {1, &pic16c5x_device::incfsz },{1, &pic16c5x_device::incfsz },{1, &pic16c5x_device::incfsz },{1, &pic16c5x_device::incfsz },
/*40*/ {1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },
- {1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },
+ {1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },
/*48*/ {1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },
- {1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },
+ {1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },{1, &pic16c5x_device::bcf },
/*50*/ {1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },
- {1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },
+ {1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },
/*58*/ {1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },
- {1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },
+ {1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },{1, &pic16c5x_device::bsf },
/*60*/ {1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },
- {1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },
+ {1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },
/*68*/ {1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },
- {1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },
+ {1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },{1, &pic16c5x_device::btfsc },
/*70*/ {1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },
- {1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },
+ {1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },
/*78*/ {1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },
- {1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },
+ {1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },{1, &pic16c5x_device::btfss },
/*80*/ {2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },
- {2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },
+ {2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },
/*88*/ {2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },
- {2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },
+ {2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },{2, &pic16c5x_device::retlw },
/*90*/ {2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },
- {2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },
+ {2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },
/*98*/ {2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },
- {2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },
+ {2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },{2, &pic16c5x_device::call },
/*A0*/ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
- {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
+ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
/*A8*/ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
- {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
+ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
/*B0*/ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
- {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
+ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
/*B8*/ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
- {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
+ {2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },{2, &pic16c5x_device::goto_op },
/*C0*/ {1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },
- {1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },
+ {1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },
/*C8*/ {1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },
- {1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },
+ {1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },{1, &pic16c5x_device::movlw },
/*D0*/ {1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },
- {1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },
+ {1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },
/*D8*/ {1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },
- {1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },
+ {1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },{1, &pic16c5x_device::iorlw },
/*E0*/ {1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },
- {1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },
+ {1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },
/*E8*/ {1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },
- {1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },
+ {1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },{1, &pic16c5x_device::andlw },
/*F0*/ {1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },
- {1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },
+ {1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },
/*F8*/ {1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },
- {1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw }
+ {1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw },{1, &pic16c5x_device::xorlw }
};
const pic16c5x_device::pic16c5x_opcode pic16c5x_device::s_opcode_00x[16]=
{
/*00*/ {1, &pic16c5x_device::nop },{0, &pic16c5x_device::illegal },{1, &pic16c5x_device::option },{1, &pic16c5x_device::sleepic },
- {1, &pic16c5x_device::clrwdt },{1, &pic16c5x_device::tris },{1, &pic16c5x_device::tris },{1, &pic16c5x_device::tris },
+ {1, &pic16c5x_device::clrwdt },{1, &pic16c5x_device::tris },{1, &pic16c5x_device::tris },{1, &pic16c5x_device::tris },
/*08*/ {0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },
- {0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal }
+ {0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal },{0, &pic16c5x_device::illegal }
};
@@ -1102,4 +1102,3 @@ void pic16c5x_device::execute_run()
} while (m_icount > 0);
}
-
diff --git a/src/emu/cpu/pic16c62x/pic16c62x.c b/src/emu/cpu/pic16c62x/pic16c62x.c
index 37ed67b3703..6a4c239e2fb 100644
--- a/src/emu/cpu/pic16c62x/pic16c62x.c
+++ b/src/emu/cpu/pic16c62x/pic16c62x.c
@@ -1176,4 +1176,3 @@ void pic16c62x_device::device_reset()
pic16c62x_reset_regs();
SET(STATUS, (TO_FLAG | PD_FLAG));
}
-
diff --git a/src/emu/cpu/pic16c62x/pic16c62x.h b/src/emu/cpu/pic16c62x/pic16c62x.h
index 4e2e1ab3e89..a0e924b19de 100644
--- a/src/emu/cpu/pic16c62x/pic16c62x.h
+++ b/src/emu/cpu/pic16c62x/pic16c62x.h
@@ -227,8 +227,8 @@ public:
class pic16cr620a_device : public pic16c62x_device
{
public:
- // construction/destruction
- pic16cr620a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ // construction/destruction
+ pic16cr620a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
}*/;
class pic16c621_device : public pic16c62x_device
diff --git a/src/emu/cpu/pps4/pps4.c b/src/emu/cpu/pps4/pps4.c
index 3379dd2d413..84ace009839 100644
--- a/src/emu/cpu/pps4/pps4.c
+++ b/src/emu/cpu/pps4/pps4.c
@@ -367,4 +367,3 @@ void pps4_device::device_reset()
m_SB.d = 0;
m_B.d = 0;
}
-
diff --git a/src/emu/cpu/psx/rcnt.h b/src/emu/cpu/psx/rcnt.h
index d1477a91e5c..336109dd5d9 100644
--- a/src/emu/cpu/psx/rcnt.h
+++ b/src/emu/cpu/psx/rcnt.h
@@ -65,7 +65,7 @@ private:
UINT16 root_current( int n_counter );
int root_target( int n_counter );
void root_timer_adjust( int n_counter );
-
+
devcb2_write_line m_irq0_handler;
devcb2_write_line m_irq1_handler;
devcb2_write_line m_irq2_handler;
diff --git a/src/emu/cpu/rsp/rspdrc.c b/src/emu/cpu/rsp/rspdrc.c
index 479d10d3786..eaa62b8d124 100644
--- a/src/emu/cpu/rsp/rspdrc.c
+++ b/src/emu/cpu/rsp/rspdrc.c
@@ -6167,4 +6167,3 @@ CPU_GET_INFO( rsp_drc )
}
DEFINE_LEGACY_CPU_DEVICE(RSP_DRC, rsp_drc);
-
diff --git a/src/emu/cpu/s2650/s2650.c b/src/emu/cpu/s2650/s2650.c
index a0ad6bc71c7..64b71fc4e0a 100644
--- a/src/emu/cpu/s2650/s2650.c
+++ b/src/emu/cpu/s2650/s2650.c
@@ -1564,4 +1564,3 @@ void s2650_device::execute_run()
}
} while( m_icount > 0 );
}
-
diff --git a/src/emu/cpu/sh2/sh2comn.c b/src/emu/cpu/sh2/sh2comn.c
index d90363c0f83..e866a83e910 100644
--- a/src/emu/cpu/sh2/sh2comn.c
+++ b/src/emu/cpu/sh2/sh2comn.c
@@ -17,11 +17,11 @@
INLINE sh2_state *GET_SH2(device_t *dev)
{
- if (dev->machine().options().drc()) {
+ if (dev->machine().options().drc()) {
return *(sh2_state **)downcast<legacy_cpu_device *>(dev)->token();
- } else {
+ } else {
return (sh2_state *)downcast<legacy_cpu_device *>(dev)->token();
- }
+ }
}
static const int div_tab[4] = { 3, 5, 7, 0 };
@@ -844,7 +844,7 @@ void sh2_set_irq_line(sh2_state *sh2, int irqline, int state)
sh2_exception(sh2, "Set IRQ line", 16);
if (sh2->isdrc)
- sh2->pending_nmi = 1;
+ sh2->pending_nmi = 1;
}
}
else
diff --git a/src/emu/cpu/sh2/sh2comn.h b/src/emu/cpu/sh2/sh2comn.h
index 64cadf3b965..6a1218ae2b5 100644
--- a/src/emu/cpu/sh2/sh2comn.h
+++ b/src/emu/cpu/sh2/sh2comn.h
@@ -117,7 +117,7 @@ struct sh2_state
UINT32 irqsr; // IRQ-time old SR for DRC
UINT32 target; // target for jmp/jsr/etc so the delay slot can't kill it
irq_entry irq_queue[16];
-
+
bool isdrc;
int pcfsel; // last pcflush entry set
diff --git a/src/emu/cpu/sh2/sh2fe.c b/src/emu/cpu/sh2/sh2fe.c
index e5981966ca6..688b729c8ff 100644
--- a/src/emu/cpu/sh2/sh2fe.c
+++ b/src/emu/cpu/sh2/sh2fe.c
@@ -760,4 +760,3 @@ bool sh2_frontend::describe_group_12(opcode_desc &desc, const opcode_desc *prev,
return false;
}
-
diff --git a/src/emu/cpu/tlcs900/tlcs900.c b/src/emu/cpu/tlcs900/tlcs900.c
index db55b567bc9..ac9f4e09f56 100644
--- a/src/emu/cpu/tlcs900/tlcs900.c
+++ b/src/emu/cpu/tlcs900/tlcs900.c
@@ -2168,4 +2168,3 @@ void tmp95c063_device::execute_set_input(int input, int level)
}
m_check_irqs = 1;
}
-
diff --git a/src/emu/cpu/tms32082/dis_mp.c b/src/emu/cpu/tms32082/dis_mp.c
index 6c50536ce0a..0bcb5a79788 100644
--- a/src/emu/cpu/tms32082/dis_mp.c
+++ b/src/emu/cpu/tms32082/dis_mp.c
@@ -16,10 +16,10 @@ static const char *BCND_CONDITION[32] =
static const char *BITNUM_CONDITION[32] =
{
- "eq.b", "ne.b", "gt.b", "le.b", "lt.b", "ge.b", "hi.b", "ls.b",
- "lo.b", "hs.b", "eq.h", "ne.h", "gt.h", "le.h", "lt.h", "ge.h",
- "hi.h", "ls.h", "lo.h", "hs.h", "eq.w", "ne.w", "gt.w", "le.w",
- "lt.w", "ge.w", "hi.w", "ls.w", "lo.w", "hs.w", "?", "?",
+ "eq.b", "ne.b", "gt.b", "le.b", "lt.b", "ge.b", "hi.b", "ls.b",
+ "lo.b", "hs.b", "eq.h", "ne.h", "gt.h", "le.h", "lt.h", "ge.h",
+ "hi.h", "ls.h", "lo.h", "hs.h", "eq.w", "ne.w", "gt.w", "le.w",
+ "lt.w", "ge.w", "hi.w", "ls.w", "lo.w", "hs.w", "?", "?",
};
static const char *MEMOP_S[2] =
@@ -156,8 +156,8 @@ static char* format_vector_op(UINT32 op, UINT32 imm32)
b += sprintf(b, "vrnd.%s%s 0x%08X, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[pd4], imm32, rs);
break;
- case 0xca: b += sprintf(b, "vrnd.%s%s R%d, R%d", FLOATOP_PRECISION[2 + p1], FLOATOP_PRECISION[pd2],src1, rs); break;
- case 0xcb: b += sprintf(b, "vrnd.%s%s 0x%08X, R%d", FLOATOP_PRECISION[2 + p1], FLOATOP_PRECISION[pd2], imm32, rs); break;
+ case 0xca: b += sprintf(b, "vrnd.%s%s R%d, R%d", FLOATOP_PRECISION[2 + p1], FLOATOP_PRECISION[pd2],src1, rs); break;
+ case 0xcb: b += sprintf(b, "vrnd.%s%s 0x%08X, R%d", FLOATOP_PRECISION[2 + p1], FLOATOP_PRECISION[pd2], imm32, rs); break;
case 0xcc: case 0xdc:
b += sprintf(b, "vmac.ss%s R%d, R%d, %s, %s", FLOATOP_PRECISION[(op >> 9) & 1], src1, rs, z ? "0" : ACC_SEL[acc], (regdest && rd == 0) ? ACC_SEL[acc] : dest);
@@ -172,7 +172,7 @@ static char* format_vector_op(UINT32 op, UINT32 imm32)
b += sprintf(b, "vmsc.ss%s 0x%08X, R%d, %s, %s", FLOATOP_PRECISION[(op >> 9) & 1], imm32, rs, z ? "0" : ACC_SEL[acc], (regdest && rd == 0) ? ACC_SEL[acc] : dest);
break;
- default: b += sprintf(b, "?"); break;
+ default: b += sprintf(b, "?"); break;
}
// align the line end
@@ -183,17 +183,17 @@ static char* format_vector_op(UINT32 op, UINT32 imm32)
{
b += sprintf(b, " ");
}
- }
+ }
// optional load/store op
switch (vector_ls_bits)
{
- case 0x01: b += sprintf(b, "|| vst.s R%d", rd); break;
- case 0x03: b += sprintf(b, "|| vst.d R%d", rd); break;
- case 0x04: b += sprintf(b, "|| vld0.s R%d", rd); break;
- case 0x05: b += sprintf(b, "|| vld1.s R%d", rd); break;
- case 0x06: b += sprintf(b, "|| vld0.d R%d", rd); break;
- case 0x07: b += sprintf(b, "|| vld1.d R%d", rd); break;
+ case 0x01: b += sprintf(b, "|| vst.s R%d", rd); break;
+ case 0x03: b += sprintf(b, "|| vst.d R%d", rd); break;
+ case 0x04: b += sprintf(b, "|| vld0.s R%d", rd); break;
+ case 0x05: b += sprintf(b, "|| vld1.s R%d", rd); break;
+ case 0x06: b += sprintf(b, "|| vld0.d R%d", rd); break;
+ case 0x07: b += sprintf(b, "|| vld1.d R%d", rd); break;
}
return buffer;
@@ -226,30 +226,30 @@ static offs_t tms32082_disasm_mp(char *buffer, offs_t pc, const UINT8 *oprom)
switch (subop)
{
- case 0x00: print("illop0 "); break;
- case 0x01: print("trap %d", UIMM15(uimm15)); break;
- case 0x02: print("cmnd 0x%04X", UIMM15(uimm15)); break;
- case 0x04: print("rdcr %s, R%d", get_creg_name(UIMM15(uimm15)), rd); break;
- case 0x05: print("swcr R%d, %s, R%d", rd, get_creg_name(UIMM15(uimm15)), rs); break;
- case 0x06: print("brcr %s", get_creg_name(UIMM15(uimm15))); break;
- case 0x08: print("shift%s.dz %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x09: print("shift%s.dm %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x0a: print("shift%s.ds %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x0b: print("shift%s.ez %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x0c: print("shift%s.em %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x0d: print("shift%s.es %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x0e: print("shift%s.iz %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x0f: print("shift%s.im %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
- case 0x11: print("and 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x12: print("and.tf 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x14: print("and.ft 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x16: print("xor 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x17: print("or 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x18: print("and.ff 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x19: print("xnor 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x1b: print("or.tf 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x1d: print("or.ft 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
- case 0x1e: print("or.ff 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x00: print("illop0 "); break;
+ case 0x01: print("trap %d", UIMM15(uimm15)); break;
+ case 0x02: print("cmnd 0x%04X", UIMM15(uimm15)); break;
+ case 0x04: print("rdcr %s, R%d", get_creg_name(UIMM15(uimm15)), rd); break;
+ case 0x05: print("swcr R%d, %s, R%d", rd, get_creg_name(UIMM15(uimm15)), rs); break;
+ case 0x06: print("brcr %s", get_creg_name(UIMM15(uimm15))); break;
+ case 0x08: print("shift%s.dz %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x09: print("shift%s.dm %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x0a: print("shift%s.ds %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x0b: print("shift%s.ez %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x0c: print("shift%s.em %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x0d: print("shift%s.es %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x0e: print("shift%s.iz %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x0f: print("shift%s.im %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
+ case 0x11: print("and 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x12: print("and.tf 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x14: print("and.ft 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x16: print("xor 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x17: print("or 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x18: print("and.ff 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x19: print("xnor 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x1b: print("or.tf 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x1d: print("or.ft 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
+ case 0x1e: print("or.ff 0x%04X, R%d, R%d", UIMM15(uimm15), rs, rd); break;
case 0x24: case 0x20:
print("ld.b 0x%04X(R%d%s), R%d", UIMM15(uimm15), rs, MEMOP_M[m], rd);
@@ -283,23 +283,23 @@ static offs_t tms32082_disasm_mp(char *buffer, offs_t pc, const UINT8 *oprom)
print("st.d R%d, 0x%04X(R%d%s)", rd, UIMM15(uimm15), rs, MEMOP_M[m]);
break;
- case 0x40: print("bsr 0x%08X, R%d", pc + (SIMM15(uimm15) * 4), link); break;
- case 0x41: print("bsr.a 0x%08X, R%d", pc + (SIMM15(uimm15) * 4), link); break;
- case 0x44: print("jsr 0x%04X(R%d), R%d", SIMM15(uimm15), rs, link); break;
- case 0x45: print("jsr.a 0x%04X(R%d), R%d", SIMM15(uimm15), rs, link); break;
- case 0x48: print("bbz 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x49: print("bbz.a 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x4a: print("bbo 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x4b: print("bbo.a 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x4c: print("bcnd 0x%08X, R%d, %s", pc + (SIMM15(uimm15) * 4), rs, BCND_CONDITION[rd]); break;
- case 0x4d: print("bcnd.a 0x%08X, R%d, %s", pc + (SIMM15(uimm15) * 4), rs, BCND_CONDITION[rd]); break;
- case 0x50: print("cmp 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
- case 0x58: print("add 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
- case 0x59: print("addu 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
- case 0x5a: print("sub 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
- case 0x5b: print("subu 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
-
- default: print("?"); break;
+ case 0x40: print("bsr 0x%08X, R%d", pc + (SIMM15(uimm15) * 4), link); break;
+ case 0x41: print("bsr.a 0x%08X, R%d", pc + (SIMM15(uimm15) * 4), link); break;
+ case 0x44: print("jsr 0x%04X(R%d), R%d", SIMM15(uimm15), rs, link); break;
+ case 0x45: print("jsr.a 0x%04X(R%d), R%d", SIMM15(uimm15), rs, link); break;
+ case 0x48: print("bbz 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x49: print("bbz.a 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x4a: print("bbo 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x4b: print("bbo.a 0x%08X, R%d, %s (%d)", pc + (SIMM15(uimm15) * 4), rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x4c: print("bcnd 0x%08X, R%d, %s", pc + (SIMM15(uimm15) * 4), rs, BCND_CONDITION[rd]); break;
+ case 0x4d: print("bcnd.a 0x%08X, R%d, %s", pc + (SIMM15(uimm15) * 4), rs, BCND_CONDITION[rd]); break;
+ case 0x50: print("cmp 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
+ case 0x58: print("add 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
+ case 0x59: print("addu 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
+ case 0x5a: print("sub 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
+ case 0x5b: print("subu 0x%08X, R%d, R%d", SIMM15(uimm15), rs, rd); break;
+
+ default: print("?"); break;
}
break;
}
@@ -324,16 +324,16 @@ static offs_t tms32082_disasm_mp(char *buffer, offs_t pc, const UINT8 *oprom)
switch (subop)
{
- case 0x02: print("trap %d", src1); break;
- case 0x03: print("trap %d", imm32); break;
- case 0x04: print("cmnd R%d", src1); break;
- case 0x05: print("cmnd 0x%08X", imm32); break;
- case 0x08: print("rdcr R%d, R%d,", src1, rd); break;
- case 0x09: print("rdcr %s, R%d", get_creg_name(imm32), rd); break;
- case 0x0a: print("swcr R%d, R%d, R%d", rd, src1, rs); break;
- case 0x0b: print("swcr R%d, %s, R%d", rd, get_creg_name(imm32), rs); break;
- case 0x0c: print("brcr R%d", src1); break;
- case 0x0d: print("brcr %s", get_creg_name(imm32)); break;
+ case 0x02: print("trap %d", src1); break;
+ case 0x03: print("trap %d", imm32); break;
+ case 0x04: print("cmnd R%d", src1); break;
+ case 0x05: print("cmnd 0x%08X", imm32); break;
+ case 0x08: print("rdcr R%d, R%d,", src1, rd); break;
+ case 0x09: print("rdcr %s, R%d", get_creg_name(imm32), rd); break;
+ case 0x0a: print("swcr R%d, R%d, R%d", rd, src1, rs); break;
+ case 0x0b: print("swcr R%d, %s, R%d", rd, get_creg_name(imm32), rs); break;
+ case 0x0c: print("brcr R%d", src1); break;
+ case 0x0d: print("brcr %s", get_creg_name(imm32)); break;
case 0x10: print("shift%s.dz %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
case 0x12: print("shift%s.dm %d, %d, R%d, R%d", (op & (1 << 10)) ? "r" : "l", rotate, endmask, rs, rd); break;
@@ -434,69 +434,69 @@ static offs_t tms32082_disasm_mp(char *buffer, offs_t pc, const UINT8 *oprom)
print("dcache 0x%08X(R%d)", imm32, rs);
break;
- case 0x80: print("bsr R%d, R%d", src1, link); break;
- case 0x81: print("bsr 0x%08X, R%d", imm32, link); break;
- case 0x82: print("bsr.a R%d, R%d", src1, rd); break;
- case 0x83: print("bsr.a 0x%08X, R%d", imm32, link); break;
- case 0x88: print("jsr R%d, R%d", src1, link); break;
- case 0x89: print("jsr 0x%08X, R%d", imm32, link); break;
- case 0x8a: print("jsr.a R%d, R%d", src1, link); break;
- case 0x8b: print("jsr.a 0x%08X, R%d", imm32, link); break;
- case 0x90: print("bbz R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x91: print("bbz 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x92: print("bbz.a R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x93: print("bbz.a 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x94: print("bbo R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x95: print("bbo 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x96: print("bbo.a R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x97: print("bbo.a 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
- case 0x98: print("bcnd R%d, R%d, %s", src1, rs, BCND_CONDITION[rd]); break;
- case 0x99: print("bcnd 0x%08X, R%d, %s", imm32, rs, BCND_CONDITION[rd]); break;
- case 0x9a: print("bcnd.a R%d, R%d, %s", src1, rs, BCND_CONDITION[rd]); break;
- case 0x9b: print("bcnd.a 0x%08X, R%d, %s", imm32, rs, BCND_CONDITION[rd]); break;
- case 0xa0: print("cmp R%d, R%d, R%d", src1, rs, rd); break;
- case 0xa1: print("cmp 0x%08X, R%d, R%d", imm32, rs, rd); break;
- case 0xb0: print("add R%d, R%d, R%d", src1, rs, rd); break;
- case 0xb1: print("add 0x%08X, R%d, R%d", imm32, rs, rd); break;
- case 0xb2: print("addu R%d, R%d, R%d", src1, rs, rd); break;
- case 0xb3: print("addu 0x%08X, R%d, R%d", imm32, rs, rd); break;
- case 0xb4: print("sub R%d, R%d, R%d", src1, rs, rd); break;
- case 0xb5: print("sub 0x%08X, R%d, R%d", imm32, rs, rd); break;
- case 0xb6: print("subu R%d, R%d, R%d", src1, rs, rd); break;
- case 0xb7: print("subu 0x%08X, R%d, R%d", imm32, rs, rd); break;
+ case 0x80: print("bsr R%d, R%d", src1, link); break;
+ case 0x81: print("bsr 0x%08X, R%d", imm32, link); break;
+ case 0x82: print("bsr.a R%d, R%d", src1, rd); break;
+ case 0x83: print("bsr.a 0x%08X, R%d", imm32, link); break;
+ case 0x88: print("jsr R%d, R%d", src1, link); break;
+ case 0x89: print("jsr 0x%08X, R%d", imm32, link); break;
+ case 0x8a: print("jsr.a R%d, R%d", src1, link); break;
+ case 0x8b: print("jsr.a 0x%08X, R%d", imm32, link); break;
+ case 0x90: print("bbz R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x91: print("bbz 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x92: print("bbz.a R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x93: print("bbz.a 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x94: print("bbo R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x95: print("bbo 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x96: print("bbo.a R%d, R%d, %s (%d)", src1, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x97: print("bbo.a 0x%08X, R%d, %s (%d)", imm32, rs, BITNUM_CONDITION[bitnum], bitnum); break;
+ case 0x98: print("bcnd R%d, R%d, %s", src1, rs, BCND_CONDITION[rd]); break;
+ case 0x99: print("bcnd 0x%08X, R%d, %s", imm32, rs, BCND_CONDITION[rd]); break;
+ case 0x9a: print("bcnd.a R%d, R%d, %s", src1, rs, BCND_CONDITION[rd]); break;
+ case 0x9b: print("bcnd.a 0x%08X, R%d, %s", imm32, rs, BCND_CONDITION[rd]); break;
+ case 0xa0: print("cmp R%d, R%d, R%d", src1, rs, rd); break;
+ case 0xa1: print("cmp 0x%08X, R%d, R%d", imm32, rs, rd); break;
+ case 0xb0: print("add R%d, R%d, R%d", src1, rs, rd); break;
+ case 0xb1: print("add 0x%08X, R%d, R%d", imm32, rs, rd); break;
+ case 0xb2: print("addu R%d, R%d, R%d", src1, rs, rd); break;
+ case 0xb3: print("addu 0x%08X, R%d, R%d", imm32, rs, rd); break;
+ case 0xb4: print("sub R%d, R%d, R%d", src1, rs, rd); break;
+ case 0xb5: print("sub 0x%08X, R%d, R%d", imm32, rs, rd); break;
+ case 0xb6: print("subu R%d, R%d, R%d", src1, rs, rd); break;
+ case 0xb7: print("subu 0x%08X, R%d, R%d", imm32, rs, rd); break;
case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5:
case 0xc6: case 0xd6: case 0xc7: case 0xd7: case 0xc8: case 0xd8: case 0xc9: case 0xd9:
- case 0xca: case 0xcb: case 0xcc: case 0xdc: case 0xcd: case 0xdd: case 0xce: case 0xde:
+ case 0xca: case 0xcb: case 0xcc: case 0xdc: case 0xcd: case 0xdd: case 0xce: case 0xde:
case 0xcf: case 0xdf:
{
print("%s", format_vector_op(op, imm32));
break;
}
- case 0xe0: print("fadd.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
- case 0xe1: print("fadd.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
- case 0xe2: print("fsub.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
- case 0xe3: print("fsub.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
- case 0xe4: print("fmpy.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
- case 0xe5: print("fmpy.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
- case 0xe6: print("fdiv.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
- case 0xe7: print("fdiv.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
- case 0xe8: print("frnd%s.%s%s R%d, R%d", FLOATOP_ROUND[rndmode], FLOATOP_PRECISION[p1], FLOATOP_PRECISION[pd], src1, rd); break;
- case 0xe9: print("frnd%s.%s%s 0x%08X, R%d", FLOATOP_ROUND[rndmode], FLOATOP_PRECISION[p1], FLOATOP_PRECISION[pd], imm32, rd); break;
- case 0xea: print("fcmp R%d, R%d, R%d", src1, rs, rd); break;
- case 0xeb: print("fcmp 0x%08X, R%d, R%d", imm32, rs, rd); break;
- case 0xee: print("fsqrt R%d, R%d", src1, rd); break;
- case 0xef: print("fsqrt 0x%08X, R%d", imm32, rd); break;
- case 0xf0: print("lmo R%d, R%d", rs, rd); break;
- case 0xf2: print("rmo R%d, R%d", rs, rd); break;
- case 0xfc: print("estop "); break;
-
+ case 0xe0: print("fadd.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
+ case 0xe1: print("fadd.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
+ case 0xe2: print("fsub.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
+ case 0xe3: print("fsub.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
+ case 0xe4: print("fmpy.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
+ case 0xe5: print("fmpy.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
+ case 0xe6: print("fdiv.%s%s%s R%d, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], src1, rs, rd); break;
+ case 0xe7: print("fdiv.%s%s%s 0x%08X, R%d, R%d", FLOATOP_PRECISION[p1], FLOATOP_PRECISION[p2], FLOATOP_PRECISION[pd], imm32, rs, rd); break;
+ case 0xe8: print("frnd%s.%s%s R%d, R%d", FLOATOP_ROUND[rndmode], FLOATOP_PRECISION[p1], FLOATOP_PRECISION[pd], src1, rd); break;
+ case 0xe9: print("frnd%s.%s%s 0x%08X, R%d", FLOATOP_ROUND[rndmode], FLOATOP_PRECISION[p1], FLOATOP_PRECISION[pd], imm32, rd); break;
+ case 0xea: print("fcmp R%d, R%d, R%d", src1, rs, rd); break;
+ case 0xeb: print("fcmp 0x%08X, R%d, R%d", imm32, rs, rd); break;
+ case 0xee: print("fsqrt R%d, R%d", src1, rd); break;
+ case 0xef: print("fsqrt 0x%08X, R%d", imm32, rd); break;
+ case 0xf0: print("lmo R%d, R%d", rs, rd); break;
+ case 0xf2: print("rmo R%d, R%d", rs, rd); break;
+ case 0xfc: print("estop "); break;
+
case 0xfe: case 0xff:
print("illopF ");
break;
- default: print("?"); break;
+ default: print("?"); break;
}
break;
}
diff --git a/src/emu/cpu/tms32082/dis_pp.c b/src/emu/cpu/tms32082/dis_pp.c
index 01397ac39d3..cd63a3c2559 100644
--- a/src/emu/cpu/tms32082/dis_pp.c
+++ b/src/emu/cpu/tms32082/dis_pp.c
@@ -6,37 +6,37 @@
static const char *REG_NAMES[128] =
{
// 0 - 15
- "a0", "a1", "a2", "a3", "a4", "???", "a6", "a7",
- "a8", "a9", "a10", "a11", "a12", "???", "a14", "a15",
+ "a0", "a1", "a2", "a3", "a4", "???", "a6", "a7",
+ "a8", "a9", "a10", "a11", "a12", "???", "a14", "a15",
// 16 - 31
- "x0", "x1", "x2", "???", "???", "???", "???", "???",
- "x8", "x9", "x10", "???", "???", "???", "???", "???",
+ "x0", "x1", "x2", "???", "???", "???", "???", "???",
+ "x8", "x9", "x10", "???", "???", "???", "???", "???",
// 32 - 47
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
- "???", "sr", "mf", "???", "???", "???", "???", "???",
+ "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
+ "???", "sr", "mf", "???", "???", "???", "???", "???",
// 48 - 63
- "???", "???", "???", "???", "???", "???", "???", "???",
- "pc/call", "ipa/br", "ipe", "iprs", "inten", "intflg", "comm", "lctl",
+ "???", "???", "???", "???", "???", "???", "???", "???",
+ "pc/call", "ipa/br", "ipe", "iprs", "inten", "intflg", "comm", "lctl",
// 64 - 79
- "???", "???", "???", "???", "???", "???", "???", "???",
- "???", "???", "???", "???", "???", "???", "???", "???",
+ "???", "???", "???", "???", "???", "???", "???", "???",
+ "???", "???", "???", "???", "???", "???", "???", "???",
// 80 - 95
- "???", "???", "???", "???", "???", "???", "???", "???",
- "???", "???", "???", "???", "???", "???", "???", "???",
+ "???", "???", "???", "???", "???", "???", "???", "???",
+ "???", "???", "???", "???", "???", "???", "???", "???",
// 96 - 111
- "lc0", "lc1", "lc2", "???", "lr0", "lr1", "lr2", "???",
- "lrse0", "lrse1", "lrse2", "???", "lrs0", "lrs1", "lrs2", "???",
+ "lc0", "lc1", "lc2", "???", "lr0", "lr1", "lr2", "???",
+ "lrse0", "lrse1", "lrse2", "???", "lrs0", "lrs1", "lrs2", "???",
// 112 - 127
- "ls0", "ls1", "ls2", "???", "le0", "le1", "le2", "???",
- "???", "???", "???", "???", "tag0", "tag1", "tag2", "tag3"
+ "ls0", "ls1", "ls2", "???", "le0", "le1", "le2", "???",
+ "???", "???", "???", "???", "tag0", "tag1", "tag2", "tag3"
};
static const char *CONDITION_CODES[16] =
{
- "", "[p] ", "[ls] ", "[hi] ",
- "[lt] ", "[le] ", "[ge] ", "[gt] ",
- "[hs] ", "[lo] ", "[eq] ", "[ne] ",
- "[v] ", "[nv] ", "[n] ", "[nn] "
+ "", "[p] ", "[ls] ", "[hi] ",
+ "[lt] ", "[le] ", "[ge] ", "[gt] ",
+ "[hs] ", "[lo] ", "[eq] ", "[ne] ",
+ "[v] ", "[nv] ", "[n] ", "[nn] "
};
static const char *TRANSFER_SIZE[4] =
@@ -103,7 +103,7 @@ static void format_transfer(UINT64 op)
switch (gmode)
{
- case 0x00: // Format 7: Conditional DU || Conditional Move
+ case 0x00: // Format 7: Conditional DU || Conditional Move
{
int dstbank = (op >> 18) & 0xf;
int srcbank = (op >> 6) & 0xf;
@@ -117,14 +117,14 @@ static void format_transfer(UINT64 op)
b += sprintf(b, "%s = %s", REG_NAMES[dreg], REG_NAMES[sreg]);
break;
}
- case 0x01: // Format 8: Conditional DU ||Conditional Field Move
+ case 0x01: // Format 8: Conditional DU ||Conditional Field Move
{
int dstbank = (op >> 18) & 0xf;
int src = (op >> 10) & 0x7;
int dst = (op >> 3) & 0x7;
int itm = (op >> 22) & 0x3;
int size = (op >> 7) & 0x3;
- // int e = (op & (1 << 9));
+ // int e = (op & (1 << 9));
int dreg = (dstbank << 3) | dst;
int sreg = (4 << 3) | src;
@@ -133,7 +133,7 @@ static void format_transfer(UINT64 op)
b += sprintf(b, "%s = [%s%d]%s", REG_NAMES[dreg], TRANSFER_SIZE[size], itm, REG_NAMES[sreg]);
break;
}
- case 0x02: case 0x03: // Format 10: Conditional Non-D Data Unit
+ case 0x02: case 0x03: // Format 10: Conditional Non-D Data Unit
{
int as1bank = (op >> 6) & 0xf;
int adstbank = (op >> 18) & 0xf;
@@ -156,7 +156,7 @@ static void format_transfer(UINT64 op)
}
default:
{
- if (op & 0x4) // Format 9: Conditional DU || Conditional Global
+ if (op & 0x4) // Format 9: Conditional DU || Conditional Global
{
int bank = (op >> 18) & 0xf;
int le = ((op >> 16) & 2) | ((op >> 9) & 1);
@@ -178,7 +178,7 @@ static void format_transfer(UINT64 op)
case 3: b += sprintf(b, "%s = &%s%s", REG_NAMES[greg], TRANSFER_SIZE[size], format_address_mode(gmode, ga, s, gimx)); break;
}
}
- else // Format 5: Global (Long Offset)
+ else // Format 5: Global (Long Offset)
{
int bank = (op >> 18) & 0xf;
int le = ((op >> 16) & 2) | ((op >> 9) & 1);
@@ -194,7 +194,7 @@ static void format_transfer(UINT64 op)
// sign extend offset
if (s && (offset & 0x4000))
offset |= 0xffffc000;
-
+
switch (le)
{
case 0: b += sprintf(b, "&%s%s = %s", TRANSFER_SIZE[size], format_address_mode(gmode, ga, s, offset), REG_NAMES[greg]); break;
@@ -215,17 +215,17 @@ static void format_transfer(UINT64 op)
switch (mode)
{
- case 0x00: // Format 2: Move || Local
+ case 0x00: // Format 2: Move || Local
{
b += sprintf(b, "move||local <TODO>");
break;
}
- case 0x01: // Format 3: Field Move || Local
+ case 0x01: // Format 3: Field Move || Local
{
b += sprintf(b, "field move||local <TODO>");
break;
}
- case 0x02: case 0x03: // Format 6: Non-D DU || Local
+ case 0x02: case 0x03: // Format 6: Non-D DU || Local
{
int d = (op >> 32) & 0x7;
int s = (op & (1 << 28));
@@ -245,7 +245,7 @@ static void format_transfer(UINT64 op)
}
break;
}
- case 0x10: case 0x11: case 0x12: case 0x13: // Format 4: Local (Long Offset)
+ case 0x10: case 0x11: case 0x12: case 0x13: // Format 4: Local (Long Offset)
{
int d = (op >> 32) & 0x7;
int bank = (op >> 18) & 0xf;
@@ -277,7 +277,7 @@ static void format_transfer(UINT64 op)
}
break;
}
- case 0x14: case 0x15: case 0x16: case 0x17: // Format 1: Double Parallel
+ case 0x14: case 0x15: case 0x16: case 0x17: // Format 1: Double Parallel
case 0x18: case 0x19: case 0x1a: case 0x1b:
case 0x1c: case 0x1d: case 0x1e: case 0x1f:
{
@@ -329,83 +329,83 @@ static void format_transfer(UINT64 op)
static void format_alu_op(int aluop, int a, const char *dst_text, const char *a_text, const char *b_text, const char *c_text)
{
- if (a) // arithmetic
+ if (a) // arithmetic
{
int bits = (aluop & 1) | ((aluop >> 1) & 2) | ((aluop >> 2) & 4) | ((aluop >> 3) & 8);
switch (bits)
{
- case 1: print("%s = %s - %s<1<", dst_text, a_text, b_text); break;
- case 2: print("%s = %s + %s<0<", dst_text, a_text, b_text); break;
- case 3: print("%s = %s - %s", dst_text, a_text, c_text); break;
- case 4: print("%s = %s - %s>1>", dst_text, a_text, b_text); break;
- case 5: print("%s = %s - %s", dst_text, a_text, b_text); break;
- case 6: print("?"); break;
- case 7: print("%s = %s - %s>0>", dst_text, a_text, b_text); break;
- case 8: print("%s = %s + %s>0>", dst_text, a_text, b_text); break;
- case 9: print("?"); break;
- case 10: print("%s = %s + %s", dst_text, a_text, b_text); break;
- case 11: print("%s = %s + %s>1>", dst_text, a_text, b_text); break;
- case 12: print("%s = %s + %s", dst_text, a_text, c_text); break;
- case 13: print("%s = %s - %s<0<", dst_text, a_text, b_text); break;
- case 14: print("%s = %s + %s<1<", dst_text, a_text, b_text); break;
- case 15: print("%s = field %s + %s", dst_text, a_text, b_text); break;
+ case 1: print("%s = %s - %s<1<", dst_text, a_text, b_text); break;
+ case 2: print("%s = %s + %s<0<", dst_text, a_text, b_text); break;
+ case 3: print("%s = %s - %s", dst_text, a_text, c_text); break;
+ case 4: print("%s = %s - %s>1>", dst_text, a_text, b_text); break;
+ case 5: print("%s = %s - %s", dst_text, a_text, b_text); break;
+ case 6: print("?"); break;
+ case 7: print("%s = %s - %s>0>", dst_text, a_text, b_text); break;
+ case 8: print("%s = %s + %s>0>", dst_text, a_text, b_text); break;
+ case 9: print("?"); break;
+ case 10: print("%s = %s + %s", dst_text, a_text, b_text); break;
+ case 11: print("%s = %s + %s>1>", dst_text, a_text, b_text); break;
+ case 12: print("%s = %s + %s", dst_text, a_text, c_text); break;
+ case 13: print("%s = %s - %s<0<", dst_text, a_text, b_text); break;
+ case 14: print("%s = %s + %s<1<", dst_text, a_text, b_text); break;
+ case 15: print("%s = field %s + %s", dst_text, a_text, b_text); break;
}
}
- else // boolean
+ else // boolean
{
switch (aluop)
{
- case 0xaa: // A & B & C | A & ~B & C | A & B & ~C | A & ~B & ~C = A
+ case 0xaa: // A & B & C | A & ~B & C | A & B & ~C | A & ~B & ~C = A
print("%s = %s", dst_text, a_text);
break;
- case 0x55: // ~A & B & C | ~A & ~B & C | ~A & B & ~C | ~A & ~B & ~C = ~A
+ case 0x55: // ~A & B & C | ~A & ~B & C | ~A & B & ~C | ~A & ~B & ~C = ~A
print("%s = ~%s", dst_text, a_text);
break;
- case 0xcc: // A & B & C | ~A & B & C | A & B & ~C | ~A & B & ~C = B
+ case 0xcc: // A & B & C | ~A & B & C | A & B & ~C | ~A & B & ~C = B
print("%s = %s", dst_text, b_text);
break;
- case 0x33: // A & ~B & C | ~A & ~B & C | A & ~B & ~C | ~A & ~B & ~C = ~B
+ case 0x33: // A & ~B & C | ~A & ~B & C | A & ~B & ~C | ~A & ~B & ~C = ~B
print("%s = %s", dst_text, b_text);
break;
- case 0xf0: // A & B & C | ~A & B & C | A & ~B & C | ~A & ~B & C = C
+ case 0xf0: // A & B & C | ~A & B & C | A & ~B & C | ~A & ~B & C = C
print("%s = %s", dst_text, c_text);
break;
- case 0x0f: // A & B & ~C | ~A & B & ~C | A & ~B & ~C | ~A & ~B & ~C = ~C
+ case 0x0f: // A & B & ~C | ~A & B & ~C | A & ~B & ~C | ~A & ~B & ~C = ~C
print("%s = ~%s", dst_text, c_text);
break;
- case 0x80: // A & B & C
+ case 0x80: // A & B & C
print("%s = %s & %s & %s", dst_text, a_text, b_text, c_text);
break;
- case 0x88: // A & B & C | A & B & ~C = A & B
+ case 0x88: // A & B & C | A & B & ~C = A & B
print("%s = %s & %s", dst_text, a_text, b_text);
break;
- case 0xa0: // A & B & C | A & ~B & C = A & C
+ case 0xa0: // A & B & C | A & ~B & C = A & C
print("%s = %s & %s", dst_text, a_text, c_text);
break;
- case 0xc0: // A & B & C | ~A & B & C = B & C
+ case 0xc0: // A & B & C | ~A & B & C = B & C
print("%s = %s & %s", dst_text, b_text, c_text);
break;
- case 0xea: // A & B & C | ~A & B & C | A & ~B & C |
+ case 0xea: // A & B & C | ~A & B & C | A & ~B & C |
// A & B & ~C | A & ~B & ~C = A | C
print("%s = %s | %s", dst_text, a_text, c_text);
break;
- case 0xee: // A & B & C | ~A & B & C | A & ~B & C |
+ case 0xee: // A & B & C | ~A & B & C | A & ~B & C |
// A & B & ~C | ~A & B & ~C | A & ~B & ~C = A | B
print("%s = %s | %s", dst_text, a_text, b_text);
break;
- case 0x44: // ~A & B & C | ~A & B & ~C = ~A & B
+ case 0x44: // ~A & B & C | ~A & B & ~C = ~A & B
print("%s = ~%s & %s", dst_text, a_text, b_text);
break;
@@ -420,14 +420,14 @@ static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const UINT8 *oprom)
{
output = buffer;
UINT32 flags = 0;
-
+
UINT64 op = ((UINT64)(oprom[0]) << 56) | ((UINT64)(oprom[1]) << 48) | ((UINT64)(oprom[2]) << 40) | ((UINT64)(oprom[3]) << 32) |
((UINT64)(oprom[4]) << 24) | ((UINT64)(oprom[5]) << 16) | ((UINT64)(oprom[6]) << 8) | ((UINT64)(oprom[7]));
switch (op >> 60)
{
case 0x6:
- case 0x7: // Six-operand
+ case 0x7: // Six-operand
{
print("A: six operand <TODO>");
break;
@@ -452,7 +452,7 @@ static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const UINT8 *oprom)
case 0x00: print("nop"); break;
case 0x02: print("eint"); break;
case 0x03: print("dint"); break;
- default: print("<reserved>"); break;
+ default: print("<reserved>"); break;
}
format_transfer(parallel_xfer);
@@ -467,7 +467,7 @@ static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const UINT8 *oprom)
switch ((op >> 43) & 3)
{
case 0:
- case 1: // Base set ALU (5-bit immediate)
+ case 1: // Base set ALU (5-bit immediate)
{
UINT64 parallel_xfer = (op & U64(0x0000007fffffffff));
@@ -545,8 +545,8 @@ static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const UINT8 *oprom)
format_transfer(parallel_xfer);
break;
}
-
- case 2: // Base set ALU (reg src2)
+
+ case 2: // Base set ALU (reg src2)
{
UINT64 parallel_xfer = (op & U64(0x0000007fffffffff));
@@ -625,8 +625,8 @@ static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const UINT8 *oprom)
format_transfer(parallel_xfer);
break;
}
-
- case 3: // Base set ALU (32-bit immediate)
+
+ case 3: // Base set ALU (32-bit immediate)
{
int dst = (op >> 48) & 7;
int src1 = (op >> 45) & 7;
@@ -709,4 +709,4 @@ static offs_t tms32082_disasm_pp(char *buffer, offs_t pc, const UINT8 *oprom)
CPU_DISASSEMBLE(tms32082_pp)
{
return tms32082_disasm_pp(buffer, pc, oprom);
-} \ No newline at end of file
+}
diff --git a/src/emu/cpu/tms32082/mp_ops.c b/src/emu/cpu/tms32082/mp_ops.c
index b02cc1a5390..5f79cb2379c 100644
--- a/src/emu/cpu/tms32082/mp_ops.c
+++ b/src/emu/cpu/tms32082/mp_ops.c
@@ -32,7 +32,7 @@
#define SIGN16(x) (((x) & 0x8000) ? 1 : 0)
#define SIGN8(x) (((x) & 0x80) ? 1 : 0)
-#define SIGN_EXTEND(x, r) ((x) | (((x) & (0x80000000 >> r)) ? ((INT32)(0x80000000) >> r) : 0))
+#define SIGN_EXTEND(x, r) ((x) | (((x) & (0x80000000 >> r)) ? ((INT32)(0x80000000) >> r) : 0))
@@ -95,38 +95,38 @@ UINT32 tms32082_mp_device::calculate_cmp(UINT32 src1, UINT32 src2)
UINT32 flags = 0;
// 32-bits (bits 20-29)
- flags |= ((~c32) & 1) << 29; // higher than or same (C)
- flags |= ((c32) & 1) << 28; // lower than (~C)
- flags |= ((c32|z32) & 1) << 27; // lower than or same (~C|Z)
- flags |= ((~c32&~z32) & 1) << 26; // higher than (C&~Z)
- flags |= (((n32&v32)|(~n32&~v32)) & 1) << 25; // greater than or equal (N&V)|(~N&~V)
- flags |= (((n32&~v32)|(~n32&v32)) & 1) << 24; // less than (N&~V)|(~N&V)
- flags |= (((n32&~v32)|(~n32&v32)|(z32)) & 1) << 23; // less than or equal (N&~V)|(~N&V)|Z
- flags |= (((n32&v32&~z32)|(~n32&~v32&~z32)) & 1) << 22; // greater than (N&V&~Z)|(~N&~V&~Z)
- flags |= ((~z32) & 1) << 21; // not equal (~Z)
- flags |= ((z32) & 1) << 20; // equal (Z)
+ flags |= ((~c32) & 1) << 29; // higher than or same (C)
+ flags |= ((c32) & 1) << 28; // lower than (~C)
+ flags |= ((c32|z32) & 1) << 27; // lower than or same (~C|Z)
+ flags |= ((~c32&~z32) & 1) << 26; // higher than (C&~Z)
+ flags |= (((n32&v32)|(~n32&~v32)) & 1) << 25; // greater than or equal (N&V)|(~N&~V)
+ flags |= (((n32&~v32)|(~n32&v32)) & 1) << 24; // less than (N&~V)|(~N&V)
+ flags |= (((n32&~v32)|(~n32&v32)|(z32)) & 1) << 23; // less than or equal (N&~V)|(~N&V)|Z
+ flags |= (((n32&v32&~z32)|(~n32&~v32&~z32)) & 1) << 22; // greater than (N&V&~Z)|(~N&~V&~Z)
+ flags |= ((~z32) & 1) << 21; // not equal (~Z)
+ flags |= ((z32) & 1) << 20; // equal (Z)
// 16-bits (bits 10-19)
- flags |= ((~c16) & 1) << 19; // higher than or same (C)
- flags |= ((c16) & 1) << 18; // lower than (~C)
- flags |= ((c16|z16) & 1) << 17; // lower than or same (~C|Z)
- flags |= ((~c16&~z16) & 1) << 16; // higher than (C&~Z)
- flags |= (((n16&v16)|(~n16&~v16)) & 1) << 15; // greater than or equal (N&V)|(~N&~V)
- flags |= (((n16&~v16)|(~n16&v16)) & 1) << 14; // less than (N&~V)|(~N&V)
- flags |= (((n16&~v16)|(~n16&v16)|(z16)) & 1) << 13; // less than or equal (N&~V)|(~N&V)|Z
- flags |= (((n16&v16&~z16)|(~n16&~v16&~z16)) & 1) << 12; // greater than (N&V&~Z)|(~N&~V&~Z)
- flags |= ((~z16) & 1) << 11; // not equal (~Z)
- flags |= ((z16) & 1) << 10; // equal (Z)
+ flags |= ((~c16) & 1) << 19; // higher than or same (C)
+ flags |= ((c16) & 1) << 18; // lower than (~C)
+ flags |= ((c16|z16) & 1) << 17; // lower than or same (~C|Z)
+ flags |= ((~c16&~z16) & 1) << 16; // higher than (C&~Z)
+ flags |= (((n16&v16)|(~n16&~v16)) & 1) << 15; // greater than or equal (N&V)|(~N&~V)
+ flags |= (((n16&~v16)|(~n16&v16)) & 1) << 14; // less than (N&~V)|(~N&V)
+ flags |= (((n16&~v16)|(~n16&v16)|(z16)) & 1) << 13; // less than or equal (N&~V)|(~N&V)|Z
+ flags |= (((n16&v16&~z16)|(~n16&~v16&~z16)) & 1) << 12; // greater than (N&V&~Z)|(~N&~V&~Z)
+ flags |= ((~z16) & 1) << 11; // not equal (~Z)
+ flags |= ((z16) & 1) << 10; // equal (Z)
// 8-bits (bits 0-9)
- flags |= ((~c8) & 1) << 9; // higher than or same (C)
- flags |= ((c8) & 1) << 8; // lower than (~C)
- flags |= ((c8|z8) & 1) << 7; // lower than or same (~C|Z)
- flags |= ((~c8&~z8) & 1) << 6; // higher than (C&~Z)
- flags |= (((n8&v8)|(~n8&~v8)) & 1) << 5; // greater than or equal (N&V)|(~N&~V)
- flags |= (((n8&~v8)|(~n8&v8)) & 1) << 4; // less than (N&~V)|(~N&V)
- flags |= (((n8&~v8)|(~n8&v8)|(z8)) & 1) << 3; // less than or equal (N&~V)|(~N&V)|Z
- flags |= (((n8&v8&~z8)|(~n8&~v8&~z8)) & 1) << 2; // greater than (N&V&~Z)|(~N&~V&~Z)
- flags |= ((~z8) & 1) << 1; // not equal (~Z)
- flags |= ((z8) & 1) << 0; // equal (Z)
+ flags |= ((~c8) & 1) << 9; // higher than or same (C)
+ flags |= ((c8) & 1) << 8; // lower than (~C)
+ flags |= ((c8|z8) & 1) << 7; // lower than or same (~C|Z)
+ flags |= ((~c8&~z8) & 1) << 6; // higher than (C&~Z)
+ flags |= (((n8&v8)|(~n8&~v8)) & 1) << 5; // greater than or equal (N&V)|(~N&~V)
+ flags |= (((n8&~v8)|(~n8&v8)) & 1) << 4; // less than (N&~V)|(~N&V)
+ flags |= (((n8&~v8)|(~n8&v8)|(z8)) & 1) << 3; // less than or equal (N&~V)|(~N&V)|Z
+ flags |= (((n8&v8&~z8)|(~n8&~v8&~z8)) & 1) << 2; // greater than (N&V&~Z)|(~N&~V&~Z)
+ flags |= ((~z8) & 1) << 1; // not equal (~Z)
+ flags |= ((z8) & 1) << 0; // equal (Z)
return flags;
}
@@ -138,38 +138,38 @@ void tms32082_mp_device::vector_loadstore()
switch (vector_ls_bits)
{
- case 0x01: // vst.s
+ case 0x01: // vst.s
{
m_program->write_dword(m_outp, m_reg[rd]);
m_outp += 4;
break;
}
- case 0x03: // vst.d
+ case 0x03: // vst.d
{
UINT64 data = m_fpair[rd >> 1];
m_program->write_qword(m_outp, data);
m_outp += 8;
break;
}
- case 0x04: // vld0.s
+ case 0x04: // vld0.s
{
m_reg[rd] = m_program->read_dword(m_in0p);
m_in0p += 4;
break;
}
- case 0x05: // vld1.s
+ case 0x05: // vld1.s
{
m_reg[rd] = m_program->read_dword(m_in1p);
m_in1p += 4;
break;
}
- case 0x06: // vld0.d
+ case 0x06: // vld0.d
{
m_fpair[rd >> 1] = m_program->read_qword(m_in0p);
m_in0p += 8;
break;
}
- case 0x07: // vld1.d
+ case 0x07: // vld1.d
{
m_fpair[rd >> 1] = m_program->read_qword(m_in1p);
m_in1p += 8;
@@ -186,7 +186,7 @@ void tms32082_mp_device::execute_short_imm()
{
switch ((m_ir >> 15) & 0x7f)
{
- case 0x02: // cmnd
+ case 0x02: // cmnd
{
UINT32 data = OP_UIMM15();
@@ -220,7 +220,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x06: // brcr
+ case 0x06: // brcr
{
int cr = OP_UIMM15();
@@ -233,13 +233,13 @@ void tms32082_mp_device::execute_short_imm()
UINT32 data = read_creg(cr);
m_fetchpc = data & ~3;
- m_ie = (m_ie & ~1) | (data & 1); // global interrupt mask from creg
+ m_ie = (m_ie & ~1) | (data & 1); // global interrupt mask from creg
// TODO: user/supervisor latch from creg
}
break;
}
- case 0x08: // shift.dz
+ case 0x08: // shift.dz
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -251,14 +251,14 @@ void tms32082_mp_device::execute_short_imm()
UINT32 endmask = SHIFT_MASK[end ? end : 32];
if (inv) endmask = ~endmask;
- UINT32 compmask = endmask; // shiftmask == 0xffffffff
+ UINT32 compmask = endmask; // shiftmask == 0xffffffff
UINT32 res = 0;
- if (r) // right
+ if (r) // right
{
res = ROTATE_R(source, rot) & compmask;
}
- else // left
+ else // left
{
res = ROTATE_L(source, rot) & compmask;
}
@@ -268,7 +268,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x0a: // shift.ds
+ case 0x0a: // shift.ds
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -280,15 +280,15 @@ void tms32082_mp_device::execute_short_imm()
UINT32 endmask = SHIFT_MASK[end ? end : 32];
if (inv) endmask = ~endmask;
- UINT32 compmask = endmask; // shiftmask == 0xffffffff
+ UINT32 compmask = endmask; // shiftmask == 0xffffffff
UINT32 res = 0;
- if (r) // right
+ if (r) // right
{
res = ROTATE_R(source, rot) & compmask;
res = SIGN_EXTEND(res, rot);
}
- else // left
+ else // left
{
res = ROTATE_L(source, rot) & compmask;
// sign extend makes no sense to left..
@@ -299,7 +299,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x0b: // shift.ez
+ case 0x0b: // shift.ez
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -330,7 +330,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x0c: // shift.em
+ case 0x0c: // shift.em
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -346,11 +346,11 @@ void tms32082_mp_device::execute_short_imm()
UINT32 compmask = endmask & shiftmask;
UINT32 res = 0;
- if (r) // right
+ if (r) // right
{
res = (ROTATE_R(source, rot) & compmask) | (m_reg[rd] & ~compmask);
}
- else // left
+ else // left
{
res = (ROTATE_L(source, rot) & compmask) | (m_reg[rd] & ~compmask);
}
@@ -360,7 +360,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x0d: // shift.es
+ case 0x0d: // shift.es
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -371,18 +371,18 @@ void tms32082_mp_device::execute_short_imm()
UINT32 endmask = SHIFT_MASK[end ? end : 32];
if (inv) endmask = ~endmask;
-
+
int shift = r ? 32-rot : rot;
UINT32 shiftmask = SHIFT_MASK[shift ? shift : 32];
UINT32 compmask = endmask & shiftmask;
UINT32 res = 0;
- if (r) // right
+ if (r) // right
{
res = ROTATE_R(source, rot) & compmask;
res = SIGN_EXTEND(res, rot);
}
- else // left
+ else // left
{
res = ROTATE_L(source, rot) & compmask;
// sign extend makes no sense to left..
@@ -393,7 +393,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x0e: // shift.iz
+ case 0x0e: // shift.iz
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -423,7 +423,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x0f: // shift.im
+ case 0x0f: // shift.im
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -439,11 +439,11 @@ void tms32082_mp_device::execute_short_imm()
UINT32 compmask = endmask & ~shiftmask;
UINT32 res = 0;
- if (r) // right
+ if (r) // right
{
res = (ROTATE_R(source, rot) & compmask) | (m_reg[rd] & ~compmask);
}
- else // left
+ else // left
{
res = (ROTATE_L(source, rot) & compmask) | (m_reg[rd] & ~compmask);
}
@@ -453,7 +453,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x11: // and
+ case 0x11: // and
{
int rd = OP_RD();
int rs = OP_RS();
@@ -464,7 +464,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x14: // and.ft
+ case 0x14: // and.ft
{
int rd = OP_RD();
int rs = OP_RS();
@@ -475,7 +475,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x17: // or
+ case 0x17: // or
{
int rd = OP_RD();
int rs = OP_RS();
@@ -486,7 +486,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x1d: // or.ft
+ case 0x1d: // or.ft
{
int rd = OP_RD();
int rs = OP_RS();
@@ -498,7 +498,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x24:
- case 0x20: // ld.b
+ case 0x20: // ld.b
{
int rd = OP_RD();
int base = OP_BASE();
@@ -517,7 +517,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x25:
- case 0x21: // ld.h
+ case 0x21: // ld.h
{
int rd = OP_RD();
int base = OP_BASE();
@@ -536,7 +536,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x26:
- case 0x22: // ld
+ case 0x22: // ld
{
int rd = OP_RD();
int base = OP_BASE();
@@ -554,7 +554,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x27:
- case 0x23: // ld.d
+ case 0x23: // ld.d
{
int rd = OP_RD();
int base = OP_BASE();
@@ -576,7 +576,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x28:
- case 0x2c: // ld.ub
+ case 0x2c: // ld.ub
{
int rd = OP_RD();
int base = OP_BASE();
@@ -594,7 +594,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x2d:
- case 0x29: // ld.uh
+ case 0x29: // ld.uh
{
int rd = OP_RD();
int base = OP_BASE();
@@ -612,7 +612,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x34:
- case 0x30: // st.b
+ case 0x30: // st.b
{
int rd = OP_RD();
int base = OP_BASE();
@@ -629,7 +629,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x35:
- case 0x31: // st.h
+ case 0x31: // st.h
{
int rd = OP_RD();
int base = OP_BASE();
@@ -663,7 +663,7 @@ void tms32082_mp_device::execute_short_imm()
}
case 0x37:
- case 0x33: // st.d
+ case 0x33: // st.d
{
int rd = OP_RD();
int base = OP_BASE();
@@ -679,8 +679,8 @@ void tms32082_mp_device::execute_short_imm()
m_reg[base] = address;
break;
}
-
- case 0x48: // bbz
+
+ case 0x48: // bbz
{
int bitnum = OP_BITNUM() ^ 0x1f;
INT32 offset = OP_SIMM15();
@@ -698,7 +698,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x49: // bbz.a
+ case 0x49: // bbz.a
{
int bitnum = OP_BITNUM() ^ 0x1f;
INT32 offset = OP_SIMM15();
@@ -711,7 +711,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x4a: // bbo
+ case 0x4a: // bbo
{
int bitnum = OP_BITNUM() ^ 0x1f;
INT32 offset = OP_SIMM15();
@@ -742,7 +742,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x4c: // bcnd
+ case 0x4c: // bcnd
{
INT32 offset = OP_SIMM15();
int code = OP_RD();
@@ -760,7 +760,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x4d: // bcnd.a
+ case 0x4d: // bcnd.a
{
INT32 offset = OP_SIMM15();
int code = OP_RD();
@@ -784,7 +784,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x58: // add
+ case 0x58: // add
{
INT32 imm = OP_SIMM15();
int rd = OP_RD();
@@ -808,7 +808,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x5a: // sub
+ case 0x5a: // sub
{
INT32 imm = OP_SIMM15();
int rd = OP_RD();
@@ -821,7 +821,7 @@ void tms32082_mp_device::execute_short_imm()
break;
}
- case 0x5b: // subu
+ case 0x5b: // subu
{
INT32 imm = OP_SIMM15();
int rd = OP_RD();
@@ -887,7 +887,7 @@ void tms32082_mp_device::execute_reg_long_imm()
break;
}
- case 0x1c: // shift.iz
+ case 0x1c: // shift.iz
{
int r = (m_ir & (1 << 10));
int inv = (m_ir & (1 << 11));
@@ -919,7 +919,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0x22:
- case 0x23: // and
+ case 0x23: // and
{
int rd = OP_RD();
int rs = OP_RS();
@@ -943,7 +943,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0x2c:
- case 0x2d: // xor
+ case 0x2d: // xor
{
int rd = OP_RD();
int rs = OP_RS();
@@ -967,7 +967,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x40:
case 0x41:
case 0x48:
- case 0x49: // ld.b
+ case 0x49: // ld.b
{
int m = m_ir & (1 << 15);
@@ -977,7 +977,7 @@ void tms32082_mp_device::execute_reg_long_imm()
UINT32 address = m_reg[base] + (has_imm ? imm32 : m_reg[OP_SRC1()]);
UINT32 r = m_program->read_byte(address);
if (r & 0x80) r |= 0xffffff00;
-
+
if (rd)
m_reg[rd] = r;
@@ -989,7 +989,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x42:
case 0x4a:
case 0x43:
- case 0x4b: // ld.h
+ case 0x4b: // ld.h
{
int shift = (m_ir & (1 << 11)) ? 1 : 0;
int m = m_ir & (1 << 15);
@@ -1012,7 +1012,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x4c:
case 0x44:
case 0x4d:
- case 0x45: // ld
+ case 0x45: // ld
{
int shift = (m_ir & (1 << 11)) ? 2 : 0;
int m = m_ir & (1 << 15);
@@ -1033,7 +1033,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x4e:
case 0x4f:
case 0x46:
- case 0x47: // ld.d
+ case 0x47: // ld.d
{
int shift = (m_ir & (1 << 11)) ? 3 : 0;
int m = m_ir & (1 << 15);
@@ -1054,7 +1054,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x58:
case 0x59:
case 0x50:
- case 0x51: // ld.ub
+ case 0x51: // ld.ub
{
int m = m_ir & (1 << 15);
int base = OP_BASE();
@@ -1074,7 +1074,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x5a:
case 0x5b:
case 0x52:
- case 0x53: // ld.uh
+ case 0x53: // ld.uh
{
int shift = (m_ir & (1 << 11)) ? 1 : 0;
int m = m_ir & (1 << 15);
@@ -1095,7 +1095,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x60:
case 0x61:
case 0x68:
- case 0x69: // st.b
+ case 0x69: // st.b
{
int m = m_ir & (1 << 15);
@@ -1112,7 +1112,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x62:
case 0x63:
case 0x6a:
- case 0x6b: // st.h
+ case 0x6b: // st.h
{
int shift = (m_ir & (1 << 11)) ? 1 : 0;
int m = m_ir & (1 << 15);
@@ -1130,7 +1130,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0x6c:
case 0x6d:
case 0x64:
- case 0x65: // st
+ case 0x65: // st
{
int shift = (m_ir & (1 << 11)) ? 2 : 0;
int m = m_ir & (1 << 15);
@@ -1177,7 +1177,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xa0:
- case 0xa1: // cmp
+ case 0xa1: // cmp
{
int rd = OP_RD();
UINT32 src1 = has_imm ? imm32 : m_reg[OP_SRC1()];
@@ -1200,7 +1200,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xb4:
- case 0xb5: // sub
+ case 0xb5: // sub
{
int rd = OP_RD();
int rs = OP_RS();
@@ -1213,7 +1213,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xb6:
- case 0xb7: // subu
+ case 0xb7: // subu
{
int rd = OP_RD();
int rs = OP_RS();
@@ -1226,7 +1226,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0xc4:
case 0xd4:
case 0xc5:
- case 0xd5: // vmpy
+ case 0xd5: // vmpy
{
int p1 = m_ir & (1 << 5);
int pd = m_ir & (1 << 7);
@@ -1262,7 +1262,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0xc8:
case 0xd8:
case 0xc9:
- case 0xd9: // vrnd
+ case 0xd9: // vrnd
{
int acc = OP_ACC();
int p1 = m_ir & (1 << 5);
@@ -1282,7 +1282,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0:
m_reg[rd] = f2u((float)source);
break;
- case 1:
+ case 1:
m_fpair[rd >> 1] = d2u(source);
break;
case 2:
@@ -1313,7 +1313,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0xcc:
case 0xdc:
case 0xcd:
- case 0xdd: // vmac
+ case 0xdd: // vmac
{
int acc = OP_ACC();
int z = m_ir & (1 << 8);
@@ -1356,7 +1356,7 @@ void tms32082_mp_device::execute_reg_long_imm()
case 0xce:
case 0xde:
case 0xcf:
- case 0xdf: // vmsc
+ case 0xdf: // vmsc
{
int acc = OP_ACC();
int z = m_ir & (1 << 8);
@@ -1397,25 +1397,25 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xe0:
- case 0xe1: // fadd
+ case 0xe1: // fadd
{
int rd = OP_RD();
int rs = OP_RS();
int src1 = OP_SRC1();
int precision = (m_ir >> 5) & 0x3f;
- if (rd) // only calculate if destination register is valid
+ if (rd) // only calculate if destination register is valid
{
switch (precision)
{
- case 0x00: // SP - SP -> SP
+ case 0x00: // SP - SP -> SP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
float s2 = u2f(m_reg[rs]);
m_reg[rd] = f2u(s1 + s2);
break;
}
- case 0x10: // SP - SP -> DP
+ case 0x10: // SP - SP -> DP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
float s2 = u2f(m_reg[rs]);
@@ -1423,7 +1423,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x14: // SP - DP -> DP
+ case 0x14: // SP - DP -> DP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
double s2 = u2d(m_fpair[rs >> 1]);
@@ -1431,7 +1431,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x11: // DP - SP -> DP
+ case 0x11: // DP - SP -> DP
{
double s1 = u2d(m_fpair[src1 >> 1]);
float s2 = u2f(m_reg[rs]);
@@ -1439,7 +1439,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x15: // DP - DP -> DP
+ case 0x15: // DP - DP -> DP
{
double s1 = u2d(m_fpair[src1 >> 1]);
double s2 = u2d(m_fpair[rs >> 1]);
@@ -1455,25 +1455,25 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xe2:
- case 0xe3: // fsub
+ case 0xe3: // fsub
{
int rd = OP_RD();
int rs = OP_RS();
int src1 = OP_SRC1();
int precision = (m_ir >> 5) & 0x3f;
- if (rd) // only calculate if destination register is valid
+ if (rd) // only calculate if destination register is valid
{
switch (precision)
{
- case 0x00: // SP - SP -> SP
+ case 0x00: // SP - SP -> SP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
float s2 = u2f(m_reg[rs]);
m_reg[rd] = f2u(s1 - s2);
break;
}
- case 0x10: // SP - SP -> DP
+ case 0x10: // SP - SP -> DP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
float s2 = u2f(m_reg[rs]);
@@ -1481,7 +1481,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x14: // SP - DP -> DP
+ case 0x14: // SP - DP -> DP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
double s2 = u2d(m_fpair[rs >> 1]);
@@ -1489,7 +1489,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x11: // DP - SP -> DP
+ case 0x11: // DP - SP -> DP
{
double s1 = u2d(m_fpair[src1 >> 1]);
float s2 = u2f(m_reg[rs]);
@@ -1497,7 +1497,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x15: // DP - DP -> DP
+ case 0x15: // DP - DP -> DP
{
double s1 = u2d(m_fpair[src1 >> 1]);
double s2 = u2d(m_fpair[rs >> 1]);
@@ -1513,25 +1513,25 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xe4:
- case 0xe5: // fmpy
+ case 0xe5: // fmpy
{
int rd = OP_RD();
int rs = OP_RS();
int src1 = OP_SRC1();
int precision = (m_ir >> 5) & 0x3f;
- if (rd) // only calculate if destination register is valid
+ if (rd) // only calculate if destination register is valid
{
switch (precision)
{
- case 0x00: // SP x SP -> SP
+ case 0x00: // SP x SP -> SP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
float s2 = u2f(m_reg[rs]);
m_reg[rd] = f2u(s1 * s2);
break;
}
- case 0x10: // SP x SP -> DP
+ case 0x10: // SP x SP -> DP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
float s2 = u2f(m_reg[rs]);
@@ -1539,7 +1539,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x14: // SP x DP -> DP
+ case 0x14: // SP x DP -> DP
{
float s1 = u2f(has_imm ? imm32 : m_reg[src1]);
double s2 = u2d(m_fpair[rs >> 1]);
@@ -1547,7 +1547,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x11: // DP x SP -> DP
+ case 0x11: // DP x SP -> DP
{
double s1 = u2d(m_fpair[src1 >> 1]);
float s2 = u2f(m_reg[rs]);
@@ -1555,7 +1555,7 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x15: // DP x DP -> DP
+ case 0x15: // DP x DP -> DP
{
double s1 = u2d(m_fpair[src1 >> 1]);
double s2 = u2d(m_fpair[rs >> 1]);
@@ -1563,12 +1563,12 @@ void tms32082_mp_device::execute_reg_long_imm()
m_fpair[rd >> 1] = res;
break;
}
- case 0x2a: // I x I -> I
+ case 0x2a: // I x I -> I
{
m_reg[rd] = (INT32)(m_reg[rs]) * (INT32)(has_imm ? imm32 : m_reg[OP_SRC1()]);
break;
}
- case 0x3f: // U x U -> U
+ case 0x3f: // U x U -> U
{
m_reg[rd] = (UINT32)(m_reg[rs]) * (UINT32)(has_imm ? imm32 : m_reg[OP_SRC1()]);
break;
@@ -1581,7 +1581,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xe6:
- case 0xe7: // fdiv
+ case 0xe7: // fdiv
{
int rd = OP_RD();
int p1 = m_ir & (1 << 5);
@@ -1606,7 +1606,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xe8:
- case 0xe9: // frnd
+ case 0xe9: // frnd
{
//int mode = (m_ir >> 7) & 3;
int p1 = (m_ir >> 5) & 3;
@@ -1654,9 +1654,9 @@ void tms32082_mp_device::execute_reg_long_imm()
}
break;
}
-
+
case 0xea:
- case 0xeb: // fcmp
+ case 0xeb: // fcmp
{
int rd = OP_RD();
int p1 = m_ir & (1 << 5);
@@ -1689,7 +1689,7 @@ void tms32082_mp_device::execute_reg_long_imm()
}
case 0xee:
- case 0xef: // fsqrt
+ case 0xef: // fsqrt
{
int rd = OP_RD();
int src1 = OP_SRC1();
@@ -1709,7 +1709,7 @@ void tms32082_mp_device::execute_reg_long_imm()
break;
}
- case 0xf2: // rmo
+ case 0xf2: // rmo
{
UINT32 source = m_reg[OP_RS()];
int rd = OP_RD();
diff --git a/src/emu/cpu/tms32082/tms32082.c b/src/emu/cpu/tms32082/tms32082.c
index 914dccc8f86..b591f3fc6ac 100644
--- a/src/emu/cpu/tms32082/tms32082.c
+++ b/src/emu/cpu/tms32082/tms32082.c
@@ -22,7 +22,7 @@ const device_type TMS32082_PP = &device_creator<tms32082_pp_device>;
// internal memory map
static ADDRESS_MAP_START(mp_internal_map, AS_PROGRAM, 32, tms32082_mp_device)
- AM_RANGE(0x00000000, 0x00000fff) AM_RAM AM_SHARE("pp0_data0")
+ AM_RANGE(0x00000000, 0x00000fff) AM_RAM AM_SHARE("pp0_data0")
AM_RANGE(0x00001000, 0x00001fff) AM_RAM AM_SHARE("pp1_data0")
AM_RANGE(0x00008000, 0x00008fff) AM_RAM AM_SHARE("pp0_data1")
AM_RANGE(0x00009000, 0x00009fff) AM_RAM AM_SHARE("pp1_data1")
@@ -141,7 +141,7 @@ void tms32082_mp_device::device_start()
save_item(NAME(m_fetchpc));
save_item(NAME(m_reg));
save_item(NAME(m_acc));
-
+
save_item(NAME(m_in0p));
save_item(NAME(m_in1p));
save_item(NAME(m_outp));
@@ -256,7 +256,7 @@ void tms32082_mp_device::processor_command(UINT32 command)
printf("Task ");
if (command & 0x00002000)
printf("Msg ");
-
+
printf("to: ");
if (command & 0x00000400)
@@ -300,28 +300,28 @@ UINT32 tms32082_mp_device::read_creg(int reg)
{
switch (reg)
{
- case 0x0: // EPC
+ case 0x0: // EPC
return m_epc;
- case 0x1: // EIP
+ case 0x1: // EIP
return m_eip;
- case 0x4: // INTPEN
+ case 0x4: // INTPEN
return m_intpen;
- case 0x6: // IE
+ case 0x6: // IE
return m_ie;
case 0xa: // PPERROR
return 0xe0000;
- case 0x4000: // IN0P
+ case 0x4000: // IN0P
return m_in0p;
- case 0x4001: // IN1P
+ case 0x4001: // IN1P
return m_in1p;
- case 0x4002: // OUTP
+ case 0x4002: // OUTP
return m_outp;
default:
@@ -335,15 +335,15 @@ void tms32082_mp_device::write_creg(int reg, UINT32 data)
{
switch (reg)
{
- case 0x0: // EPC
+ case 0x0: // EPC
m_epc = data;
break;
- case 0x1: // EIP
+ case 0x1: // EIP
m_eip = data;
break;
- case 0x4: // INTPEN
+ case 0x4: // INTPEN
{
for (int i=0; i < 32; i++)
{
@@ -353,20 +353,20 @@ void tms32082_mp_device::write_creg(int reg, UINT32 data)
break;
}
- case 0x6: // IE
+ case 0x6: // IE
m_ie = data;
printf("IE = %08X\n", data);
break;
- case 0x4000: // IN0P
+ case 0x4000: // IN0P
m_in0p = data;
break;
- case 0x4001: // IN1P
+ case 0x4001: // IN1P
m_in1p = data;
break;
- case 0x4002: // OUTP
+ case 0x4002: // OUTP
m_outp = data;
break;
@@ -378,19 +378,19 @@ void tms32082_mp_device::write_creg(int reg, UINT32 data)
void tms32082_mp_device::check_interrupts()
{
- if (m_ie & 1) // global interrupt mask
+ if (m_ie & 1) // global interrupt mask
{
for (int i=1; i < 32; i++)
{
if (m_ie & m_intpen & (1 << i))
{
m_epc = (m_fetchpc & ~3);
- m_epc |= (m_ie & 1); // save global interrupt mask
+ m_epc |= (m_ie & 1); // save global interrupt mask
// TODO: user mode bit to EPC
m_eip = m_pc;
- m_ie &= ~1; // clear global interrupt mask
+ m_ie &= ~1; // clear global interrupt mask
// get new pc from vector table
m_fetchpc = m_pc = m_program->read_dword(0x01010180 + (i * 4));
@@ -445,7 +445,7 @@ void tms32082_mp_device::execute_run()
while (m_icount > 0)
{
m_pc = m_fetchpc;
-
+
check_interrupts();
debugger_instruction_hook(this, m_pc);
@@ -466,7 +466,7 @@ void tms32082_mp_device::execute_run()
// internal memory map
static ADDRESS_MAP_START(pp_internal_map, AS_PROGRAM, 32, tms32082_pp_device)
- AM_RANGE(0x00000000, 0x00000fff) AM_RAM AM_SHARE("pp0_data0")
+ AM_RANGE(0x00000000, 0x00000fff) AM_RAM AM_SHARE("pp0_data0")
AM_RANGE(0x00001000, 0x00001fff) AM_RAM AM_SHARE("pp1_data0")
AM_RANGE(0x00008000, 0x00008fff) AM_RAM AM_SHARE("pp0_data1")
AM_RANGE(0x00009000, 0x00009fff) AM_RAM AM_SHARE("pp1_data1")
@@ -528,4 +528,4 @@ void tms32082_pp_device::execute_run()
m_icount = 0;
return;
-} \ No newline at end of file
+}
diff --git a/src/emu/cpu/tms32082/tms32082.h b/src/emu/cpu/tms32082/tms32082.h
index 81dd80296fd..f791e52e157 100644
--- a/src/emu/cpu/tms32082/tms32082.h
+++ b/src/emu/cpu/tms32082/tms32082.h
@@ -58,10 +58,10 @@ public:
enum
{
- INPUT_X1 = 1,
- INPUT_X2 = 2,
- INPUT_X3 = 3,
- INPUT_X4 = 4,
+ INPUT_X1 = 1,
+ INPUT_X2 = 2,
+ INPUT_X3 = 3,
+ INPUT_X4 = 4,
};
DECLARE_READ32_MEMBER(mp_param_r);
diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c
index 9ed68966521..06aa593bebb 100644
--- a/src/emu/cpu/tms34010/tms34010.c
+++ b/src/emu/cpu/tms34010/tms34010.c
@@ -1842,4 +1842,3 @@ tms34020_device::tms34020_device(const machine_config &mconfig, device_type type
}
const device_type TMS34020 = &legacy_device_creator<tms34020_device>;
-
diff --git a/src/emu/cpu/tms34010/tms34010.h b/src/emu/cpu/tms34010/tms34010.h
index 4abf072789c..9240b33fa09 100644
--- a/src/emu/cpu/tms34010/tms34010.h
+++ b/src/emu/cpu/tms34010/tms34010.h
@@ -210,10 +210,10 @@ class tms34010_device : public legacy_cpu_device
public:
tms34010_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock);
tms34010_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, cpu_get_info_func get_info);
-
+
UINT32 tms340x0_ind16(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 tms340x0_rgb32(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-};
+};
extern const device_type TMS34010;
diff --git a/src/emu/cpu/tms9900/99xxcore.h b/src/emu/cpu/tms9900/99xxcore.h
index 338d206355b..e014ccda059 100644
--- a/src/emu/cpu/tms9900/99xxcore.h
+++ b/src/emu/cpu/tms9900/99xxcore.h
@@ -4781,7 +4781,7 @@ void TMS99XX_GET_INFO(legacy_cpu_device *device, UINT32 state, cpuinfo *info)
/* --- the following bits of info are returned as NULL-terminated strings --- */
case CPUINFO_STR_NAME: strcpy(info->s, TMS99XX_device_get_name); break;
case CPUINFO_STR_SHORTNAME: strcpy(info->s, TMS99XX_device_get_shortname); break;
-
+
case CPUINFO_STR_FAMILY: strcpy(info->s, "Texas Instruments 9900L"); break;
case CPUINFO_STR_VERSION: strcpy(info->s, "2.0"); break;
case CPUINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index cf0d7f0b1ab..6f5940973ec 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -1495,8 +1495,8 @@ static void execute_wplist(running_machine &machine, int ref, int params, const
{
static const char *const types[] = { "unkn ", "read ", "write", "r/w " };
- debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device->tag(),
- device->debug()->watchpoint_first(spacenum)->space().name());
+ debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device->tag(),
+ device->debug()->watchpoint_first(spacenum)->space().name());
/* loop over the watchpoints */
for (device_debug::watchpoint *wp = device->debug()->watchpoint_first(spacenum); wp != NULL; wp = wp->next())
diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c
index 6ebcfd0f3ed..074de69dcc4 100644
--- a/src/emu/debug/debugcpu.c
+++ b/src/emu/debug/debugcpu.c
@@ -3279,18 +3279,18 @@ void device_debug::set_state(symbol_table &table, void *ref, UINT64 value)
//-------------------------------------------------
device_debug::breakpoint::breakpoint(device_debug* debugInterface,
- symbol_table &symbols,
- int index,
- offs_t address,
- const char *condition,
- const char *action)
+ symbol_table &symbols,
+ int index,
+ offs_t address,
+ const char *condition,
+ const char *action)
: m_debugInterface(debugInterface),
- m_next(NULL),
- m_index(index),
- m_enabled(true),
- m_address(address),
- m_condition(&symbols, (condition != NULL) ? condition : "1"),
- m_action((action != NULL) ? action : "")
+ m_next(NULL),
+ m_index(index),
+ m_enabled(true),
+ m_address(address),
+ m_condition(&symbols, (condition != NULL) ? condition : "1"),
+ m_action((action != NULL) ? action : "")
{
}
@@ -3335,25 +3335,25 @@ bool device_debug::breakpoint::hit(offs_t pc)
// watchpoint - constructor
//-------------------------------------------------
-device_debug::watchpoint::watchpoint(device_debug* debugInterface,
- symbol_table &symbols,
- int index,
- address_space &space,
- int type,
- offs_t address,
- offs_t length,
- const char *condition,
- const char *action)
+device_debug::watchpoint::watchpoint(device_debug* debugInterface,
+ symbol_table &symbols,
+ int index,
+ address_space &space,
+ int type,
+ offs_t address,
+ offs_t length,
+ const char *condition,
+ const char *action)
: m_debugInterface(debugInterface),
- m_next(NULL),
- m_space(space),
- m_index(index),
- m_enabled(true),
- m_type(type),
- m_address(space.address_to_byte(address) & space.bytemask()),
- m_length(space.address_to_byte(length)),
- m_condition(&symbols, (condition != NULL) ? condition : "1"),
- m_action((action != NULL) ? action : "")
+ m_next(NULL),
+ m_space(space),
+ m_index(index),
+ m_enabled(true),
+ m_type(type),
+ m_address(space.address_to_byte(address) & space.bytemask()),
+ m_length(space.address_to_byte(length)),
+ m_condition(&symbols, (condition != NULL) ? condition : "1"),
+ m_action((action != NULL) ? action : "")
{
}
diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h
index e4d3e8306f8..f767b205b29 100644
--- a/src/emu/debug/debugcpu.h
+++ b/src/emu/debug/debugcpu.h
@@ -80,11 +80,11 @@ public:
public:
// construction/destruction
breakpoint(device_debug* debugInterface,
- symbol_table &symbols,
- int index,
- offs_t address,
- const char *condition = NULL,
- const char *action = NULL);
+ symbol_table &symbols,
+ int index,
+ offs_t address,
+ const char *condition = NULL,
+ const char *action = NULL);
// getters
const device_debug *debugInterface() const { return m_debugInterface; }
@@ -119,14 +119,14 @@ public:
public:
// construction/destruction
watchpoint(device_debug* debugInterface,
- symbol_table &symbols,
- int index,
- address_space &space,
- int type,
- offs_t address,
- offs_t length,
- const char *condition = NULL,
- const char *action = NULL);
+ symbol_table &symbols,
+ int index,
+ address_space &space,
+ int type,
+ offs_t address,
+ offs_t length,
+ const char *condition = NULL,
+ const char *action = NULL);
// getters
const device_debug *debugInterface() const { return m_debugInterface; }
diff --git a/src/emu/debug/dvwpoints.c b/src/emu/debug/dvwpoints.c
index 0eed8c98179..19a5ad1a4d6 100644
--- a/src/emu/debug/dvwpoints.c
+++ b/src/emu/debug/dvwpoints.c
@@ -496,9 +496,9 @@ void debug_view_watchpoints::view_update()
pad_astring_to_length(buffer, tableBreaks[2]);
buffer.catprintf("%s", wp->space().name());
pad_astring_to_length(buffer, tableBreaks[3]);
- buffer.catprintf("%s-%s",
- core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars()),
- core_i64_hex_format(wp->space().byte_to_address_end(wp->address() + wp->length()) - 1, wp->space().addrchars()));
+ buffer.catprintf("%s-%s",
+ core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars()),
+ core_i64_hex_format(wp->space().byte_to_address_end(wp->address() + wp->length()) - 1, wp->space().addrchars()));
pad_astring_to_length(buffer, tableBreaks[4]);
buffer.catprintf("%s", types[wp->type() & 3]);
pad_astring_to_length(buffer, tableBreaks[5]);
diff --git a/src/emu/divideo.c b/src/emu/divideo.c
index 5168fbcd1cf..9dd403e2b49 100644
--- a/src/emu/divideo.c
+++ b/src/emu/divideo.c
@@ -104,7 +104,7 @@ void device_video_interface::interface_validity_check(validity_checker &valid) c
if (screen == NULL)
mame_printf_error("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag());
}
-
+
// otherwise, look for a single match
else
{
@@ -138,7 +138,7 @@ void device_video_interface::interface_pre_start()
if (m_screen == NULL)
throw emu_fatalerror("Screen '%s' not found, explicitly set for device '%s'", m_screen_tag, device().tag());
}
-
+
// otherwise, look for a single match
else
{
diff --git a/src/emu/divideo.h b/src/emu/divideo.h
index 9445290a613..6df3da598f1 100644
--- a/src/emu/divideo.h
+++ b/src/emu/divideo.h
@@ -81,13 +81,13 @@ protected:
// optional operation overrides
virtual void interface_validity_check(validity_checker &valid) const;
virtual void interface_pre_start();
-
+
// configuration state
- bool m_screen_required; // is a screen required?
- const char * m_screen_tag; // configured tag for the target screen
+ bool m_screen_required; // is a screen required?
+ const char * m_screen_tag; // configured tag for the target screen
// internal state
- screen_device * m_screen; // pointer to the screen device
+ screen_device * m_screen; // pointer to the screen device
};
// iterator
diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c
index 099b9cbe68c..dd3a54af3e3 100644
--- a/src/emu/emuopts.c
+++ b/src/emu/emuopts.c
@@ -189,8 +189,8 @@ const options_entry emu_options::s_option_entries[] =
// misc options
{ NULL, NULL, OPTION_HEADER, "CORE MISC OPTIONS" },
- { OPTION_DRC, "1", OPTION_BOOLEAN, "enable DRC cpu core if available" },
- { OPTION_DRC_USE_C, "0", OPTION_BOOLEAN, "force DRC use C backend" },
+ { OPTION_DRC, "1", OPTION_BOOLEAN, "enable DRC cpu core if available" },
+ { OPTION_DRC_USE_C, "0", OPTION_BOOLEAN, "force DRC use C backend" },
{ OPTION_BIOS, NULL, OPTION_STRING, "select the system BIOS to use" },
{ OPTION_CHEAT ";c", "0", OPTION_BOOLEAN, "enable cheat subsystem" },
{ OPTION_SKIP_GAMEINFO, "0", OPTION_BOOLEAN, "skip displaying the information screen at startup" },
@@ -202,8 +202,8 @@ const options_entry emu_options::s_option_entries[] =
{ OPTION_AUTOBOOT_DELAY, "2", OPTION_INTEGER, "timer delay in sec to trigger command execution on autoboot" },
{ OPTION_AUTOBOOT_SCRIPT ";script", NULL, OPTION_STRING, "lua script to execute after machine boot" },
{ OPTION_HTTP, "0", OPTION_BOOLEAN, "enable local http server" },
- { OPTION_HTTP_PORT, "8080", OPTION_INTEGER, "http server listener port" },
- { OPTION_HTTP_PATH, "web", OPTION_STRING, "path to web files" },
+ { OPTION_HTTP_PORT, "8080", OPTION_INTEGER, "http server listener port" },
+ { OPTION_HTTP_PATH, "web", OPTION_STRING, "path to web files" },
{ NULL }
};
diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h
index d95ce2c8409..c128ecddc16 100644
--- a/src/emu/emuopts.h
+++ b/src/emu/emuopts.h
@@ -206,9 +206,9 @@ enum
#define OPTION_AUTOBOOT_DELAY "autoboot_delay"
#define OPTION_AUTOBOOT_SCRIPT "autoboot_script"
-#define OPTION_HTTP "http"
-#define OPTION_HTTP_PORT "http_port"
-#define OPTION_HTTP_PATH "http_path"
+#define OPTION_HTTP "http"
+#define OPTION_HTTP_PORT "http_port"
+#define OPTION_HTTP_PATH "http_path"
//**************************************************************************
// TYPE DEFINITIONS
@@ -369,7 +369,7 @@ public:
const char *autoboot_command() const { return value(OPTION_AUTOBOOT_COMMAND); }
int autoboot_delay() const { return int_value(OPTION_AUTOBOOT_DELAY); }
const char *autoboot_script() const { return value(OPTION_AUTOBOOT_SCRIPT); }
-
+
bool http() const { return bool_value(OPTION_HTTP); }
const char *http_port() const { return value(OPTION_HTTP_PORT); }
const char *http_path() const { return value(OPTION_HTTP_PATH); }
diff --git a/src/emu/machine.c b/src/emu/machine.c
index ed8f40a31ef..37221bb3a5a 100644
--- a/src/emu/machine.c
+++ b/src/emu/machine.c
@@ -394,7 +394,7 @@ int running_machine::run(bool firstrun)
bool settingsloaded = config_load_settings(*this);
nvram_load(*this);
sound().ui_mute(false);
-
+
// initialize ui lists
ui_initialize(*this);
diff --git a/src/emu/machine/40105.c b/src/emu/machine/40105.c
index 9ef59e37c5e..3333053a57f 100644
--- a/src/emu/machine/40105.c
+++ b/src/emu/machine/40105.c
@@ -37,8 +37,8 @@ const device_type CMOS_40105 = &device_creator<cmos_40105_device>;
cmos_40105_device::cmos_40105_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, CMOS_40105, "40105", tag, owner, clock, "40105", __FILE__),
- m_write_dir(*this),
- m_write_dor(*this)
+ m_write_dir(*this),
+ m_write_dor(*this)
{
}
diff --git a/src/emu/machine/40105.h b/src/emu/machine/40105.h
index 0291d75b0b6..7786acee153 100644
--- a/src/emu/machine/40105.h
+++ b/src/emu/machine/40105.h
@@ -48,7 +48,7 @@ public:
DECLARE_WRITE_LINE_MEMBER( si_w );
DECLARE_WRITE_LINE_MEMBER( so_w );
-
+
DECLARE_READ_LINE_MEMBER( dir_r );
DECLARE_READ_LINE_MEMBER( dor_r );
diff --git a/src/emu/machine/74148.c b/src/emu/machine/74148.c
index 50c957b6321..ba9743ca0b2 100644
--- a/src/emu/machine/74148.c
+++ b/src/emu/machine/74148.c
@@ -70,12 +70,12 @@ void ttl74148_device::device_config_complete()
const ttl74148_config *intf = reinterpret_cast<const ttl74148_config *>(static_config());
if (intf != NULL)
*static_cast<ttl74148_config *>(this) = *intf;
-
+
// or initialize to defaults if none provided
else
{
}
-
+
}
//-------------------------------------------------
@@ -100,7 +100,6 @@ void ttl74148_device::device_start()
void ttl74148_device::device_reset()
{
-
m_enable_input = 1;
m_input_lines[0] = 1;
m_input_lines[1] = 1;
diff --git a/src/emu/machine/74153.c b/src/emu/machine/74153.c
index a5e5de8ec56..9d21cfc6387 100644
--- a/src/emu/machine/74153.c
+++ b/src/emu/machine/74153.c
@@ -52,13 +52,13 @@ ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag,
m_input_lines[1][1] = 0;
m_input_lines[1][2] = 0;
m_input_lines[1][3] = 0;
-
+
for (int i = 0; i < 2; i++)
m_enable[i] = 0;
-
+
for (int i = 0; i < 2; i++)
m_output[i] = 0;
-
+
for (int i = 0; i < 2; i++)
m_last_output[i] = 0;
}
@@ -75,7 +75,7 @@ void ttl74153_device::device_config_complete()
const ttl74153_config *intf = reinterpret_cast<const ttl74153_config *>(static_config());
if (intf != NULL)
*static_cast<ttl74153_config *>(this) = *intf;
-
+
// or initialize to defaults if none provided
else
{
diff --git a/src/emu/machine/74153.h b/src/emu/machine/74153.h
index 2973fee12c8..a23b4941df3 100644
--- a/src/emu/machine/74153.h
+++ b/src/emu/machine/74153.h
@@ -59,13 +59,13 @@ public:
void input_line_w(int section, int input_line, int data);
void enable_w(int section, int data);
int output_r(int section);
-
+
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
-
+
private:
// internal state
diff --git a/src/emu/machine/74181.h b/src/emu/machine/74181.h
index 4eed4bc697c..b7e8a0efd6e 100644
--- a/src/emu/machine/74181.h
+++ b/src/emu/machine/74181.h
@@ -19,8 +19,7 @@
//**************************************************************************
#define MCFG_TTL74181_ADD(_tag) \
- MCFG_DEVICE_ADD(_tag, TTL74181, 0) \
-
+ MCFG_DEVICE_ADD(_tag, TTL74181, 0)
//**************************************************************************
// TYPE DEFINITIONS
diff --git a/src/emu/machine/aicartc.c b/src/emu/machine/aicartc.c
index ace57a368e8..5bd3323dff9 100644
--- a/src/emu/machine/aicartc.c
+++ b/src/emu/machine/aicartc.c
@@ -1,9 +1,9 @@
/***************************************************************************
- AICA-RTC sub-device
+ AICA-RTC sub-device
- TODO:
- - move this inside AICA sound core once that'll get modernized
+ TODO:
+ - move this inside AICA sound core once that'll get modernized
***************************************************************************/
diff --git a/src/emu/machine/aicartc.h b/src/emu/machine/aicartc.h
index 7f72c0eb4b9..592cf9f4e09 100644
--- a/src/emu/machine/aicartc.h
+++ b/src/emu/machine/aicartc.h
@@ -25,7 +25,7 @@ Template for skeleton device
// ======================> aicartc_device
class aicartc_device : public device_t,
- public device_rtc_interface
+ public device_rtc_interface
{
public:
// construction/destruction
diff --git a/src/emu/machine/atahle.c b/src/emu/machine/atahle.c
index d94eb4fe4ea..6632b3753ee 100644
--- a/src/emu/machine/atahle.c
+++ b/src/emu/machine/atahle.c
@@ -239,7 +239,7 @@ bool ata_hle_device::set_dma_mode(int word)
m_identify_buffer[word] |= 0x100 << (m_sector_count & 7);
return true;
}
-
+
return false;
}
diff --git a/src/emu/machine/ataintf.c b/src/emu/machine/ataintf.c
index 6082cf4d1ab..3c19c50e491 100644
--- a/src/emu/machine/ataintf.c
+++ b/src/emu/machine/ataintf.c
@@ -141,7 +141,7 @@ READ16_MEMBER( ata_interface_device::read_cs0 )
if (m_slot[i]->dev() != NULL)
result &= m_slot[i]->dev()->read_cs0(space, offset, mem_mask);
-// { static int last_status = -1; if (offset == 7 ) { if( result == last_status ) return last_status; last_status = result; } else last_status = -1; }
+// { static int last_status = -1; if (offset == 7 ) { if( result == last_status ) return last_status; last_status = result; } else last_status = -1; }
// printf( "read cs0 %04x %04x %04x\n", offset, result, mem_mask );
diff --git a/src/emu/machine/eeprom.c b/src/emu/machine/eeprom.c
index a12a8da293e..70cd543483a 100644
--- a/src/emu/machine/eeprom.c
+++ b/src/emu/machine/eeprom.c
@@ -87,10 +87,10 @@ eeprom_base_device::eeprom_base_device(const machine_config &mconfig, device_typ
m_completion_time(attotime::zero)
{
// a 2ms write time is too long for rfjetsa
- m_operation_time[WRITE_TIME] = attotime::from_usec(1750);
- m_operation_time[WRITE_ALL_TIME] = attotime::from_usec(8000);
- m_operation_time[ERASE_TIME] = attotime::from_usec(1000);
- m_operation_time[ERASE_ALL_TIME] = attotime::from_usec(8000);
+ m_operation_time[WRITE_TIME] = attotime::from_usec(1750);
+ m_operation_time[WRITE_ALL_TIME] = attotime::from_usec(8000);
+ m_operation_time[ERASE_TIME] = attotime::from_usec(1000);
+ m_operation_time[ERASE_ALL_TIME] = attotime::from_usec(8000);
}
@@ -195,8 +195,8 @@ void eeprom_base_device::write(offs_t address, UINT32 data)
//-------------------------------------------------
// write_all - write data at all addresses
-// (assumes an erase has previously been
-// performed)
+// (assumes an erase has previously been
+// performed)
//-------------------------------------------------
void eeprom_base_device::write_all(UINT32 data)
@@ -308,7 +308,7 @@ void eeprom_base_device::nvram_default()
if (m_default_data.u8 != NULL)
{
mame_printf_verbose("Warning: Driver-specific EEPROM defaults are going away soon.\n");
- for (offs_t offs = 0; offs < m_default_data_size; offs++)
+ for (offs_t offs = 0; offs < m_default_data_size; offs++)
{
if (m_data_bits == 8)
m_addrspace[0]->write_byte(offs, m_default_data.u8[offs]);
@@ -385,8 +385,8 @@ UINT32 eeprom_base_device::internal_read(offs_t address)
//-------------------------------------------------
-// internal_write - write data at the given
-// address
+// internal_write - write data at the given
+// address
//-------------------------------------------------
void eeprom_base_device::internal_write(offs_t address, UINT32 data)
diff --git a/src/emu/machine/eeprom.h b/src/emu/machine/eeprom.h
index e90228d7a55..fd851283e72 100644
--- a/src/emu/machine/eeprom.h
+++ b/src/emu/machine/eeprom.h
@@ -72,7 +72,7 @@
// ======================> eeprom_base_device
-class eeprom_base_device : public device_t,
+class eeprom_base_device : public device_t,
public device_memory_interface,
public device_nvram_interface
{
@@ -84,10 +84,10 @@ public:
// timing constants
enum timing_type
{
- WRITE_TIME, // default = 2ms
- WRITE_ALL_TIME, // default = 8ms
- ERASE_TIME, // default = 1ms
- ERASE_ALL_TIME, // default = 8ms
+ WRITE_TIME, // default = 2ms
+ WRITE_ALL_TIME, // default = 8ms
+ ERASE_TIME, // default = 1ms
+ ERASE_ALL_TIME, // default = 8ms
TIMING_COUNT
};
@@ -104,10 +104,10 @@ public:
void write_all(UINT32 data);
void erase(offs_t address);
void erase_all();
-
+
// status
bool ready() const { return machine().time() >= m_completion_time; }
-
+
protected:
// device-level overrides
virtual void device_validity_check(validity_checker &valid) const;
@@ -127,18 +127,18 @@ protected:
void internal_write(offs_t address, UINT32 data);
// configuration state
- UINT32 m_cells;
- UINT8 m_address_bits;
- UINT8 m_data_bits;
+ UINT32 m_cells;
+ UINT8 m_address_bits;
+ UINT8 m_data_bits;
address_space_config m_space_config;
generic_ptr m_default_data;
UINT32 m_default_data_size;
UINT32 m_default_value;
bool m_default_value_set;
- attotime m_operation_time[TIMING_COUNT];
+ attotime m_operation_time[TIMING_COUNT];
// live state
- attotime m_completion_time;
+ attotime m_completion_time;
};
diff --git a/src/emu/machine/eeprompar.c b/src/emu/machine/eeprompar.c
index b4417613c6d..0d730224df3 100644
--- a/src/emu/machine/eeprompar.c
+++ b/src/emu/machine/eeprompar.c
@@ -37,33 +37,33 @@
****************************************************************************
- Parallel EEPROMs are generally simpler than serial EEPROMs, though
- they require more pins to provide the full set of address and data
- lines necessary. They also require more pins the larger the EEPROM
- is, whereas serial EEPROMs all share the same pinout regardless of
- size.
-
- At a basic level, there are 5 sets of signals involved:
-
- * /CE = chip enable
- * /OE = output enable
- * /WE = write enable
- * D0-Dn = data lines
- * A0-An = address lines
-
- To access the chip, the various enable states must be asserted or
- cleared. Note that these are generally active-low, so asserted means
- pulled to GND, and cleared means pulled to Vcc:
-
- /CE /OE /WE Action
- ASSERT ASSERT CLEAR Read (D0-Dn contain output data)
- ASSERT CLEAR ASSERT Write/Erase (D0-Dn are input data)
-
- Erase is performed by doing a write with D0-Dn all set to 1.
-
- In general, it is slow to write or erase (9ms is quoted in the 2816A
- datasheet, for example), and the /WE must be held low for the entire
- write/erase duration in order to guarantee the data is written.
+ Parallel EEPROMs are generally simpler than serial EEPROMs, though
+ they require more pins to provide the full set of address and data
+ lines necessary. They also require more pins the larger the EEPROM
+ is, whereas serial EEPROMs all share the same pinout regardless of
+ size.
+
+ At a basic level, there are 5 sets of signals involved:
+
+ * /CE = chip enable
+ * /OE = output enable
+ * /WE = write enable
+ * D0-Dn = data lines
+ * A0-An = address lines
+
+ To access the chip, the various enable states must be asserted or
+ cleared. Note that these are generally active-low, so asserted means
+ pulled to GND, and cleared means pulled to Vcc:
+
+ /CE /OE /WE Action
+ ASSERT ASSERT CLEAR Read (D0-Dn contain output data)
+ ASSERT CLEAR ASSERT Write/Erase (D0-Dn are input data)
+
+ Erase is performed by doing a write with D0-Dn all set to 1.
+
+ In general, it is slow to write or erase (9ms is quoted in the 2816A
+ datasheet, for example), and the /WE must be held low for the entire
+ write/erase duration in order to guarantee the data is written.
***************************************************************************/
@@ -150,8 +150,7 @@ eeprom_parallel_##_lowercase##_device::eeprom_parallel_##_lowercase##_device(con
{ \
static_set_size(*this, _cells, _bits); \
}; \
-const device_type EEPROM_PARALLEL_##_uppercase = &device_creator<eeprom_parallel_##_lowercase##_device>; \
-
+const device_type EEPROM_PARALLEL_##_uppercase = &device_creator<eeprom_parallel_##_lowercase##_device>;
// standard 28XX class of 8-bit EEPROMs
DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 2804, 2804, 8, 512)
DEFINE_PARALLEL_EEPROM_DEVICE(28xx, 2816, 2816, 8, 2048)
diff --git a/src/emu/machine/eeprompar.h b/src/emu/machine/eeprompar.h
index 83baf7c743a..aab0a6d8b4f 100644
--- a/src/emu/machine/eeprompar.h
+++ b/src/emu/machine/eeprompar.h
@@ -120,8 +120,7 @@ class eeprom_parallel_##_lowercase##_device : public eeprom_parallel_##_baseclas
public: \
eeprom_parallel_##_lowercase##_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); \
}; \
-extern const device_type EEPROM_PARALLEL_##_uppercase; \
-
+extern const device_type EEPROM_PARALLEL_##_uppercase;
// standard 28XX class of 8-bit EEPROMs
DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 2804, 2804)
DECLARE_PARALLEL_EEPROM_DEVICE(28xx, 2816, 2816)
diff --git a/src/emu/machine/eepromser.c b/src/emu/machine/eepromser.c
index a1180e49f4d..461e059273b 100644
--- a/src/emu/machine/eepromser.c
+++ b/src/emu/machine/eepromser.c
@@ -37,95 +37,95 @@
****************************************************************************
- Serial EEPROMs generally work the same across manufacturers and models,
- varying largely by the size of the EEPROM and the packaging details.
-
- At a basic level, there are 5 signals involved:
-
- * CS = chip select
- * CLK = serial data clock
- * DI = serial data in
- * DO = serial data out
- * RDY/BUSY = ready (1) or busy (0) status
-
- Data is read or written via serial commands. A command is begun on a
- low-to-high transition of the CS line, following by clocking a start
- bit (1) on the DI line. After the start bit, subsequent clocks
- assemble one of the following commands:
-
- Start Opcode Address Data
- 1 01 aaaaaaaaa ddddddd WRITE data
- 1 10 aaaaaaaaa READ data
- 1 11 aaaaaaaaa ERASE data
- 1 00 00xxxxxxx WREN = WRite ENable
- 1 00 01xxxxxxx ddddddd WRAL = WRite ALl cells
- 1 00 10xxxxxxx ERAL = ERase ALl cells
- 1 00 11xxxxxxx WRDS = WRite DiSable
-
- The number of address bits (a) clocked varies based on the size of the
- chip, though it does not always map 1:1 with the size of the chip.
- For example, the 93C06 has 16 cells, which only needs 4 address bits;
- but commands to the 93C06 require 6 address bits (the top two must
- be 0).
-
- The number of data bits (d) clocked varies based on the chip and at
- times on the state of a pin on the chip which selects between multiple
- sizes (e.g., 8-bit versus 16-bit).
-
+ Serial EEPROMs generally work the same across manufacturers and models,
+ varying largely by the size of the EEPROM and the packaging details.
+
+ At a basic level, there are 5 signals involved:
+
+ * CS = chip select
+ * CLK = serial data clock
+ * DI = serial data in
+ * DO = serial data out
+ * RDY/BUSY = ready (1) or busy (0) status
+
+ Data is read or written via serial commands. A command is begun on a
+ low-to-high transition of the CS line, following by clocking a start
+ bit (1) on the DI line. After the start bit, subsequent clocks
+ assemble one of the following commands:
+
+ Start Opcode Address Data
+ 1 01 aaaaaaaaa ddddddd WRITE data
+ 1 10 aaaaaaaaa READ data
+ 1 11 aaaaaaaaa ERASE data
+ 1 00 00xxxxxxx WREN = WRite ENable
+ 1 00 01xxxxxxx ddddddd WRAL = WRite ALl cells
+ 1 00 10xxxxxxx ERAL = ERase ALl cells
+ 1 00 11xxxxxxx WRDS = WRite DiSable
+
+ The number of address bits (a) clocked varies based on the size of the
+ chip, though it does not always map 1:1 with the size of the chip.
+ For example, the 93C06 has 16 cells, which only needs 4 address bits;
+ but commands to the 93C06 require 6 address bits (the top two must
+ be 0).
+
+ The number of data bits (d) clocked varies based on the chip and at
+ times on the state of a pin on the chip which selects between multiple
+ sizes (e.g., 8-bit versus 16-bit).
+
****************************************************************************
- Most EEPROMs are based on the 93Cxx design (and have similar part
- designations):
-
- +--v--+
- CS |1 8| Vcc
- CLK |2 7| NC
- DI |3 6| NC
- DO |4 5| GND
- +-----+
-
- Note the lack of a READY/BUSY pin. On the 93Cxx series, the DO pin
- serves double-duty, returning READY/BUSY during a write/erase cycle,
- and outputting data during a read cycle.
-
- Some manufacturers have released "enhanced" versions with additional
- features:
-
- * Several manufacturers (ST) map pin 6 to "ORG", specifying the
- logical organization of the data. Connecting ORG to ground
- makes the EEPROM work as an 8-bit device, while connecting it
- to Vcc makes it work as a 16-bit device with one less
- address bit.
-
- * Other manufacturers (ST) have enhanced the read operations to
- allow serially streaming more than one cell. Essentially, after
- reading the first cell, keep CS high and keep clocking, and
- data from following cells will be read as well.
-
- The ER5911 is only slightly different:
-
- +--v--+
- CS |1 8| Vcc
- CLK |2 7| RDY/BUSY
- DI |3 6| ORG
- DO |4 5| GND
- +-----+
-
- Here we have an explicit RDY/BUSY signal, and the ORG flag as described
- above.
-
- From a command perspective, the ER5911 is also slightly different:
-
- 93Cxx has ERASE command; this maps to WRITE on ER5911
- 93Cxx has WRITEALL command; no equivalent on ER5911
+ Most EEPROMs are based on the 93Cxx design (and have similar part
+ designations):
+
+ +--v--+
+ CS |1 8| Vcc
+ CLK |2 7| NC
+ DI |3 6| NC
+ DO |4 5| GND
+ +-----+
+
+ Note the lack of a READY/BUSY pin. On the 93Cxx series, the DO pin
+ serves double-duty, returning READY/BUSY during a write/erase cycle,
+ and outputting data during a read cycle.
+
+ Some manufacturers have released "enhanced" versions with additional
+ features:
+
+ * Several manufacturers (ST) map pin 6 to "ORG", specifying the
+ logical organization of the data. Connecting ORG to ground
+ makes the EEPROM work as an 8-bit device, while connecting it
+ to Vcc makes it work as a 16-bit device with one less
+ address bit.
+
+ * Other manufacturers (ST) have enhanced the read operations to
+ allow serially streaming more than one cell. Essentially, after
+ reading the first cell, keep CS high and keep clocking, and
+ data from following cells will be read as well.
+
+ The ER5911 is only slightly different:
+
+ +--v--+
+ CS |1 8| Vcc
+ CLK |2 7| RDY/BUSY
+ DI |3 6| ORG
+ DO |4 5| GND
+ +-----+
+
+ Here we have an explicit RDY/BUSY signal, and the ORG flag as described
+ above.
+
+ From a command perspective, the ER5911 is also slightly different:
+
+ 93Cxx has ERASE command; this maps to WRITE on ER5911
+ 93Cxx has WRITEALL command; no equivalent on ER5911
****************************************************************************
- Issues with:
-
- kickgoal.c - code seems wrong, clock logic writes 0-0-0 instead of 0-1-0 as expected
- overdriv.c - drops CS, raises CS, keeps DI=1, triggering extraneous start bit
-
+ Issues with:
+
+ kickgoal.c - code seems wrong, clock logic writes 0-0-0 instead of 0-1-0 as expected
+ overdriv.c - drops CS, raises CS, keeps DI=1, triggering extraneous start bit
+
***************************************************************************/
#include "emu.h"
@@ -138,11 +138,11 @@
//**************************************************************************
// logging levels:
-// 0 = errors and warnings only
-// 1 = commands
-// 2 = state machine
-// 3 = DI/DO/READY reads & writes
-// 4 = all reads & writes
+// 0 = errors and warnings only
+// 1 = commands
+// 2 = state machine
+// 3 = DI/DO/READY reads & writes
+// 4 = all reads & writes
#define VERBOSE_PRINTF 0
#define VERBOSE_LOGERROR 0
@@ -195,7 +195,7 @@ eeprom_serial_base_device::eeprom_serial_base_device(const machine_config &mconf
//-------------------------------------------------
// static_set_address_bits - configuration helper
// to set the number of address bits in the
-// serial commands
+// serial commands
//-------------------------------------------------
void eeprom_serial_base_device::static_set_address_bits(device_t &device, int addrbits)
@@ -227,7 +227,7 @@ void eeprom_serial_base_device::device_start()
// start the base class
eeprom_base_device::device_start();
-
+
// save the current state
save_item(NAME(m_state));
save_item(NAME(m_cs_state));
@@ -269,8 +269,8 @@ void eeprom_serial_base_device::device_reset()
//**************************************************************************
//-------------------------------------------------
-// base_cs_write - set the state of the chip
-// select (CS) line
+// base_cs_write - set the state of the chip
+// select (CS) line
//-------------------------------------------------
void eeprom_serial_base_device::base_cs_write(int state)
@@ -280,10 +280,10 @@ void eeprom_serial_base_device::base_cs_write(int state)
if (state == m_cs_state)
return;
- // set the new state
+ // set the new state
LOG4((" cs_write(%d)\n", state));
m_cs_state = state;
-
+
// remember the rising edge time so we don't process CLK signals at the same time
if (state == ASSERT_LINE)
m_last_cs_rising_edge_time = machine().time();
@@ -292,7 +292,7 @@ void eeprom_serial_base_device::base_cs_write(int state)
//-------------------------------------------------
-// base_clk_write - set the state of the clock
+// base_clk_write - set the state of the clock
// (CLK) line
//-------------------------------------------------
@@ -303,7 +303,7 @@ void eeprom_serial_base_device::base_clk_write(int state)
if (state == m_clk_state)
return;
- // set the new state
+ // set the new state
LOG4((" clk_write(%d)\n", state));
m_clk_state = state;
handle_event((m_clk_state == ASSERT_LINE) ? EVENT_CLK_RISING_EDGE : EVENT_CLK_FALLING_EDGE);
@@ -311,8 +311,8 @@ void eeprom_serial_base_device::base_clk_write(int state)
//-------------------------------------------------
-// base_di_write - set the state of the data input
-// (DI) line
+// base_di_write - set the state of the data input
+// (DI) line
//-------------------------------------------------
void eeprom_serial_base_device::base_di_write(int state)
@@ -325,7 +325,7 @@ void eeprom_serial_base_device::base_di_write(int state)
//-------------------------------------------------
-// base_do_read - read the state of the data
+// base_do_read - read the state of the data
// output (DO) line
//-------------------------------------------------
@@ -341,7 +341,7 @@ int eeprom_serial_base_device::base_do_read()
//-------------------------------------------------
-// base_ready_read - read the state of the
+// base_ready_read - read the state of the
// READY/BUSY line
//-------------------------------------------------
@@ -390,7 +390,7 @@ void eeprom_serial_base_device::set_state(eeprom_state newstate)
//-------------------------------------------------
// handle_event - handle an event via the state
-// machine
+// machine
//-------------------------------------------------
void eeprom_serial_base_device::handle_event(eeprom_event event)
@@ -421,7 +421,7 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
if (event == EVENT_CS_RISING_EDGE)
set_state(STATE_WAIT_FOR_START_BIT);
break;
-
+
// CS is asserted; wait for rising clock with a 1 start bit; falling CS will reset us
// note that because each bit is written independently, it is possible for us to receive
// a false rising CLK edge at the exact same time as a rising CS edge; it appears we
@@ -435,7 +435,7 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
else if (event == EVENT_CS_FALLING_EDGE)
set_state(STATE_IN_RESET);
break;
-
+
// CS is asserted; wait for a command to come through; falling CS will reset us
case STATE_WAIT_FOR_COMMAND:
if (event == EVENT_CLK_RISING_EDGE)
@@ -448,13 +448,13 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
else if (event == EVENT_CS_FALLING_EDGE)
set_state(STATE_IN_RESET);
break;
-
+
// CS is asserted; reading data, clock the shift register; falling CS will reset us
case STATE_READING_DATA:
if (event == EVENT_CLK_RISING_EDGE)
{
int bit_index = m_bits_accum++;
-
+
// wrapping the address on multi-read is required by pacslot(cave.c)
if (bit_index % m_data_bits == 0 && (bit_index == 0 || m_streaming_enabled))
m_shift_register = read((m_address + m_bits_accum / m_data_bits) & ((1 << m_address_bits) - 1)) << (32 - m_data_bits);
@@ -474,7 +474,7 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
LOG0(("EEPROM: CS deasserted in READING_DATA after %d bits\n", m_bits_accum));
}
break;
-
+
// CS is asserted; waiting for data; clock data through until we accumulate enough; falling CS will reset us
case STATE_WAIT_FOR_DATA:
if (event == EVENT_CLK_RISING_EDGE)
@@ -489,7 +489,7 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
LOG0(("EEPROM: CS deasserted in STATE_WAIT_FOR_DATA after %d bits\n", m_bits_accum));
}
break;
-
+
// CS is asserted; waiting for completion; watch for CS falling
case STATE_WAIT_FOR_COMPLETION:
if (event == EVENT_CS_FALLING_EDGE)
@@ -501,7 +501,7 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
//-------------------------------------------------
// execute_command - execute a command once we
-// have enough bits for one
+// have enough bits for one
//-------------------------------------------------
void eeprom_serial_base_device::execute_command()
@@ -509,7 +509,7 @@ void eeprom_serial_base_device::execute_command()
// parse into a generic command and reset the accumulator count
parse_command_and_address();
m_bits_accum = 0;
-
+
#if (VERBOSE_PRINTF > 0 || VERBOSE_LOGERROR > 0)
// for debugging purposes
static const struct { eeprom_command command; const char *string; } s_command_names[] =
@@ -540,14 +540,14 @@ void eeprom_serial_base_device::execute_command()
m_shift_register = 0;
set_state(STATE_READING_DATA);
break;
-
+
// reset the shift register and wait for enough data to be clocked through
case COMMAND_WRITE:
case COMMAND_WRITEALL:
m_shift_register = 0;
set_state(STATE_WAIT_FOR_DATA);
break;
-
+
// erase the parsed address (unless locked) and wait for it to complete
case COMMAND_ERASE:
if (m_locked)
@@ -559,19 +559,19 @@ void eeprom_serial_base_device::execute_command()
erase(m_address);
set_state(STATE_WAIT_FOR_COMPLETION);
break;
-
+
// lock the chip; return to IN_RESET state
case COMMAND_LOCK:
m_locked = true;
set_state(STATE_IN_RESET);
break;
-
+
// unlock the chip; return to IN_RESET state
case COMMAND_UNLOCK:
m_locked = false;
set_state(STATE_IN_RESET);
break;
-
+
// erase the entire chip (unless locked) and wait for it to complete
case COMMAND_ERASEALL:
if (m_locked)
@@ -583,7 +583,7 @@ void eeprom_serial_base_device::execute_command()
erase_all();
set_state(STATE_WAIT_FOR_COMPLETION);
break;
-
+
default:
throw emu_fatalerror("execute_command called with invalid command %d\n", m_command);
}
@@ -591,8 +591,8 @@ void eeprom_serial_base_device::execute_command()
//-------------------------------------------------
-// execute_write_command - execute a write
-// command after receiving the data bits
+// execute_write_command - execute a write
+// command after receiving the data bits
//-------------------------------------------------
void eeprom_serial_base_device::execute_write_command()
@@ -627,7 +627,7 @@ void eeprom_serial_base_device::execute_write_command()
break;
// write the entire EEPROM with the same data; ERASEALL is required before so we
- // AND against the already-present data
+ // AND against the already-present data
case COMMAND_WRITEALL:
if (m_locked)
{
@@ -638,7 +638,7 @@ void eeprom_serial_base_device::execute_write_command()
write_all(m_shift_register);
set_state(STATE_WAIT_FOR_COMPLETION);
break;
-
+
default:
throw emu_fatalerror("execute_write_command called with invalid command %d\n", m_command);
}
@@ -661,8 +661,8 @@ eeprom_serial_93cxx_device::eeprom_serial_93cxx_device(const machine_config &mco
//-------------------------------------------------
-// parse_command_and_address - extract the
-// command and address from a bitstream
+// parse_command_and_address - extract the
+// command and address from a bitstream
//-------------------------------------------------
void eeprom_serial_93cxx_device::parse_command_and_address()
@@ -670,7 +670,7 @@ void eeprom_serial_93cxx_device::parse_command_and_address()
// set the defaults
m_command = COMMAND_INVALID;
m_address = m_command_address_accum & ((1 << m_command_address_bits) - 1);
-
+
// extract the command portion and handle it
switch (m_command_address_accum >> m_command_address_bits)
{
@@ -678,16 +678,16 @@ void eeprom_serial_93cxx_device::parse_command_and_address()
case 0:
switch (m_address >> (m_command_address_bits - 2))
{
- case 0: m_command = COMMAND_LOCK; break;
- case 1: m_command = COMMAND_WRITEALL; break;
- case 2: m_command = COMMAND_ERASEALL; break;
- case 3: m_command = COMMAND_UNLOCK; break;
+ case 0: m_command = COMMAND_LOCK; break;
+ case 1: m_command = COMMAND_WRITEALL; break;
+ case 2: m_command = COMMAND_ERASEALL; break;
+ case 3: m_command = COMMAND_UNLOCK; break;
}
m_address = 0;
break;
- case 1: m_command = COMMAND_WRITE; break;
- case 2: m_command = COMMAND_READ; break;
- case 3: m_command = COMMAND_ERASE; break;
+ case 1: m_command = COMMAND_WRITE; break;
+ case 2: m_command = COMMAND_READ; break;
+ case 3: m_command = COMMAND_ERASE; break;
}
// warn about out-of-range addresses
@@ -728,8 +728,8 @@ eeprom_serial_er5911_device::eeprom_serial_er5911_device(const machine_config &m
//-------------------------------------------------
-// parse_command_and_address - extract the
-// command and address from a bitstream
+// parse_command_and_address - extract the
+// command and address from a bitstream
//-------------------------------------------------
void eeprom_serial_er5911_device::parse_command_and_address()
@@ -737,7 +737,7 @@ void eeprom_serial_er5911_device::parse_command_and_address()
// set the defaults
m_command = COMMAND_INVALID;
m_address = m_command_address_accum & ((1 << m_command_address_bits) - 1);
-
+
// extract the command portion and handle it
switch (m_command_address_accum >> m_command_address_bits)
{
@@ -745,16 +745,16 @@ void eeprom_serial_er5911_device::parse_command_and_address()
case 0:
switch (m_address >> (m_command_address_bits - 2))
{
- case 0: m_command = COMMAND_LOCK; break;
- case 1: m_command = COMMAND_INVALID; break; // not on ER5911
- case 2: m_command = COMMAND_ERASEALL; break;
- case 3: m_command = COMMAND_UNLOCK; break;
+ case 0: m_command = COMMAND_LOCK; break;
+ case 1: m_command = COMMAND_INVALID; break; // not on ER5911
+ case 2: m_command = COMMAND_ERASEALL; break;
+ case 3: m_command = COMMAND_UNLOCK; break;
}
m_address = 0;
break;
- case 1: m_command = COMMAND_WRITE; break;
- case 2: m_command = COMMAND_READ; break;
- case 3: m_command = COMMAND_WRITE; break; // WRITE instead of ERASE on ER5911
+ case 1: m_command = COMMAND_WRITE; break;
+ case 2: m_command = COMMAND_READ; break;
+ case 3: m_command = COMMAND_WRITE; break; // WRITE instead of ERASE on ER5911
}
// warn about out-of-range addresses
@@ -793,8 +793,7 @@ eeprom_serial_##_lowercase##_##_bits##bit_device::eeprom_serial_##_lowercase##_#
static_set_size(*this, _cells, _bits); \
static_set_address_bits(*this, _addrbits); \
}; \
-const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT = &device_creator<eeprom_serial_##_lowercase##_##_bits##bit_device>; \
-
+const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT = &device_creator<eeprom_serial_##_lowercase##_##_bits##bit_device>;
// standard 93CX6 class of 16-bit EEPROMs
DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c06, 93C06, 16, 16, 6)
DEFINE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 16, 64, 6)
diff --git a/src/emu/machine/eepromser.h b/src/emu/machine/eepromser.h
index 99caeab6b54..8a28d4fbe24 100644
--- a/src/emu/machine/eepromser.h
+++ b/src/emu/machine/eepromser.h
@@ -87,8 +87,7 @@
// optional enable for streaming reads
#define MCFG_EEPROM_SERIAL_ENABLE_STREAMING() \
- eeprom_serial_base_device::static_enable_streaming(*device); \
-
+ eeprom_serial_base_device::static_enable_streaming(*device);
// pass-throughs to the base class for setting default data
#define MCFG_EEPROM_SERIAL_DATA MCFG_EEPROM_DATA
#define MCFG_EEPROM_SERIAL_DEFAULT_VALUE MCFG_EEPROM_DEFAULT_VALUE
@@ -112,14 +111,14 @@ public:
// inline configuration helpers
static void static_set_address_bits(device_t &device, int addrbits);
static void static_enable_streaming(device_t &device);
-
+
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
-
+
// read interfaces differ between implementations
-
+
// commands
enum eeprom_command
{
@@ -143,7 +142,7 @@ protected:
STATE_WAIT_FOR_DATA,
STATE_WAIT_FOR_COMPLETION
};
-
+
// events
enum eeprom_event
{
@@ -158,34 +157,34 @@ protected:
void handle_event(eeprom_event event);
void execute_command();
void execute_write_command();
-
+
// subclass helpers
void base_cs_write(int state);
void base_clk_write(int state);
void base_di_write(int state);
int base_do_read();
int base_ready_read();
-
+
// subclass overrides
virtual void parse_command_and_address() = 0;
// configuration state
- UINT8 m_command_address_bits; // number of address bits in a command
- bool m_streaming_enabled; // true if streaming is enabled
+ UINT8 m_command_address_bits; // number of address bits in a command
+ bool m_streaming_enabled; // true if streaming is enabled
// runtime state
- eeprom_state m_state; // current internal state
- UINT8 m_cs_state; // state of the CS line
- attotime m_last_cs_rising_edge_time; // time of the last CS rising edge
- UINT8 m_oe_state; // state of the OE line
- UINT8 m_clk_state; // state of the CLK line
- UINT8 m_di_state; // state of the DI line
- bool m_locked; // are we locked against writes?
- UINT32 m_bits_accum; // number of bits accumulated
- UINT32 m_command_address_accum; // accumulator of command+address bits
- eeprom_command m_command; // current command
- UINT32 m_address; // current address extracted from command
- UINT32 m_shift_register; // holds data coming in/going out
+ eeprom_state m_state; // current internal state
+ UINT8 m_cs_state; // state of the CS line
+ attotime m_last_cs_rising_edge_time; // time of the last CS rising edge
+ UINT8 m_oe_state; // state of the OE line
+ UINT8 m_clk_state; // state of the CLK line
+ UINT8 m_di_state; // state of the DI line
+ bool m_locked; // are we locked against writes?
+ UINT32 m_bits_accum; // number of bits accumulated
+ UINT32 m_command_address_accum; // accumulator of command+address bits
+ eeprom_command m_command; // current command
+ UINT32 m_address; // current address extracted from command
+ UINT32 m_shift_register; // holds data coming in/going out
};
@@ -200,12 +199,12 @@ protected:
public:
// read handlers
- DECLARE_READ_LINE_MEMBER(do_read); // combined DO+READY/BUSY
+ DECLARE_READ_LINE_MEMBER(do_read); // combined DO+READY/BUSY
// write handlers
- DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
- DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
- DECLARE_WRITE_LINE_MEMBER(di_write); // DI
+ DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
+ DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
+ DECLARE_WRITE_LINE_MEMBER(di_write); // DI
protected:
// subclass overrides
@@ -223,13 +222,13 @@ protected:
public:
// read handlers
- DECLARE_READ_LINE_MEMBER(do_read); // DO
- DECLARE_READ_LINE_MEMBER(ready_read); // READY/BUSY only
+ DECLARE_READ_LINE_MEMBER(do_read); // DO
+ DECLARE_READ_LINE_MEMBER(ready_read); // READY/BUSY only
// write handlers
- DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
- DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
- DECLARE_WRITE_LINE_MEMBER(di_write); // DI
+ DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high)
+ DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high)
+ DECLARE_WRITE_LINE_MEMBER(di_write); // DI
protected:
// subclass overrides
@@ -249,8 +248,7 @@ class eeprom_serial_##_lowercase##_##_bits##bit_device : public eeprom_serial_##
public: \
eeprom_serial_##_lowercase##_##_bits##bit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); \
}; \
-extern const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT; \
-
+extern const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT;
// standard 93CX6 class of 16-bit EEPROMs
DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c06, 93C06, 16)
DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 16)
diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c
index 5b7d7267759..28049b5df32 100644
--- a/src/emu/machine/generic.c
+++ b/src/emu/machine/generic.c
@@ -558,4 +558,3 @@ void generic_pulse_irq_line(device_t *device, int irqline, int cycles) { device-
// legacy
INTERRUPT_GEN( irq2_line_hold ) { device->machine().driver_data()->irq2_line_hold(*device); }
-
diff --git a/src/emu/machine/mb87078.h b/src/emu/machine/mb87078.h
index 98d90fec44c..de92cc0c521 100644
--- a/src/emu/machine/mb87078.h
+++ b/src/emu/machine/mb87078.h
@@ -44,7 +44,7 @@ public:
Range from 100 to 0. (100 = 0dB; 50 = -6dB; 0 = -infinity)
This function is designed for use with MAME mixer_xxx() functions. */
int gain_percent_r(int channel);
-
+
void gain_recalc();
protected:
@@ -52,7 +52,7 @@ protected:
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
-
+
private:
// internal state
int m_gain[4]; /* gain index 0-63,64,65 */
diff --git a/src/emu/machine/s2636.c b/src/emu/machine/s2636.c
index fb143e0448d..121ed6e87ca 100644
--- a/src/emu/machine/s2636.c
+++ b/src/emu/machine/s2636.c
@@ -143,13 +143,13 @@ void s2636_device::device_start()
save_pointer(NAME(m_work_ram), m_work_ram_size);
save_item(NAME(*m_bitmap));
save_item(NAME(*m_collision_bitmap));
-
-
+
+
m_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this);
save_item(NAME(m_size));
save_item(NAME(m_pos));
save_item(NAME(m_level));
-
+
for (int i = 0; i < 1; i++)
save_item(NAME(m_reg[i]), i);
}
diff --git a/src/emu/machine/s2636.h b/src/emu/machine/s2636.h
index ae49f117ee5..112fe5f9913 100644
--- a/src/emu/machine/s2636.h
+++ b/src/emu/machine/s2636.h
@@ -47,14 +47,14 @@ public:
bitmap_ind16 &update( const rectangle &cliprect );
DECLARE_WRITE8_MEMBER( work_ram_w );
DECLARE_READ8_MEMBER( work_ram_r );
-
+
void soundport_w (int mode, int data);
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
-
+
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
@@ -63,13 +63,13 @@ private:
UINT8 *m_work_ram;
bitmap_ind16 *m_bitmap;
bitmap_ind16 *m_collision_bitmap;
-
+
sound_stream *m_channel;
UINT8 m_reg[1];
int m_size;
int m_pos;
unsigned m_level;
-
+
int check_collision( int spriteno1, int spriteno2, const rectangle &cliprect );
};
diff --git a/src/emu/machine/smc91c9x.h b/src/emu/machine/smc91c9x.h
index 0295a339b2b..6260a2264b9 100644
--- a/src/emu/machine/smc91c9x.h
+++ b/src/emu/machine/smc91c9x.h
@@ -35,13 +35,13 @@ public:
DECLARE_READ16_MEMBER( read );
DECLARE_WRITE16_MEMBER( write );
-
+
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
-
+
private:
// internal state
smc91c9x_irq_func m_irq_handler;
@@ -64,7 +64,7 @@ private:
/* counters */
UINT32 m_sent;
UINT32 m_recd;
-
+
void update_ethernet_irq();
void update_stats();
void finish_enqueue(int param);
diff --git a/src/emu/machine/wd_fdc.c b/src/emu/machine/wd_fdc.c
index b30f62ac2b5..76c37444535 100644
--- a/src/emu/machine/wd_fdc.c
+++ b/src/emu/machine/wd_fdc.c
@@ -1466,7 +1466,7 @@ void wd_fdc_t::live_run(attotime limit)
if(cur_live.bit_counter & 15)
break;
int slot = (cur_live.bit_counter >> 4)-1;
- // fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).cstr(), slot, cur_live.data_reg, cur_live.crc);
+ // fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).cstr(), slot, cur_live.data_reg, cur_live.crc);
cur_live.idbuf[slot] = cur_live.data_reg;
if(slot == 5) {
live_delay(IDLE);
diff --git a/src/emu/mame.c b/src/emu/mame.c
index e7ada704667..b58aa4b05a8 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -147,9 +147,9 @@ int mame_execute(emu_options &options, osd_interface &osd)
// loop across multiple hard resets
bool exit_pending = false;
int error = MAMERR_NONE;
-
+
web_engine web(options);
-
+
while (error == MAMERR_NONE && !exit_pending)
{
// if no driver, use the internal empty driver
@@ -187,9 +187,9 @@ int mame_execute(emu_options &options, osd_interface &osd)
// looooong term: remove this
global_machine = &machine;
-
+
web.set_machine(machine);
- web.push_message("update_machine");
+ web.push_message("update_machine");
// run the machine
error = machine.run(firstrun);
firstrun = false;
diff --git a/src/emu/memarray.h b/src/emu/memarray.h
index c1acc53e5c6..39d2b0b54e2 100644
--- a/src/emu/memarray.h
+++ b/src/emu/memarray.h
@@ -37,16 +37,16 @@
****************************************************************************
- A memory array in this case is an array of 8, 16, or 32-bit data
- arranged logically.
-
- A memory array is stored in "natural" order, i.e., read/writes to it
- are done via AM_RAM, or standard COMBINE_DATA, even if the width of
- the CPU is different from the array width.
-
- The read_entry/write_entry functions serve to read/write entries of
- the configured size regardless of the underlay width of the CPU's
- memory system.
+ A memory array in this case is an array of 8, 16, or 32-bit data
+ arranged logically.
+
+ A memory array is stored in "natural" order, i.e., read/writes to it
+ are done via AM_RAM, or standard COMBINE_DATA, even if the width of
+ the CPU is different from the array width.
+
+ The read_entry/write_entry functions serve to read/write entries of
+ the configured size regardless of the underlay width of the CPU's
+ memory system.
***************************************************************************/
diff --git a/src/emu/profiler.h b/src/emu/profiler.h
index e521abf506a..e853bc31561 100644
--- a/src/emu/profiler.h
+++ b/src/emu/profiler.h
@@ -119,7 +119,7 @@ public:
// getters
bool enabled() const
- {
+ {
#ifndef MAME_DEBUG_FAST
return m_filoptr != NULL;
#else
diff --git a/src/emu/screen.h b/src/emu/screen.h
index 1c47e2add0f..ed84c9930c4 100644
--- a/src/emu/screen.h
+++ b/src/emu/screen.h
@@ -355,12 +355,12 @@ typedef device_type_iterator<&device_creator<screen_device>, screen_device> scre
// SCREEN DEVICE CONFIGURATION MACROS
//**************************************************************************
- // legacy
+ // legacy
#define SCREEN_UPDATE_NAME(name) screen_update_##name
#define SCREEN_UPDATE_IND16(name) UINT32 SCREEN_UPDATE_NAME(name)(device_t *, screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
#define SCREEN_UPDATE_RGB32(name) UINT32 SCREEN_UPDATE_NAME(name)(device_t *, screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
- // legacy
+ // legacy
#define SCREEN_VBLANK_NAME(name) screen_vblank_##name
#define SCREEN_VBLANK(name) void SCREEN_VBLANK_NAME(name)(device_t *, screen_device &screen, bool vblank_on)
diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c
index d6f679f6441..b62f081c6e3 100644
--- a/src/emu/sound/aica.c
+++ b/src/emu/sound/aica.c
@@ -734,8 +734,8 @@ static void AICA_UpdateReg(aica_state *AICA, address_space &space, int reg)
//case 0x0c:
//case 0x0d:
- // printf("%04x\n",AICA->udata.data[0xc/2]);
- // break;
+ // printf("%04x\n",AICA->udata.data[0xc/2]);
+ // break;
case 0x12:
case 0x13:
diff --git a/src/emu/sound/cdp1864.h b/src/emu/sound/cdp1864.h
index 5cda3291e7a..f3489f95b92 100644
--- a/src/emu/sound/cdp1864.h
+++ b/src/emu/sound/cdp1864.h
@@ -158,7 +158,7 @@ private:
TIMER_DMA,
TIMER_HSYNC
};
-
+
void initialize_palette();
static const int bckgnd[];
diff --git a/src/emu/sound/esqpump.c b/src/emu/sound/esqpump.c
index 0efc4a6d1fa..5d8da22111f 100644
--- a/src/emu/sound/esqpump.c
+++ b/src/emu/sound/esqpump.c
@@ -1,9 +1,9 @@
/***************************************************************************
-
+
esqpump.c - Ensoniq 5505/5506 to 5510 interface.
-
+
By Christian Brunschen
-
+
***************************************************************************/
#include "sound/esqpump.h"
@@ -70,7 +70,7 @@ void esq_5505_5510_pump::sound_stream_update(sound_stream &stream, stream_sample
for (int i = 0; i < samples; i++)
{
#define SAMPLE_SHIFT 4
- // anything for the 'aux' output?
+ // anything for the 'aux' output?
INT16 l = inputs[0][i] >> SAMPLE_SHIFT;
INT16 r = inputs[1][i] >> SAMPLE_SHIFT;
@@ -108,7 +108,7 @@ void esq_5505_5510_pump::sound_stream_update(sound_stream &stream, stream_sample
INT32 er = (inputs[3][i]) + (inputs[5][i]) + (inputs[7][i]);
INT32 e_next = el + er;
e[(ei + 0x1d0f) % 0x4000] = e_next;
-
+
if (l != e[ei]) {
fprintf(stderr, "expected (%d) but have (%d)\n", e[ei], l);
}
@@ -166,4 +166,3 @@ void esq_5505_5510_pump::device_timer(emu_timer &timer, device_timer_id id, int
// ecery time there's a new sample period, update the stream!
m_stream->update();
}
-
diff --git a/src/emu/sound/esqpump.h b/src/emu/sound/esqpump.h
index fbead6b485a..eae3cebb32d 100644
--- a/src/emu/sound/esqpump.h
+++ b/src/emu/sound/esqpump.h
@@ -24,10 +24,9 @@ public:
m_esp_halted = esp_halted;
logerror("ESP-halted -> %d\n", m_esp_halted);
if (!esp_halted) {
-
#if PUMP_REPLACE_ESP_PROGRAM
m_esp->write_reg(245, 0x1d0f << 8); // dlength = 0x3fff, 16-sample delay
-
+
int pc = 0;
for (pc = 0; pc < 0xc0; pc++) {
m_esp->write_reg(pc, 0);
@@ -41,7 +40,7 @@ public:
m_esp->_instr(pc++) = 0xffffeea00000; // ADD SER2R, gpr_a0 > gpr_a0
m_esp->_instr(pc ) = 0xffffefa00000; // ADD SER2L, gpr_a0 > gpr_a0; prepare to read from delay 2 instructions from now, offset = 0
- m_esp->write_reg(pc++, 0); //offset into delay
+ m_esp->write_reg(pc++, 0); //offset into delay
m_esp->_instr(pc ) = 0xffffa0a09508; // MOV gpr_a0 > delay + offset
m_esp->write_reg(pc++, 1 << 8); // offset into delay - -1 samples
diff --git a/src/emu/sound/multipcm.h b/src/emu/sound/multipcm.h
index b79e7c81539..b900d77f71d 100644
--- a/src/emu/sound/multipcm.h
+++ b/src/emu/sound/multipcm.h
@@ -94,7 +94,7 @@ private:
//I include these in the chip because they depend on the chip clock
unsigned int m_ARStep[0x40], m_DRStep[0x40]; //Envelope step table
unsigned int m_FNS_Table[0x400]; //Frequency step table
-
+
void EG_Calc(SLOT *slot);
void LFO_ComputeStep(LFO_t *LFO,UINT32 LFOF,UINT32 LFOS,int ALFO);
void WriteSlot(SLOT *slot,int reg,unsigned char data);
diff --git a/src/emu/sound/okim6376.h b/src/emu/sound/okim6376.h
index c9d40fb2f77..91fd971771b 100644
--- a/src/emu/sound/okim6376.h
+++ b/src/emu/sound/okim6376.h
@@ -36,7 +36,7 @@ public:
void set_frequency(int frequency);
-
+
protected:
// device-level overrides
virtual void device_config_complete();
@@ -66,7 +66,7 @@ private:
UINT8 m_st_pulses; /* Keep track of attenuation */
UINT8 m_ch2_update; /* Pulse shape */
UINT8 m_st_update;
-
+
void oki_process(int channel, int command);
void generate_adpcm(struct ADPCMVoice *voice, INT16 *buffer, int samples,int channel);
void postload();
diff --git a/src/emu/sound/s14001a.h b/src/emu/sound/s14001a.h
index d7e58cbcbd7..d3bd5b43e94 100644
--- a/src/emu/sound/s14001a.h
+++ b/src/emu/sound/s14001a.h
@@ -24,7 +24,7 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-
+
private:
// internal state
sound_stream * m_stream;
@@ -50,7 +50,7 @@ private:
UINT8 *m_SpeechRom; // array to hold rom contents, mame will not need this, will use a pointer
INT16 m_filtervals[8];
UINT8 m_VSU1000_amp; // amplitude setting on VSU-1000 board
-
+
INT16 audiofilter();
void shiftIntoFilter(INT16 inputvalue);
void PostPhoneme();
diff --git a/src/emu/sound/sound.mak b/src/emu/sound/sound.mak
index e7656a3fe34..04ad4f8e1be 100644
--- a/src/emu/sound/sound.mak
+++ b/src/emu/sound/sound.mak
@@ -727,7 +727,7 @@ endif
#-------------------------------------------------
-# NEC uPD7752
+# NEC uPD7752
#@src/emu/sound/upd7752.h,SOUNDS += UPD7752
#-------------------------------------------------
diff --git a/src/emu/sound/sp0250.c b/src/emu/sound/sp0250.c
index 7f7b364c949..a94707c35a3 100644
--- a/src/emu/sound/sp0250.c
+++ b/src/emu/sound/sp0250.c
@@ -52,7 +52,7 @@ sp0250_device::sp0250_device(const machine_config &mconfig, const char *tag, dev
{
m_fifo[i] = 0;
}
-
+
for (int i = 0; i < 6; i++)
{
m_filter[i].F = 0;
@@ -88,7 +88,7 @@ void sp0250_device::device_config_complete()
void sp0250_device::device_start()
{
const sp0250_interface *intf = reinterpret_cast<const sp0250_interface *>(static_config());
-
+
m_RNG = 1;
m_drq = ( intf!= NULL) ? m_drq_callback : NULL;
if (m_drq != NULL)
@@ -98,7 +98,7 @@ void sp0250_device::device_start()
}
m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() / CLOCK_DIVIDER, this);
-
+
save_item(NAME(m_amp));
save_item(NAME(m_pitch));
save_item(NAME(m_repeat));
diff --git a/src/emu/sound/sp0250.h b/src/emu/sound/sp0250.h
index 7cb01c97691..1011edd08c2 100644
--- a/src/emu/sound/sp0250.h
+++ b/src/emu/sound/sp0250.h
@@ -19,7 +19,7 @@ public:
DECLARE_WRITE8_MEMBER( write );
UINT8 drq_r();
-
+
protected:
// device-level overrides
virtual void device_config_complete();
@@ -27,7 +27,7 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
-
+
private:
// internal state
INT16 m_amp;
@@ -47,7 +47,7 @@ private:
INT16 F, B;
INT16 z1, z2;
} m_filter[6];
-
+
void load_values();
TIMER_CALLBACK_MEMBER( timer_tick );
};
diff --git a/src/emu/sound/t6721a.h b/src/emu/sound/t6721a.h
index 6cc8c24b966..af9a706db76 100644
--- a/src/emu/sound/t6721a.h
+++ b/src/emu/sound/t6721a.h
@@ -65,7 +65,7 @@
// ======================> t6721a_device
class t6721a_device : public device_t,
- public device_sound_interface
+ public device_sound_interface
{
public:
t6721a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c
index 6ae658c72f9..f4d9c194919 100644
--- a/src/emu/sound/tms5220.c
+++ b/src/emu/sound/tms5220.c
@@ -120,7 +120,7 @@ Patent notes (important timing info for interpolation):
01 7 0#3 4 5 6 7 0#3 4 5 6 7 0#3 4 5
10 7 0#5 6 7 0#5 6 7 0#5 6 7 0#5 6 7
11 7 0#7 0#7 0#7 0#7 0#7 0#7 0#7 0#7
- Based on the behavior tested on the CD2501ECD this is assumed to be the same for that chip as well.
+ Based on the behavior tested on the CD2501ECD this is assumed to be the same for that chip as well.
Most of the following is based on figure 8c of 4,331,836, which is the
TMS5100/TMC0280 patent, but the same information applies to the TMS52xx
@@ -219,7 +219,7 @@ serial chips); Street Electronics Corp.'s Apple II 'Echo 2' Speech
synthesizer (early cards only)
CD2501ECD: (1983)
- Home computer: TI 99/8 (prototypes only)
+ Home computer: TI 99/8 (prototypes only)
TMS5220: (mostly on things made between 1981 and 1984-1985)
Arcade: Bally/Midway's 'NFL Football'; Atari's 'Star Wars',
diff --git a/src/emu/sound/upd7752.c b/src/emu/sound/upd7752.c
index 64185f1c9c1..d35fddf2b14 100644
--- a/src/emu/sound/upd7752.c
+++ b/src/emu/sound/upd7752.c
@@ -20,7 +20,7 @@ const device_type UPD7752 = &device_creator<upd7752_device>;
/* TODO: unknown exact size */
static ADDRESS_MAP_START( upd7752_ram, AS_0, 8, upd7752_device )
-// AM_RANGE(0x0000, 0x7fff) AM_ROM
+// AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x0000, 0xffff) AM_RAM
ADDRESS_MAP_END
@@ -34,9 +34,9 @@ ADDRESS_MAP_END
upd7752_device::upd7752_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, UPD7752, "uPD7752", tag, owner, clock, "upd7752", __FILE__),
- device_sound_interface(mconfig, *this),
- device_memory_interface(mconfig, *this),
- m_space_config("ram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(upd7752_ram))
+ device_sound_interface(mconfig, *this),
+ device_memory_interface(mconfig, *this),
+ m_space_config("ram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(upd7752_ram))
{
}
@@ -80,7 +80,6 @@ void upd7752_device::device_reset()
void upd7752_device::device_stop()
{
-
}
//-------------------------------------------------
@@ -155,7 +154,7 @@ WRITE8_MEMBER( upd7752_device::write )
[1] xxxx ---- amp Voice source amplitude
---- x--- Fricative Voice data
---- -xxx Pitch
- (repeat for N1 times)
+ (repeat for N1 times)
if [0] & 0xf8 == 0 then command stop
*/
writebyte(m_ram_addr++,data);
diff --git a/src/emu/sound/upd7752.h b/src/emu/sound/upd7752.h
index 71cff7f92d8..cdeb05b3dbd 100644
--- a/src/emu/sound/upd7752.h
+++ b/src/emu/sound/upd7752.h
@@ -30,8 +30,8 @@ Template for skeleton device
// ======================> upd7752_device
class upd7752_device : public device_t,
- public device_sound_interface,
- public device_memory_interface
+ public device_sound_interface,
+ public device_memory_interface
{
public:
// construction/destruction
diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h
index 0d2d1a0827f..e436a6c124b 100644
--- a/src/emu/tilemap.h
+++ b/src/emu/tilemap.h
@@ -599,7 +599,7 @@ private:
// blitting parameters for rendering
struct blit_parameters
{
- bitmap_ind8 * priority;
+ bitmap_ind8 * priority;
rectangle cliprect;
UINT32 tilemap_priority_code;
UINT8 mask;
diff --git a/src/emu/video/315_5124.h b/src/emu/video/315_5124.h
index 4685e500274..b1a51352787 100644
--- a/src/emu/video/315_5124.h
+++ b/src/emu/video/315_5124.h
@@ -76,7 +76,7 @@ public:
DECLARE_WRITE8_MEMBER( register_write );
DECLARE_READ8_MEMBER( vcount_read );
DECLARE_READ8_MEMBER( hcount_read );
-
+
DECLARE_PALETTE_INIT( sega315_5124 );
void hcount_latch() { hcount_latch_at_hpos( m_screen->hpos() ); };
diff --git a/src/emu/video/dl1416.c b/src/emu/video/dl1416.c
index fe53baad7b8..436e494bea4 100644
--- a/src/emu/video/dl1416.c
+++ b/src/emu/video/dl1416.c
@@ -139,7 +139,7 @@ void dl1416_device::device_start()
save_item(NAME(m_cursor_enable));
save_item(NAME(m_write_enable));
save_item(NAME(m_digit_ram));
-
+
m_update_func.resolve(m_update, *this);
}
diff --git a/src/emu/video/hd63484.h b/src/emu/video/hd63484.h
index 7491311f576..2a154c612ec 100644
--- a/src/emu/video/hd63484.h
+++ b/src/emu/video/hd63484.h
@@ -48,7 +48,7 @@ protected:
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
-
+
private:
// internal state
UINT16 * m_ram;
@@ -64,7 +64,7 @@ private:
INT16 m_cpx, m_cpy;
int m_regno;
-
+
void doclr16( int opcode, UINT16 fill, int *dst, INT16 _ax, INT16 _ay );
void docpy16( int opcode, int src, int *dst, INT16 _ax, INT16 _ay );
int org_first_pixel( int _org_dpd );
@@ -76,9 +76,9 @@ private:
void line( INT16 sx, INT16 sy, INT16 ex, INT16 ey, INT16 col );
void circle( INT16 sx, INT16 sy, UINT16 r, INT16 col );
void paint( int sx, int sy, int col );
-
+
void command_w(UINT16 cmd);
-
+
};
extern ATTR_DEPRECATED const device_type HD63484;
diff --git a/src/emu/video/huc6260.c b/src/emu/video/huc6260.c
index e68a77ae0c3..d2c8af73bfa 100644
--- a/src/emu/video/huc6260.c
+++ b/src/emu/video/huc6260.c
@@ -62,7 +62,7 @@ void huc6260_device::device_config_complete()
huc6260_device::huc6260_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, HUC6260, "HuC6260", tag, owner, clock, "huc6260", __FILE__),
+ : device_t(mconfig, HUC6260, "HuC6260", tag, owner, clock, "huc6260", __FILE__),
device_video_interface(mconfig, *this)
{
}
diff --git a/src/emu/video/huc6261.c b/src/emu/video/huc6261.c
index 3067c4ffa51..cb8b7fd8c07 100644
--- a/src/emu/video/huc6261.c
+++ b/src/emu/video/huc6261.c
@@ -38,7 +38,7 @@ void huc6261_device::device_config_complete()
huc6261_device::huc6261_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, HUC6261, "HuC6261", tag, owner, clock, "huc6261", __FILE__),
+ : device_t(mconfig, HUC6261, "HuC6261", tag, owner, clock, "huc6261", __FILE__),
device_video_interface(mconfig, *this)
{
// Set up UV lookup table
diff --git a/src/emu/video/i8275.h b/src/emu/video/i8275.h
index 18109ef654a..c343632ebd6 100644
--- a/src/emu/video/i8275.h
+++ b/src/emu/video/i8275.h
@@ -59,7 +59,7 @@ struct i8275_interface
};
-class i8275_device : public device_t,
+class i8275_device : public device_t,
public device_video_interface,
public i8275_interface
{
diff --git a/src/emu/video/i8275x.h b/src/emu/video/i8275x.h
index 741c477b8c1..36f09dc74ef 100644
--- a/src/emu/video/i8275x.h
+++ b/src/emu/video/i8275x.h
@@ -50,11 +50,9 @@
downcast<i8275x_device *>(device)->set_drq_callback(DEVCB2_##_drq);
#define MCFG_I8275_IRQ_CALLBACK(_irq) \
- downcast<i8275x_device *>(device)->set_irq_callback(DEVCB2_##_irq); \
-
+ downcast<i8275x_device *>(device)->set_irq_callback(DEVCB2_##_irq);
#define MCFG_I8275_HRTC_CALLBACK(_hrtc) \
- downcast<i8275x_device *>(device)->set_hrtc_callback(DEVCB2_##_hrtc); \
-
+ downcast<i8275x_device *>(device)->set_hrtc_callback(DEVCB2_##_hrtc);
#define MCFG_I8275_VRTC_CALLBACK(_vrtc) \
downcast<i8275x_device *>(device)->set_vrtc_callback(DEVCB2_##_vrtc);
diff --git a/src/emu/video/polynew.h b/src/emu/video/polynew.h
index 2b51d3f3607..5703db7fc96 100644
--- a/src/emu/video/polynew.h
+++ b/src/emu/video/polynew.h
@@ -249,7 +249,7 @@ private:
// queue management
running_machine & m_machine;
- screen_device * m_screen;
+ screen_device * m_screen;
osd_work_queue * m_queue; // work queue
// arrays
diff --git a/src/emu/video/v9938.h b/src/emu/video/v9938.h
index c1ef73d40e0..4ec6b07262b 100644
--- a/src/emu/video/v9938.h
+++ b/src/emu/video/v9938.h
@@ -55,7 +55,7 @@ extern const device_type V9958;
// ======================> v99x8_device
-class v99x8_device : public device_t,
+class v99x8_device : public device_t,
public device_memory_interface,
public device_video_interface
{
@@ -77,9 +77,9 @@ public:
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
-
+
DECLARE_PALETTE_INIT(v9938);
-
+
UINT8 vram_r();
UINT8 status_r();
void palette_w(UINT8 data);
@@ -245,7 +245,7 @@ class v9938_device : public v99x8_device
{
public:
v9938_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
+
protected:
virtual machine_config_constructor device_mconfig_additions() const;
};
@@ -254,9 +254,9 @@ class v9958_device : public v99x8_device
{
public:
v9958_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
-
- DECLARE_PALETTE_INIT(v9958);
-
+
+ DECLARE_PALETTE_INIT(v9958);
+
protected:
virtual machine_config_constructor device_mconfig_additions() const;
};
diff --git a/src/emu/webengine.c b/src/emu/webengine.c
index 292eb6b0dfc..67cc254ac7e 100644
--- a/src/emu/webengine.c
+++ b/src/emu/webengine.c
@@ -48,18 +48,18 @@
// WEB ENGINE
//**************************************************************************
-void web_engine::websocket_ready_handler(struct mg_connection *conn) {
+void web_engine::websocket_ready_handler(struct mg_connection *conn) {
static const char *message = "update_machine";
mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, message, strlen(message));
m_websockets.append(*global_alloc(simple_list_wrapper<mg_connection>(conn)));
-}
+}
// Arguments:
// flags: first byte of websocket frame, see websocket RFC,
// http://tools.ietf.org/html/rfc6455, section 5.2
// data, data_len: payload data. Mask, if any, is already applied.
int web_engine::websocket_data_handler(struct mg_connection *conn, int flags,
- char *data, size_t data_len)
+ char *data, size_t data_len)
{
// just Echo example for now
if ((flags & 0x0f) == WEBSOCKET_OPCODE_TEXT)
@@ -68,15 +68,15 @@ int web_engine::websocket_data_handler(struct mg_connection *conn, int flags,
// Returning zero means stoping websocket conversation.
// Close the conversation if client has sent us "exit" string.
return memcmp(data, "exit", 4);
-}
+}
static void get_qsvar(const struct mg_request_info *request_info,
- const char *name, char *dst, size_t dst_len) {
- const char *qs = request_info->query_string;
- mg_get_var(qs, strlen(qs == NULL ? "" : qs), name, dst, dst_len);
+ const char *name, char *dst, size_t dst_len) {
+ const char *qs = request_info->query_string;
+ mg_get_var(qs, strlen(qs == NULL ? "" : qs), name, dst, dst_len);
}
-int web_engine::json_game_handler(struct mg_connection *conn)
+int web_engine::json_game_handler(struct mg_connection *conn)
{
Json::Value data;
data["name"] = m_machine->system().name;
@@ -103,12 +103,12 @@ int web_engine::json_game_handler(struct mg_connection *conn)
return 1;
}
-int web_engine::json_slider_handler(struct mg_connection *conn)
+int web_engine::json_slider_handler(struct mg_connection *conn)
{
const slider_state *curslider;
astring tempstring;
Json::Value array(Json::arrayValue);
-
+
/* add all sliders */
for (curslider = ui_get_slider_list(); curslider != NULL; curslider = curslider->next)
{
@@ -151,29 +151,29 @@ int web_engine::json_slider_handler(struct mg_connection *conn)
}
// This function will be called by mongoose on every new request.
-int web_engine::begin_request_handler(struct mg_connection *conn)
+int web_engine::begin_request_handler(struct mg_connection *conn)
{
const struct mg_request_info *request_info = mg_get_request_info(conn);
- if (!strncmp(request_info->uri, "/json/",6))
+ if (!strncmp(request_info->uri, "/json/",6))
{
- if (!strcmp(request_info->uri, "/json/game"))
+ if (!strcmp(request_info->uri, "/json/game"))
{
return json_game_handler(conn);
- }
- if (!strcmp(request_info->uri, "/json/slider"))
+ }
+ if (!strcmp(request_info->uri, "/json/slider"))
{
return json_slider_handler(conn);
- }
+ }
}
- else if (!strncmp(request_info->uri, "/cmd",4))
+ else if (!strncmp(request_info->uri, "/cmd",4))
{
char cmd_name[64];
get_qsvar(request_info, "name", cmd_name, sizeof(cmd_name));
-
+
if(!strcmp(cmd_name,"softreset"))
{
m_machine->schedule_soft_reset();
- }
+ }
else if(!strcmp(cmd_name,"hardreset"))
{
m_machine->schedule_hard_reset();
@@ -181,8 +181,8 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
else if(!strcmp(cmd_name,"exit"))
{
m_machine->schedule_exit();
- }
-
+ }
+
// Send HTTP reply to the client
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
@@ -195,7 +195,7 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
// the client, and mongoose should not send client any more data.
return 1;
}
- else if (!strncmp(request_info->uri, "/slider",7))
+ else if (!strncmp(request_info->uri, "/slider",7))
{
char cmd_id[64];
char cmd_val[64];
@@ -206,17 +206,17 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
const slider_state *curslider;
for (curslider = ui_get_slider_list(); curslider != NULL; curslider = curslider->next)
{
- if (cnt==id)
+ if (cnt==id)
(*curslider->update)(machine(), curslider->arg, NULL, atoi(cmd_val));
cnt++;
}
for (curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next)
{
- if (cnt==id)
+ if (cnt==id)
(*curslider->update)(machine(), curslider->arg, NULL, atoi(cmd_val));
cnt++;
}
-
+
// Send HTTP reply to the client
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
@@ -229,7 +229,7 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
// the client, and mongoose should not send client any more data.
return 1;
}
- else if (!strncmp(request_info->uri, "/screenshot.png",15))
+ else if (!strncmp(request_info->uri, "/screenshot.png",15))
{
screen_device_iterator iter(m_machine->root_device());
screen_device *screen = iter.first();
@@ -251,25 +251,25 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
m_machine->video().save_snapshot(screen, file);
astring fullpath(file.fullpath());
file.close();
-
+
mg_send_file(conn,fullpath);
return 1;
}
return 0;
-}
+}
-void *web_engine::websocket_keepalive()
+void *web_engine::websocket_keepalive()
{
- while(!m_exiting_core)
+ while(!m_exiting_core)
{
- osd_ticks_t curtime = osd_ticks();
+ osd_ticks_t curtime = osd_ticks();
if ((curtime - m_lastupdatetime) > osd_ticks_per_second() * 5)
{
m_lastupdatetime = curtime;
for (simple_list_wrapper<mg_connection> *curitem = m_websockets.first(); curitem != NULL; curitem = curitem->next())
{
- int status = mg_websocket_write(curitem->object(), WEBSOCKET_OPCODE_PING, NULL, 0);
+ int status = mg_websocket_write(curitem->object(), WEBSOCKET_OPCODE_PING, NULL, 0);
if (status==0) m_websockets.detach(*curitem); // remove inactive clients
}
}
@@ -284,26 +284,26 @@ void *web_engine::websocket_keepalive()
static void websocket_ready_handler_static(struct mg_connection *conn)
{
const struct mg_request_info *request_info = mg_get_request_info(conn);
- web_engine *engine = static_cast<web_engine *>(request_info->user_data);
+ web_engine *engine = static_cast<web_engine *>(request_info->user_data);
engine->websocket_ready_handler(conn);
}
static int websocket_data_handler_static(struct mg_connection *conn, int flags,
- char *data, size_t data_len)
+ char *data, size_t data_len)
{
const struct mg_request_info *request_info = mg_get_request_info(conn);
- web_engine *engine = static_cast<web_engine *>(request_info->user_data);
+ web_engine *engine = static_cast<web_engine *>(request_info->user_data);
return engine->websocket_data_handler(conn, flags, data, data_len);
}
-static int begin_request_handler_static(struct mg_connection *conn)
+static int begin_request_handler_static(struct mg_connection *conn)
{
- const struct mg_request_info *request_info = mg_get_request_info(conn);
- web_engine *engine = static_cast<web_engine *>(request_info->user_data);
+ const struct mg_request_info *request_info = mg_get_request_info(conn);
+ web_engine *engine = static_cast<web_engine *>(request_info->user_data);
return engine->begin_request_handler(conn);
}
-static void *websocket_keepalive_static(void *thread_func_param)
+static void *websocket_keepalive_static(void *thread_func_param)
{
web_engine *engine = static_cast<web_engine *>(thread_func_param);
return engine->websocket_keepalive();
@@ -315,35 +315,34 @@ static void *websocket_keepalive_static(void *thread_func_param)
web_engine::web_engine(emu_options &options)
: m_options(options),
- m_machine(NULL),
- m_ctx(NULL),
- m_lastupdatetime(0),
- m_exiting_core(false)
-
+ m_machine(NULL),
+ m_ctx(NULL),
+ m_lastupdatetime(0),
+ m_exiting_core(false)
+
{
-
struct mg_callbacks callbacks;
// List of options. Last element must be NULL.
const char *web_options[] = {
- "listening_ports", options.http_port(),
+ "listening_ports", options.http_port(),
"document_root", options.http_path(),
NULL
};
- // Prepare callbacks structure.
+ // Prepare callbacks structure.
memset(&callbacks, 0, sizeof(callbacks));
callbacks.begin_request = begin_request_handler_static;
- callbacks.websocket_ready = websocket_ready_handler_static;
- callbacks.websocket_data = websocket_data_handler_static;
+ callbacks.websocket_ready = websocket_ready_handler_static;
+ callbacks.websocket_data = websocket_data_handler_static;
// Start the web server.
if (m_options.http()) {
m_ctx = mg_start(&callbacks, this, web_options);
-
+
mg_start_thread(websocket_keepalive_static, this);
}
-
+
}
//-------------------------------------------------
@@ -368,7 +367,7 @@ void web_engine::close()
{
mg_websocket_write(curitem->object(), WEBSOCKET_OPCODE_CONNECTION_CLOSE, NULL, 0);
}
- // Stop the server.
+ // Stop the server.
mg_stop(m_ctx);
}
@@ -376,7 +375,7 @@ void web_engine::close()
void web_engine::push_message(const char *message)
{
for (simple_list_wrapper<mg_connection> *curitem = m_websockets.first(); curitem != NULL; curitem = curitem->next())
- {
+ {
int status = mg_websocket_write(curitem->object(), WEBSOCKET_OPCODE_TEXT, message, strlen(message));
if (status==0) m_websockets.detach(*curitem); // remove inactive clients
}
diff --git a/src/emu/webengine.h b/src/emu/webengine.h
index 1d54646a373..89db9d99c20 100644
--- a/src/emu/webengine.h
+++ b/src/emu/webengine.h
@@ -55,25 +55,25 @@ public:
void push_message(const char *message);
void close();
- void set_machine(running_machine &machine) { m_machine = &machine; }
-
+ void set_machine(running_machine &machine) { m_machine = &machine; }
+
void websocket_ready_handler(struct mg_connection *conn);
int websocket_data_handler(struct mg_connection *conn, int flags, char *data, size_t data_len);
- int begin_request_handler(struct mg_connection *conn);
- void *websocket_keepalive();
+ int begin_request_handler(struct mg_connection *conn);
+ void *websocket_keepalive();
protected:
// getters
running_machine &machine() const { return *m_machine; }
-
+
int json_game_handler(struct mg_connection *conn);
int json_slider_handler(struct mg_connection *conn);
private:
// internal state
- emu_options & m_options;
- running_machine * m_machine;
+ emu_options & m_options;
+ running_machine * m_machine;
struct mg_context * m_ctx;
- osd_ticks_t m_lastupdatetime;
- bool m_exiting_core;
+ osd_ticks_t m_lastupdatetime;
+ bool m_exiting_core;
simple_list<simple_list_wrapper<mg_connection> > m_websockets;
};
diff --git a/src/lib/formats/cpis_dsk.c b/src/lib/formats/cpis_dsk.c
index f42dec457d0..d5c1f5ad6fe 100644
--- a/src/lib/formats/cpis_dsk.c
+++ b/src/lib/formats/cpis_dsk.c
@@ -184,4 +184,3 @@ const cpis_format::format cpis_format::formats[] = {
};
const floppy_format_type FLOPPY_CPIS_FORMAT = &floppy_image_format_creator<cpis_format>;
-
diff --git a/src/lib/formats/g64_dsk.c b/src/lib/formats/g64_dsk.c
index 475e1f45893..42ef8fbac38 100644
--- a/src/lib/formats/g64_dsk.c
+++ b/src/lib/formats/g64_dsk.c
@@ -196,7 +196,7 @@ const floppy_format_type FLOPPY_G64_FORMAT = &floppy_image_format_creator<g64_fo
***************************************************************************/
#define HEADER_LENGTH 0x2ac // standard length for 84 half tracks
-#define MAX_HEADS 2
+#define MAX_HEADS 2
#define MAX_TRACKS 84
/***************************************************************************
@@ -206,11 +206,11 @@ const floppy_format_type FLOPPY_G64_FORMAT = &floppy_image_format_creator<g64_fo
struct g64dsk_tag
{
int version;
- int heads; // number of physical heads
- int tracks; // number of physical tracks
- UINT16 track_size[MAX_HEADS][MAX_TRACKS]; // size of each track
- UINT32 track_offset[MAX_HEADS][MAX_TRACKS]; // offset within data for each track
- UINT32 speed_zone_offset[MAX_HEADS][MAX_TRACKS]; // offset within data for each track
+ int heads; // number of physical heads
+ int tracks; // number of physical tracks
+ UINT16 track_size[MAX_HEADS][MAX_TRACKS]; // size of each track
+ UINT32 track_offset[MAX_HEADS][MAX_TRACKS]; // offset within data for each track
+ UINT32 speed_zone_offset[MAX_HEADS][MAX_TRACKS]; // offset within data for each track
};
/***************************************************************************
@@ -466,7 +466,7 @@ static void read_g64_header(floppy_image_legacy *floppy, struct g64dsk_tag *tag,
for (int i = 0; i < tag->tracks; i++)
{
tag->speed_zone_offset[head][i] = pick_integer_le(header, pos, 4);
-
+
if (tag->speed_zone_offset[head][i] >= 4)
{
tag->speed_zone_offset[head][i] += start_pos;
diff --git a/src/lib/web/json/config.h b/src/lib/web/json/config.h
index 7609d45e7a0..9ca6311c20b 100644
--- a/src/lib/web/json/config.h
+++ b/src/lib/web/json/config.h
@@ -71,23 +71,23 @@
#endif // if !defined(JSONCPP_DEPRECATED)
namespace Json {
- typedef int Int;
- typedef unsigned int UInt;
+ typedef int Int;
+ typedef unsigned int UInt;
# if defined(JSON_NO_INT64)
- typedef int LargestInt;
- typedef unsigned int LargestUInt;
+ typedef int LargestInt;
+ typedef unsigned int LargestUInt;
# undef JSON_HAS_INT64
# else // if defined(JSON_NO_INT64)
- // For Microsoft Visual use specific types as long long is not supported
+ // For Microsoft Visual use specific types as long long is not supported
# if defined(_MSC_VER) // Microsoft Visual Studio
- typedef __int64 Int64;
- typedef unsigned __int64 UInt64;
+ typedef __int64 Int64;
+ typedef unsigned __int64 UInt64;
# else // if defined(_MSC_VER) // Other platforms, use long long
- typedef long long int Int64;
- typedef unsigned long long int UInt64;
+ typedef long long int Int64;
+ typedef unsigned long long int UInt64;
# endif // if defined(_MSC_VER)
- typedef Int64 LargestInt;
- typedef UInt64 LargestUInt;
+ typedef Int64 LargestInt;
+ typedef UInt64 LargestUInt;
# define JSON_HAS_INT64
# endif // if defined(JSON_NO_INT64)
} // end namespace Json
diff --git a/src/lib/web/json/features.h b/src/lib/web/json/features.h
index 4353278446d..8c7eb0f4922 100644
--- a/src/lib/web/json/features.h
+++ b/src/lib/web/json/features.h
@@ -11,38 +11,37 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
-
- /** \brief Configuration passed to reader and writer.
- * This configuration object can be used to force the Reader or Writer
- * to behave in a standard conforming way.
- */
- class JSON_API Features
- {
- public:
- /** \brief A configuration that allows all features and assumes all strings are UTF-8.
- * - C & C++ comments are allowed
- * - Root object can be any JSON value
- * - Assumes Value strings are encoded in UTF-8
- */
- static Features all();
-
- /** \brief A configuration that is strictly compatible with the JSON specification.
- * - Comments are forbidden.
- * - Root object must be either an array or an object value.
- * - Assumes Value strings are encoded in UTF-8
- */
- static Features strictMode();
-
- /** \brief Initialize the configuration like JsonConfig::allFeatures;
- */
- Features();
-
- /// \c true if comments are allowed. Default: \c true.
- bool allowComments_;
-
- /// \c true if root must be either an array or an object value. Default: \c false.
- bool strictRoot_;
- };
+ /** \brief Configuration passed to reader and writer.
+ * This configuration object can be used to force the Reader or Writer
+ * to behave in a standard conforming way.
+ */
+ class JSON_API Features
+ {
+ public:
+ /** \brief A configuration that allows all features and assumes all strings are UTF-8.
+ * - C & C++ comments are allowed
+ * - Root object can be any JSON value
+ * - Assumes Value strings are encoded in UTF-8
+ */
+ static Features all();
+
+ /** \brief A configuration that is strictly compatible with the JSON specification.
+ * - Comments are forbidden.
+ * - Root object must be either an array or an object value.
+ * - Assumes Value strings are encoded in UTF-8
+ */
+ static Features strictMode();
+
+ /** \brief Initialize the configuration like JsonConfig::allFeatures;
+ */
+ Features();
+
+ /// \c true if comments are allowed. Default: \c true.
+ bool allowComments_;
+
+ /// \c true if root must be either an array or an object value. Default: \c false.
+ bool strictRoot_;
+ };
} // namespace Json
diff --git a/src/lib/web/json/forwards.h b/src/lib/web/json/forwards.h
index ab863da853b..51abad7ce18 100644
--- a/src/lib/web/json/forwards.h
+++ b/src/lib/web/json/forwards.h
@@ -11,31 +11,30 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
-
- // writer.h
- class FastWriter;
- class StyledWriter;
-
- // reader.h
- class Reader;
-
- // features.h
- class Features;
-
- // value.h
- typedef unsigned int ArrayIndex;
- class StaticString;
- class Path;
- class PathArgument;
- class Value;
- class ValueIteratorBase;
- class ValueIterator;
- class ValueConstIterator;
+ // writer.h
+ class FastWriter;
+ class StyledWriter;
+
+ // reader.h
+ class Reader;
+
+ // features.h
+ class Features;
+
+ // value.h
+ typedef unsigned int ArrayIndex;
+ class StaticString;
+ class Path;
+ class PathArgument;
+ class Value;
+ class ValueIteratorBase;
+ class ValueIterator;
+ class ValueConstIterator;
#ifdef JSON_VALUE_USE_INTERNAL_MAP
- class ValueMapAllocator;
- class ValueInternalLink;
- class ValueInternalArray;
- class ValueInternalMap;
+ class ValueMapAllocator;
+ class ValueInternalLink;
+ class ValueInternalArray;
+ class ValueInternalMap;
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
} // namespace Json
diff --git a/src/lib/web/json/json_batchallocator.h b/src/lib/web/json/json_batchallocator.h
index 173e2ed2570..0093b8cc413 100644
--- a/src/lib/web/json/json_batchallocator.h
+++ b/src/lib/web/json/json_batchallocator.h
@@ -12,7 +12,6 @@
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
namespace Json {
-
/* Fast memory allocator.
*
* This memory allocator allocates memory for a batch of object (specified by
@@ -21,104 +20,104 @@ namespace Json {
* It does not allow the destruction of a single object. All the allocated objects
* can be destroyed at once. The memory can be either released or reused for future
* allocation.
- *
+ *
* The in-place new operator must be used to construct the object using the pointer
* returned by allocate.
*/
template<typename AllocatedType
- ,const unsigned int objectPerAllocation>
+ ,const unsigned int objectPerAllocation>
class BatchAllocator
{
public:
- typedef AllocatedType Type;
+ typedef AllocatedType Type;
- BatchAllocator( unsigned int objectsPerPage = 255 )
- : freeHead_( 0 )
- , objectsPerPage_( objectsPerPage )
- {
+ BatchAllocator( unsigned int objectsPerPage = 255 )
+ : freeHead_( 0 )
+ , objectsPerPage_( objectsPerPage )
+ {
// printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() );
- assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space.
- assert( objectsPerPage >= 16 );
- batches_ = allocateBatch( 0 ); // allocated a dummy page
- currentBatch_ = batches_;
- }
-
- ~BatchAllocator()
- {
- for ( BatchInfo *batch = batches_; batch; )
- {
- BatchInfo *nextBatch = batch->next_;
- free( batch );
- batch = nextBatch;
- }
- }
-
- /// allocate space for an array of objectPerAllocation object.
- /// @warning it is the responsability of the caller to call objects constructors.
- AllocatedType *allocate()
- {
- if ( freeHead_ ) // returns node from free list.
- {
- AllocatedType *object = freeHead_;
- freeHead_ = *(AllocatedType **)object;
- return object;
- }
- if ( currentBatch_->used_ == currentBatch_->end_ )
- {
- currentBatch_ = currentBatch_->next_;
- while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ )
- currentBatch_ = currentBatch_->next_;
-
- if ( !currentBatch_ ) // no free batch found, allocate a new one
- {
- currentBatch_ = allocateBatch( objectsPerPage_ );
- currentBatch_->next_ = batches_; // insert at the head of the list
- batches_ = currentBatch_;
- }
- }
- AllocatedType *allocated = currentBatch_->used_;
- currentBatch_->used_ += objectPerAllocation;
- return allocated;
- }
-
- /// Release the object.
- /// @warning it is the responsability of the caller to actually destruct the object.
- void release( AllocatedType *object )
- {
- assert( object != 0 );
- *(AllocatedType **)object = freeHead_;
- freeHead_ = object;
- }
+ assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space.
+ assert( objectsPerPage >= 16 );
+ batches_ = allocateBatch( 0 ); // allocated a dummy page
+ currentBatch_ = batches_;
+ }
+
+ ~BatchAllocator()
+ {
+ for ( BatchInfo *batch = batches_; batch; )
+ {
+ BatchInfo *nextBatch = batch->next_;
+ free( batch );
+ batch = nextBatch;
+ }
+ }
+
+ /// allocate space for an array of objectPerAllocation object.
+ /// @warning it is the responsability of the caller to call objects constructors.
+ AllocatedType *allocate()
+ {
+ if ( freeHead_ ) // returns node from free list.
+ {
+ AllocatedType *object = freeHead_;
+ freeHead_ = *(AllocatedType **)object;
+ return object;
+ }
+ if ( currentBatch_->used_ == currentBatch_->end_ )
+ {
+ currentBatch_ = currentBatch_->next_;
+ while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ )
+ currentBatch_ = currentBatch_->next_;
+
+ if ( !currentBatch_ ) // no free batch found, allocate a new one
+ {
+ currentBatch_ = allocateBatch( objectsPerPage_ );
+ currentBatch_->next_ = batches_; // insert at the head of the list
+ batches_ = currentBatch_;
+ }
+ }
+ AllocatedType *allocated = currentBatch_->used_;
+ currentBatch_->used_ += objectPerAllocation;
+ return allocated;
+ }
+
+ /// Release the object.
+ /// @warning it is the responsability of the caller to actually destruct the object.
+ void release( AllocatedType *object )
+ {
+ assert( object != 0 );
+ *(AllocatedType **)object = freeHead_;
+ freeHead_ = object;
+ }
private:
- struct BatchInfo
- {
- BatchInfo *next_;
- AllocatedType *used_;
- AllocatedType *end_;
- AllocatedType buffer_[objectPerAllocation];
- };
-
- // disabled copy constructor and assignement operator.
- BatchAllocator( const BatchAllocator & );
- void operator =( const BatchAllocator &);
-
- static BatchInfo *allocateBatch( unsigned int objectsPerPage )
- {
- const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation
- + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
- BatchInfo *batch = static_cast<BatchInfo*>( malloc( mallocSize ) );
- batch->next_ = 0;
- batch->used_ = batch->buffer_;
- batch->end_ = batch->buffer_ + objectsPerPage;
- return batch;
- }
-
- BatchInfo *batches_;
- BatchInfo *currentBatch_;
- /// Head of a single linked list within the allocated space of freeed object
- AllocatedType *freeHead_;
- unsigned int objectsPerPage_;
+ struct BatchInfo
+ {
+ BatchInfo *next_;
+ AllocatedType *used_;
+ AllocatedType *end_;
+ AllocatedType buffer_[objectPerAllocation];
+ };
+
+ // disabled copy constructor and assignement operator.
+ BatchAllocator( const BatchAllocator & );
+ void operator =( const BatchAllocator &);
+
+ static BatchInfo *allocateBatch( unsigned int objectsPerPage )
+ {
+ const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation
+ + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
+ BatchInfo *batch = static_cast<BatchInfo*>( malloc( mallocSize ) );
+ batch->next_ = 0;
+ batch->used_ = batch->buffer_;
+ batch->end_ = batch->buffer_ + objectsPerPage;
+ return batch;
+ }
+
+ BatchInfo *batches_;
+ BatchInfo *currentBatch_;
+ /// Head of a single linked list within the allocated space of freeed object
+ AllocatedType *freeHead_;
+ unsigned int objectsPerPage_;
};
@@ -127,4 +126,3 @@ private:
# endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
-
diff --git a/src/lib/web/json/json_tool.h b/src/lib/web/json/json_tool.h
index 658031bbba3..9ad8b0cb95c 100644
--- a/src/lib/web/json/json_tool.h
+++ b/src/lib/web/json/json_tool.h
@@ -13,57 +13,56 @@
*/
namespace Json {
-
/// Converts a unicode code-point to UTF-8.
-static inline std::string
+static inline std::string
codePointToUTF8(unsigned int cp)
{
- std::string result;
-
- // based on description from http://en.wikipedia.org/wiki/UTF-8
+ std::string result;
+
+ // based on description from http://en.wikipedia.org/wiki/UTF-8
- if (cp <= 0x7f)
- {
- result.resize(1);
- result[0] = static_cast<char>(cp);
- }
- else if (cp <= 0x7FF)
- {
- result.resize(2);
- result[1] = static_cast<char>(0x80 | (0x3f & cp));
- result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
- }
- else if (cp <= 0xFFFF)
- {
- result.resize(3);
- result[2] = static_cast<char>(0x80 | (0x3f & cp));
- result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
- result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
- }
- else if (cp <= 0x10FFFF)
- {
- result.resize(4);
- result[3] = static_cast<char>(0x80 | (0x3f & cp));
- result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
- result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
- result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
- }
+ if (cp <= 0x7f)
+ {
+ result.resize(1);
+ result[0] = static_cast<char>(cp);
+ }
+ else if (cp <= 0x7FF)
+ {
+ result.resize(2);
+ result[1] = static_cast<char>(0x80 | (0x3f & cp));
+ result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
+ }
+ else if (cp <= 0xFFFF)
+ {
+ result.resize(3);
+ result[2] = static_cast<char>(0x80 | (0x3f & cp));
+ result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
+ result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
+ }
+ else if (cp <= 0x10FFFF)
+ {
+ result.resize(4);
+ result[3] = static_cast<char>(0x80 | (0x3f & cp));
+ result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
+ result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
+ result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
+ }
- return result;
+ return result;
}
/// Returns true if ch is a control character (in range [0,32[).
-static inline bool
+static inline bool
isControlCharacter(char ch)
{
- return ch > 0 && ch <= 0x1F;
+ return ch > 0 && ch <= 0x1F;
}
-enum {
- /// Constant that specify the size of the buffer that must be passed to uintToString.
- uintToStringBufferSize = 3*sizeof(LargestUInt)+1
+enum {
+ /// Constant that specify the size of the buffer that must be passed to uintToString.
+ uintToStringBufferSize = 3*sizeof(LargestUInt)+1
};
// Defines a char buffer for use with uintToString().
@@ -72,22 +71,21 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
/** Converts an unsigned integer to string.
* @param value Unsigned interger to convert to string
- * @param current Input/Output string buffer.
+ * @param current Input/Output string buffer.
* Must have at least uintToStringBufferSize chars free.
*/
-static inline void
-uintToString( LargestUInt value,
- char *&current )
+static inline void
+uintToString( LargestUInt value,
+ char *&current )
{
- *--current = 0;
- do
- {
- *--current = char(value % 10) + '0';
- value /= 10;
- }
- while ( value != 0 );
+ *--current = 0;
+ do
+ {
+ *--current = char(value % 10) + '0';
+ value /= 10;
+ }
+ while ( value != 0 );
}
} // namespace Json {
-
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
diff --git a/src/lib/web/json/reader.h b/src/lib/web/json/reader.h
index 0a324dfc5c8..270a0901e04 100644
--- a/src/lib/web/json/reader.h
+++ b/src/lib/web/json/reader.h
@@ -16,198 +16,197 @@
# include <iostream>
namespace Json {
-
- /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
- *
- */
- class JSON_API Reader
- {
- public:
- typedef char Char;
- typedef const Char *Location;
-
- /** \brief Constructs a Reader allowing all features
- * for parsing.
- */
- Reader();
-
- /** \brief Constructs a Reader allowing the specified feature set
- * for parsing.
- */
- Reader( const Features &features );
-
- /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
- * \param document UTF-8 encoded string containing the document to read.
- * \param root [out] Contains the root value of the document if it was
- * successfully parsed.
- * \param collectComments \c true to collect comment and allow writing them back during
- * serialization, \c false to discard comments.
- * This parameter is ignored if Features::allowComments_
- * is \c false.
- * \return \c true if the document was successfully parsed, \c false if an error occurred.
- */
- bool parse( const std::string &document,
- Value &root,
- bool collectComments = true );
-
- /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
- * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the document to read.
- * \param endDoc Pointer on the end of the UTF-8 encoded string of the document to read.
- \ Must be >= beginDoc.
- * \param root [out] Contains the root value of the document if it was
- * successfully parsed.
- * \param collectComments \c true to collect comment and allow writing them back during
- * serialization, \c false to discard comments.
- * This parameter is ignored if Features::allowComments_
- * is \c false.
- * \return \c true if the document was successfully parsed, \c false if an error occurred.
- */
- bool parse( const char *beginDoc, const char *endDoc,
- Value &root,
- bool collectComments = true );
-
- /// \brief Parse from input stream.
- /// \see Json::operator>>(std::istream&, Json::Value&).
- bool parse( std::istream &is,
- Value &root,
- bool collectComments = true );
-
- /** \brief Returns a user friendly string that list errors in the parsed document.
- * \return Formatted error message with the list of errors with their location in
- * the parsed document. An empty string is returned if no error occurred
- * during parsing.
- * \deprecated Use getFormattedErrorMessages() instead (typo fix).
- */
- JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead")
- std::string getFormatedErrorMessages() const;
-
- /** \brief Returns a user friendly string that list errors in the parsed document.
- * \return Formatted error message with the list of errors with their location in
- * the parsed document. An empty string is returned if no error occurred
- * during parsing.
- */
- std::string getFormattedErrorMessages() const;
-
- private:
- enum TokenType
- {
- tokenEndOfStream = 0,
- tokenObjectBegin,
- tokenObjectEnd,
- tokenArrayBegin,
- tokenArrayEnd,
- tokenString,
- tokenNumber,
- tokenTrue,
- tokenFalse,
- tokenNull,
- tokenArraySeparator,
- tokenMemberSeparator,
- tokenComment,
- tokenError
- };
-
- class Token
- {
- public:
- TokenType type_;
- Location start_;
- Location end_;
- };
-
- class ErrorInfo
- {
- public:
- Token token_;
- std::string message_;
- Location extra_;
- };
-
- typedef std::deque<ErrorInfo> Errors;
-
- bool expectToken( TokenType type, Token &token, const char *message );
- bool readToken( Token &token );
- void skipSpaces();
- bool match( Location pattern,
- int patternLength );
- bool readComment();
- bool readCStyleComment();
- bool readCppStyleComment();
- bool readString();
- void readNumber();
- bool readValue();
- bool readObject( Token &token );
- bool readArray( Token &token );
- bool decodeNumber( Token &token );
- bool decodeString( Token &token );
- bool decodeString( Token &token, std::string &decoded );
- bool decodeDouble( Token &token );
- bool decodeUnicodeCodePoint( Token &token,
- Location &current,
- Location end,
- unsigned int &unicode );
- bool decodeUnicodeEscapeSequence( Token &token,
- Location &current,
- Location end,
- unsigned int &unicode );
- bool addError( const std::string &message,
- Token &token,
- Location extra = 0 );
- bool recoverFromError( TokenType skipUntilToken );
- bool addErrorAndRecover( const std::string &message,
- Token &token,
- TokenType skipUntilToken );
- void skipUntilSpace();
- Value &currentValue();
- Char getNextChar();
- void getLocationLineAndColumn( Location location,
- int &line,
- int &column ) const;
- std::string getLocationLineAndColumn( Location location ) const;
- void addComment( Location begin,
- Location end,
- CommentPlacement placement );
- void skipCommentTokens( Token &token );
-
- typedef std::stack<Value *> Nodes;
- Nodes nodes_;
- Errors errors_;
- std::string document_;
- Location begin_;
- Location end_;
- Location current_;
- Location lastValueEnd_;
- Value *lastValue_;
- std::string commentsBefore_;
- Features features_;
- bool collectComments_;
- };
-
- /** \brief Read from 'sin' into 'root'.
-
- Always keep comments from the input JSON.
-
- This can be used to read a file into a particular sub-object.
- For example:
- \code
- Json::Value root;
- cin >> root["dir"]["file"];
- cout << root;
- \endcode
- Result:
- \verbatim
- {
- "dir": {
- "file": {
- // The input stream JSON would be nested here.
- }
- }
- }
- \endverbatim
- \throw std::exception on parse error.
- \see Json::operator<<()
- */
- std::istream& operator>>( std::istream&, Value& );
+ /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
+ *
+ */
+ class JSON_API Reader
+ {
+ public:
+ typedef char Char;
+ typedef const Char *Location;
+
+ /** \brief Constructs a Reader allowing all features
+ * for parsing.
+ */
+ Reader();
+
+ /** \brief Constructs a Reader allowing the specified feature set
+ * for parsing.
+ */
+ Reader( const Features &features );
+
+ /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
+ * \param document UTF-8 encoded string containing the document to read.
+ * \param root [out] Contains the root value of the document if it was
+ * successfully parsed.
+ * \param collectComments \c true to collect comment and allow writing them back during
+ * serialization, \c false to discard comments.
+ * This parameter is ignored if Features::allowComments_
+ * is \c false.
+ * \return \c true if the document was successfully parsed, \c false if an error occurred.
+ */
+ bool parse( const std::string &document,
+ Value &root,
+ bool collectComments = true );
+
+ /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
+ * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the document to read.
+ * \param endDoc Pointer on the end of the UTF-8 encoded string of the document to read.
+ \ Must be >= beginDoc.
+ * \param root [out] Contains the root value of the document if it was
+ * successfully parsed.
+ * \param collectComments \c true to collect comment and allow writing them back during
+ * serialization, \c false to discard comments.
+ * This parameter is ignored if Features::allowComments_
+ * is \c false.
+ * \return \c true if the document was successfully parsed, \c false if an error occurred.
+ */
+ bool parse( const char *beginDoc, const char *endDoc,
+ Value &root,
+ bool collectComments = true );
+
+ /// \brief Parse from input stream.
+ /// \see Json::operator>>(std::istream&, Json::Value&).
+ bool parse( std::istream &is,
+ Value &root,
+ bool collectComments = true );
+
+ /** \brief Returns a user friendly string that list errors in the parsed document.
+ * \return Formatted error message with the list of errors with their location in
+ * the parsed document. An empty string is returned if no error occurred
+ * during parsing.
+ * \deprecated Use getFormattedErrorMessages() instead (typo fix).
+ */
+ JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead")
+ std::string getFormatedErrorMessages() const;
+
+ /** \brief Returns a user friendly string that list errors in the parsed document.
+ * \return Formatted error message with the list of errors with their location in
+ * the parsed document. An empty string is returned if no error occurred
+ * during parsing.
+ */
+ std::string getFormattedErrorMessages() const;
+
+ private:
+ enum TokenType
+ {
+ tokenEndOfStream = 0,
+ tokenObjectBegin,
+ tokenObjectEnd,
+ tokenArrayBegin,
+ tokenArrayEnd,
+ tokenString,
+ tokenNumber,
+ tokenTrue,
+ tokenFalse,
+ tokenNull,
+ tokenArraySeparator,
+ tokenMemberSeparator,
+ tokenComment,
+ tokenError
+ };
+
+ class Token
+ {
+ public:
+ TokenType type_;
+ Location start_;
+ Location end_;
+ };
+
+ class ErrorInfo
+ {
+ public:
+ Token token_;
+ std::string message_;
+ Location extra_;
+ };
+
+ typedef std::deque<ErrorInfo> Errors;
+
+ bool expectToken( TokenType type, Token &token, const char *message );
+ bool readToken( Token &token );
+ void skipSpaces();
+ bool match( Location pattern,
+ int patternLength );
+ bool readComment();
+ bool readCStyleComment();
+ bool readCppStyleComment();
+ bool readString();
+ void readNumber();
+ bool readValue();
+ bool readObject( Token &token );
+ bool readArray( Token &token );
+ bool decodeNumber( Token &token );
+ bool decodeString( Token &token );
+ bool decodeString( Token &token, std::string &decoded );
+ bool decodeDouble( Token &token );
+ bool decodeUnicodeCodePoint( Token &token,
+ Location &current,
+ Location end,
+ unsigned int &unicode );
+ bool decodeUnicodeEscapeSequence( Token &token,
+ Location &current,
+ Location end,
+ unsigned int &unicode );
+ bool addError( const std::string &message,
+ Token &token,
+ Location extra = 0 );
+ bool recoverFromError( TokenType skipUntilToken );
+ bool addErrorAndRecover( const std::string &message,
+ Token &token,
+ TokenType skipUntilToken );
+ void skipUntilSpace();
+ Value &currentValue();
+ Char getNextChar();
+ void getLocationLineAndColumn( Location location,
+ int &line,
+ int &column ) const;
+ std::string getLocationLineAndColumn( Location location ) const;
+ void addComment( Location begin,
+ Location end,
+ CommentPlacement placement );
+ void skipCommentTokens( Token &token );
+
+ typedef std::stack<Value *> Nodes;
+ Nodes nodes_;
+ Errors errors_;
+ std::string document_;
+ Location begin_;
+ Location end_;
+ Location current_;
+ Location lastValueEnd_;
+ Value *lastValue_;
+ std::string commentsBefore_;
+ Features features_;
+ bool collectComments_;
+ };
+
+ /** \brief Read from 'sin' into 'root'.
+
+ Always keep comments from the input JSON.
+
+ This can be used to read a file into a particular sub-object.
+ For example:
+ \code
+ Json::Value root;
+ cin >> root["dir"]["file"];
+ cout << root;
+ \endcode
+ Result:
+ \verbatim
+ {
+ "dir": {
+ "file": {
+ // The input stream JSON would be nested here.
+ }
+ }
+ }
+ \endverbatim
+ \throw std::exception on parse error.
+ \see Json::operator<<()
+ */
+ std::istream& operator>>( std::istream&, Value& );
} // namespace Json
diff --git a/src/lib/web/json/value.h b/src/lib/web/json/value.h
index 32e3455ec6c..2d67c8cf600 100644
--- a/src/lib/web/json/value.h
+++ b/src/lib/web/json/value.h
@@ -24,1077 +24,1076 @@
/** \brief JSON (JavaScript Object Notation).
*/
namespace Json {
-
- /** \brief Type of the value held by a Value object.
- */
- enum ValueType
- {
- nullValue = 0, ///< 'null' value
- intValue, ///< signed integer value
- uintValue, ///< unsigned integer value
- realValue, ///< double value
- stringValue, ///< UTF-8 string value
- booleanValue, ///< bool value
- arrayValue, ///< array value (ordered list)
- objectValue ///< object value (collection of name/value pairs).
- };
-
- enum CommentPlacement
- {
- commentBefore = 0, ///< a comment placed on the line before a value
- commentAfterOnSameLine, ///< a comment just after a value on the same line
- commentAfter, ///< a comment on the line after a value (only make sense for root value)
- numberOfCommentPlacement
- };
+ /** \brief Type of the value held by a Value object.
+ */
+ enum ValueType
+ {
+ nullValue = 0, ///< 'null' value
+ intValue, ///< signed integer value
+ uintValue, ///< unsigned integer value
+ realValue, ///< double value
+ stringValue, ///< UTF-8 string value
+ booleanValue, ///< bool value
+ arrayValue, ///< array value (ordered list)
+ objectValue ///< object value (collection of name/value pairs).
+ };
+
+ enum CommentPlacement
+ {
+ commentBefore = 0, ///< a comment placed on the line before a value
+ commentAfterOnSameLine, ///< a comment just after a value on the same line
+ commentAfter, ///< a comment on the line after a value (only make sense for root value)
+ numberOfCommentPlacement
+ };
//# ifdef JSON_USE_CPPTL
// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
//# endif
- /** \brief Lightweight wrapper to tag static string.
- *
- * Value constructor and objectValue member assignement takes advantage of the
- * StaticString and avoid the cost of string duplication when storing the
- * string or the member name.
- *
- * Example of usage:
- * \code
- * Json::Value aValue( StaticString("some text") );
- * Json::Value object;
- * static const StaticString code("code");
- * object[code] = 1234;
- * \endcode
- */
- class JSON_API StaticString
- {
- public:
- explicit StaticString( const char *czstring )
- : str_( czstring )
- {
- }
-
- operator const char *() const
- {
- return str_;
- }
-
- const char *c_str() const
- {
- return str_;
- }
-
- private:
- const char *str_;
- };
-
- /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
- *
- * This class is a discriminated union wrapper that can represents a:
- * - signed integer [range: Value::minInt - Value::maxInt]
- * - unsigned integer (range: 0 - Value::maxUInt)
- * - double
- * - UTF-8 string
- * - boolean
- * - 'null'
- * - an ordered list of Value
- * - collection of name/value pairs (javascript object)
- *
- * The type of the held value is represented by a #ValueType and
- * can be obtained using type().
- *
- * values of an #objectValue or #arrayValue can be accessed using operator[]() methods.
- * Non const methods will automatically create the a #nullValue element
- * if it does not exist.
- * The sequence of an #arrayValue will be automatically resize and initialized
- * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
- *
- * The get() methods can be used to obtanis default value in the case the required element
- * does not exist.
- *
- * It is possible to iterate over the list of a #objectValue values using
- * the getMemberNames() method.
- */
- class JSON_API Value
- {
- friend class ValueIteratorBase;
+ /** \brief Lightweight wrapper to tag static string.
+ *
+ * Value constructor and objectValue member assignement takes advantage of the
+ * StaticString and avoid the cost of string duplication when storing the
+ * string or the member name.
+ *
+ * Example of usage:
+ * \code
+ * Json::Value aValue( StaticString("some text") );
+ * Json::Value object;
+ * static const StaticString code("code");
+ * object[code] = 1234;
+ * \endcode
+ */
+ class JSON_API StaticString
+ {
+ public:
+ explicit StaticString( const char *czstring )
+ : str_( czstring )
+ {
+ }
+
+ operator const char *() const
+ {
+ return str_;
+ }
+
+ const char *c_str() const
+ {
+ return str_;
+ }
+
+ private:
+ const char *str_;
+ };
+
+ /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
+ *
+ * This class is a discriminated union wrapper that can represents a:
+ * - signed integer [range: Value::minInt - Value::maxInt]
+ * - unsigned integer (range: 0 - Value::maxUInt)
+ * - double
+ * - UTF-8 string
+ * - boolean
+ * - 'null'
+ * - an ordered list of Value
+ * - collection of name/value pairs (javascript object)
+ *
+ * The type of the held value is represented by a #ValueType and
+ * can be obtained using type().
+ *
+ * values of an #objectValue or #arrayValue can be accessed using operator[]() methods.
+ * Non const methods will automatically create the a #nullValue element
+ * if it does not exist.
+ * The sequence of an #arrayValue will be automatically resize and initialized
+ * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
+ *
+ * The get() methods can be used to obtanis default value in the case the required element
+ * does not exist.
+ *
+ * It is possible to iterate over the list of a #objectValue values using
+ * the getMemberNames() method.
+ */
+ class JSON_API Value
+ {
+ friend class ValueIteratorBase;
# ifdef JSON_VALUE_USE_INTERNAL_MAP
- friend class ValueInternalLink;
- friend class ValueInternalMap;
+ friend class ValueInternalLink;
+ friend class ValueInternalMap;
# endif
- public:
- typedef std::vector<std::string> Members;
- typedef ValueIterator iterator;
- typedef ValueConstIterator const_iterator;
- typedef Json::UInt UInt;
- typedef Json::Int Int;
+ public:
+ typedef std::vector<std::string> Members;
+ typedef ValueIterator iterator;
+ typedef ValueConstIterator const_iterator;
+ typedef Json::UInt UInt;
+ typedef Json::Int Int;
# if defined(JSON_HAS_INT64)
- typedef Json::UInt64 UInt64;
- typedef Json::Int64 Int64;
+ typedef Json::UInt64 UInt64;
+ typedef Json::Int64 Int64;
#endif // defined(JSON_HAS_INT64)
- typedef Json::LargestInt LargestInt;
- typedef Json::LargestUInt LargestUInt;
- typedef Json::ArrayIndex ArrayIndex;
-
- static const Value null;
- /// Minimum signed integer value that can be stored in a Json::Value.
- static const LargestInt minLargestInt;
- /// Maximum signed integer value that can be stored in a Json::Value.
- static const LargestInt maxLargestInt;
- /// Maximum unsigned integer value that can be stored in a Json::Value.
- static const LargestUInt maxLargestUInt;
-
- /// Minimum signed int value that can be stored in a Json::Value.
- static const Int minInt;
- /// Maximum signed int value that can be stored in a Json::Value.
- static const Int maxInt;
- /// Maximum unsigned int value that can be stored in a Json::Value.
- static const UInt maxUInt;
-
- /// Minimum signed 64 bits int value that can be stored in a Json::Value.
- static const Int64 minInt64;
- /// Maximum signed 64 bits int value that can be stored in a Json::Value.
- static const Int64 maxInt64;
- /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
- static const UInt64 maxUInt64;
-
- private:
+ typedef Json::LargestInt LargestInt;
+ typedef Json::LargestUInt LargestUInt;
+ typedef Json::ArrayIndex ArrayIndex;
+
+ static const Value null;
+ /// Minimum signed integer value that can be stored in a Json::Value.
+ static const LargestInt minLargestInt;
+ /// Maximum signed integer value that can be stored in a Json::Value.
+ static const LargestInt maxLargestInt;
+ /// Maximum unsigned integer value that can be stored in a Json::Value.
+ static const LargestUInt maxLargestUInt;
+
+ /// Minimum signed int value that can be stored in a Json::Value.
+ static const Int minInt;
+ /// Maximum signed int value that can be stored in a Json::Value.
+ static const Int maxInt;
+ /// Maximum unsigned int value that can be stored in a Json::Value.
+ static const UInt maxUInt;
+
+ /// Minimum signed 64 bits int value that can be stored in a Json::Value.
+ static const Int64 minInt64;
+ /// Maximum signed 64 bits int value that can be stored in a Json::Value.
+ static const Int64 maxInt64;
+ /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
+ static const UInt64 maxUInt64;
+
+ private:
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
# ifndef JSON_VALUE_USE_INTERNAL_MAP
- class CZString
- {
- public:
- enum DuplicationPolicy
- {
- noDuplication = 0,
- duplicate,
- duplicateOnCopy
- };
- CZString( ArrayIndex index );
- CZString( const char *cstr, DuplicationPolicy allocate );
- CZString( const CZString &other );
- ~CZString();
- CZString &operator =( const CZString &other );
- bool operator<( const CZString &other ) const;
- bool operator==( const CZString &other ) const;
- ArrayIndex index() const;
- const char *c_str() const;
- bool isStaticString() const;
- private:
- void swap( CZString &other );
- const char *cstr_;
- ArrayIndex index_;
- };
-
- public:
+ class CZString
+ {
+ public:
+ enum DuplicationPolicy
+ {
+ noDuplication = 0,
+ duplicate,
+ duplicateOnCopy
+ };
+ CZString( ArrayIndex index );
+ CZString( const char *cstr, DuplicationPolicy allocate );
+ CZString( const CZString &other );
+ ~CZString();
+ CZString &operator =( const CZString &other );
+ bool operator<( const CZString &other ) const;
+ bool operator==( const CZString &other ) const;
+ ArrayIndex index() const;
+ const char *c_str() const;
+ bool isStaticString() const;
+ private:
+ void swap( CZString &other );
+ const char *cstr_;
+ ArrayIndex index_;
+ };
+
+ public:
# ifndef JSON_USE_CPPTL_SMALLMAP
- typedef std::map<CZString, Value> ObjectValues;
+ typedef std::map<CZString, Value> ObjectValues;
# else
- typedef CppTL::SmallMap<CZString, Value> ObjectValues;
+ typedef CppTL::SmallMap<CZString, Value> ObjectValues;
# endif // ifndef JSON_USE_CPPTL_SMALLMAP
# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- public:
- /** \brief Create a default Value of the given type.
-
- This is a very useful constructor.
- To create an empty array, pass arrayValue.
- To create an empty object, pass objectValue.
- Another Value can then be set to this one by assignment.
- This is useful since clear() and resize() will not alter types.
-
- Examples:
- \code
- Json::Value null_value; // null
- Json::Value arr_value(Json::arrayValue); // []
- Json::Value obj_value(Json::objectValue); // {}
- \endcode
- */
- Value( ValueType type = nullValue );
- Value( Int value );
- Value( UInt value );
+ public:
+ /** \brief Create a default Value of the given type.
+
+ This is a very useful constructor.
+ To create an empty array, pass arrayValue.
+ To create an empty object, pass objectValue.
+ Another Value can then be set to this one by assignment.
+ This is useful since clear() and resize() will not alter types.
+
+ Examples:
+ \code
+ Json::Value null_value; // null
+ Json::Value arr_value(Json::arrayValue); // []
+ Json::Value obj_value(Json::objectValue); // {}
+ \endcode
+ */
+ Value( ValueType type = nullValue );
+ Value( Int value );
+ Value( UInt value );
#if defined(JSON_HAS_INT64)
- Value( Int64 value );
- Value( UInt64 value );
+ Value( Int64 value );
+ Value( UInt64 value );
#endif // if defined(JSON_HAS_INT64)
- Value( double value );
- Value( const char *value );
- Value( const char *beginValue, const char *endValue );
- /** \brief Constructs a value from a static string.
-
- * Like other value string constructor but do not duplicate the string for
- * internal storage. The given string must remain alive after the call to this
- * constructor.
- * Example of usage:
- * \code
- * Json::Value aValue( StaticString("some text") );
- * \endcode
- */
- Value( const StaticString &value );
- Value( const std::string &value );
+ Value( double value );
+ Value( const char *value );
+ Value( const char *beginValue, const char *endValue );
+ /** \brief Constructs a value from a static string.
+
+ * Like other value string constructor but do not duplicate the string for
+ * internal storage. The given string must remain alive after the call to this
+ * constructor.
+ * Example of usage:
+ * \code
+ * Json::Value aValue( StaticString("some text") );
+ * \endcode
+ */
+ Value( const StaticString &value );
+ Value( const std::string &value );
# ifdef JSON_USE_CPPTL
- Value( const CppTL::ConstString &value );
+ Value( const CppTL::ConstString &value );
# endif
- Value( bool value );
- Value( const Value &other );
- ~Value();
+ Value( bool value );
+ Value( const Value &other );
+ ~Value();
- Value &operator=( const Value &other );
- /// Swap values.
- /// \note Currently, comments are intentionally not swapped, for
- /// both logic and efficiency.
- void swap( Value &other );
+ Value &operator=( const Value &other );
+ /// Swap values.
+ /// \note Currently, comments are intentionally not swapped, for
+ /// both logic and efficiency.
+ void swap( Value &other );
- ValueType type() const;
+ ValueType type() const;
- bool operator <( const Value &other ) const;
- bool operator <=( const Value &other ) const;
- bool operator >=( const Value &other ) const;
- bool operator >( const Value &other ) const;
+ bool operator <( const Value &other ) const;
+ bool operator <=( const Value &other ) const;
+ bool operator >=( const Value &other ) const;
+ bool operator >( const Value &other ) const;
- bool operator ==( const Value &other ) const;
- bool operator !=( const Value &other ) const;
+ bool operator ==( const Value &other ) const;
+ bool operator !=( const Value &other ) const;
- int compare( const Value &other ) const;
+ int compare( const Value &other ) const;
- const char *asCString() const;
- std::string asString() const;
+ const char *asCString() const;
+ std::string asString() const;
# ifdef JSON_USE_CPPTL
- CppTL::ConstString asConstString() const;
+ CppTL::ConstString asConstString() const;
# endif
- Int asInt() const;
- UInt asUInt() const;
- Int64 asInt64() const;
- UInt64 asUInt64() const;
- LargestInt asLargestInt() const;
- LargestUInt asLargestUInt() const;
- float asFloat() const;
- double asDouble() const;
- bool asBool() const;
-
- bool isNull() const;
- bool isBool() const;
- bool isInt() const;
- bool isUInt() const;
- bool isIntegral() const;
- bool isDouble() const;
- bool isNumeric() const;
- bool isString() const;
- bool isArray() const;
- bool isObject() const;
-
- bool isConvertibleTo( ValueType other ) const;
-
- /// Number of values in array or object
- ArrayIndex size() const;
-
- /// \brief Return true if empty array, empty object, or null;
- /// otherwise, false.
- bool empty() const;
-
- /// Return isNull()
- bool operator!() const;
-
- /// Remove all object members and array elements.
- /// \pre type() is arrayValue, objectValue, or nullValue
- /// \post type() is unchanged
- void clear();
-
- /// Resize the array to size elements.
- /// New elements are initialized to null.
- /// May only be called on nullValue or arrayValue.
- /// \pre type() is arrayValue or nullValue
- /// \post type() is arrayValue
- void resize( ArrayIndex size );
-
- /// Access an array element (zero based index ).
- /// If the array contains less than index element, then null value are inserted
- /// in the array so that its size is index+1.
- /// (You may need to say 'value[0u]' to get your compiler to distinguish
- /// this from the operator[] which takes a string.)
- Value &operator[]( ArrayIndex index );
-
- /// Access an array element (zero based index ).
- /// If the array contains less than index element, then null value are inserted
- /// in the array so that its size is index+1.
- /// (You may need to say 'value[0u]' to get your compiler to distinguish
- /// this from the operator[] which takes a string.)
- Value &operator[]( int index );
-
- /// Access an array element (zero based index )
- /// (You may need to say 'value[0u]' to get your compiler to distinguish
- /// this from the operator[] which takes a string.)
- const Value &operator[]( ArrayIndex index ) const;
-
- /// Access an array element (zero based index )
- /// (You may need to say 'value[0u]' to get your compiler to distinguish
- /// this from the operator[] which takes a string.)
- const Value &operator[]( int index ) const;
-
- /// If the array contains at least index+1 elements, returns the element value,
- /// otherwise returns defaultValue.
- Value get( ArrayIndex index,
- const Value &defaultValue ) const;
- /// Return true if index < size().
- bool isValidIndex( ArrayIndex index ) const;
- /// \brief Append value to array at the end.
- ///
- /// Equivalent to jsonvalue[jsonvalue.size()] = value;
- Value &append( const Value &value );
-
- /// Access an object value by name, create a null member if it does not exist.
- Value &operator[]( const char *key );
- /// Access an object value by name, returns null if there is no member with that name.
- const Value &operator[]( const char *key ) const;
- /// Access an object value by name, create a null member if it does not exist.
- Value &operator[]( const std::string &key );
- /// Access an object value by name, returns null if there is no member with that name.
- const Value &operator[]( const std::string &key ) const;
- /** \brief Access an object value by name, create a null member if it does not exist.
-
- * If the object as no entry for that name, then the member name used to store
- * the new entry is not duplicated.
- * Example of use:
- * \code
- * Json::Value object;
- * static const StaticString code("code");
- * object[code] = 1234;
- * \endcode
- */
- Value &operator[]( const StaticString &key );
+ Int asInt() const;
+ UInt asUInt() const;
+ Int64 asInt64() const;
+ UInt64 asUInt64() const;
+ LargestInt asLargestInt() const;
+ LargestUInt asLargestUInt() const;
+ float asFloat() const;
+ double asDouble() const;
+ bool asBool() const;
+
+ bool isNull() const;
+ bool isBool() const;
+ bool isInt() const;
+ bool isUInt() const;
+ bool isIntegral() const;
+ bool isDouble() const;
+ bool isNumeric() const;
+ bool isString() const;
+ bool isArray() const;
+ bool isObject() const;
+
+ bool isConvertibleTo( ValueType other ) const;
+
+ /// Number of values in array or object
+ ArrayIndex size() const;
+
+ /// \brief Return true if empty array, empty object, or null;
+ /// otherwise, false.
+ bool empty() const;
+
+ /// Return isNull()
+ bool operator!() const;
+
+ /// Remove all object members and array elements.
+ /// \pre type() is arrayValue, objectValue, or nullValue
+ /// \post type() is unchanged
+ void clear();
+
+ /// Resize the array to size elements.
+ /// New elements are initialized to null.
+ /// May only be called on nullValue or arrayValue.
+ /// \pre type() is arrayValue or nullValue
+ /// \post type() is arrayValue
+ void resize( ArrayIndex size );
+
+ /// Access an array element (zero based index ).
+ /// If the array contains less than index element, then null value are inserted
+ /// in the array so that its size is index+1.
+ /// (You may need to say 'value[0u]' to get your compiler to distinguish
+ /// this from the operator[] which takes a string.)
+ Value &operator[]( ArrayIndex index );
+
+ /// Access an array element (zero based index ).
+ /// If the array contains less than index element, then null value are inserted
+ /// in the array so that its size is index+1.
+ /// (You may need to say 'value[0u]' to get your compiler to distinguish
+ /// this from the operator[] which takes a string.)
+ Value &operator[]( int index );
+
+ /// Access an array element (zero based index )
+ /// (You may need to say 'value[0u]' to get your compiler to distinguish
+ /// this from the operator[] which takes a string.)
+ const Value &operator[]( ArrayIndex index ) const;
+
+ /// Access an array element (zero based index )
+ /// (You may need to say 'value[0u]' to get your compiler to distinguish
+ /// this from the operator[] which takes a string.)
+ const Value &operator[]( int index ) const;
+
+ /// If the array contains at least index+1 elements, returns the element value,
+ /// otherwise returns defaultValue.
+ Value get( ArrayIndex index,
+ const Value &defaultValue ) const;
+ /// Return true if index < size().
+ bool isValidIndex( ArrayIndex index ) const;
+ /// \brief Append value to array at the end.
+ ///
+ /// Equivalent to jsonvalue[jsonvalue.size()] = value;
+ Value &append( const Value &value );
+
+ /// Access an object value by name, create a null member if it does not exist.
+ Value &operator[]( const char *key );
+ /// Access an object value by name, returns null if there is no member with that name.
+ const Value &operator[]( const char *key ) const;
+ /// Access an object value by name, create a null member if it does not exist.
+ Value &operator[]( const std::string &key );
+ /// Access an object value by name, returns null if there is no member with that name.
+ const Value &operator[]( const std::string &key ) const;
+ /** \brief Access an object value by name, create a null member if it does not exist.
+
+ * If the object as no entry for that name, then the member name used to store
+ * the new entry is not duplicated.
+ * Example of use:
+ * \code
+ * Json::Value object;
+ * static const StaticString code("code");
+ * object[code] = 1234;
+ * \endcode
+ */
+ Value &operator[]( const StaticString &key );
# ifdef JSON_USE_CPPTL
- /// Access an object value by name, create a null member if it does not exist.
- Value &operator[]( const CppTL::ConstString &key );
- /// Access an object value by name, returns null if there is no member with that name.
- const Value &operator[]( const CppTL::ConstString &key ) const;
+ /// Access an object value by name, create a null member if it does not exist.
+ Value &operator[]( const CppTL::ConstString &key );
+ /// Access an object value by name, returns null if there is no member with that name.
+ const Value &operator[]( const CppTL::ConstString &key ) const;
# endif
- /// Return the member named key if it exist, defaultValue otherwise.
- Value get( const char *key,
- const Value &defaultValue ) const;
- /// Return the member named key if it exist, defaultValue otherwise.
- Value get( const std::string &key,
- const Value &defaultValue ) const;
+ /// Return the member named key if it exist, defaultValue otherwise.
+ Value get( const char *key,
+ const Value &defaultValue ) const;
+ /// Return the member named key if it exist, defaultValue otherwise.
+ Value get( const std::string &key,
+ const Value &defaultValue ) const;
# ifdef JSON_USE_CPPTL
- /// Return the member named key if it exist, defaultValue otherwise.
- Value get( const CppTL::ConstString &key,
- const Value &defaultValue ) const;
+ /// Return the member named key if it exist, defaultValue otherwise.
+ Value get( const CppTL::ConstString &key,
+ const Value &defaultValue ) const;
# endif
- /// \brief Remove and return the named member.
- ///
- /// Do nothing if it did not exist.
- /// \return the removed Value, or null.
- /// \pre type() is objectValue or nullValue
- /// \post type() is unchanged
- Value removeMember( const char* key );
- /// Same as removeMember(const char*)
- Value removeMember( const std::string &key );
-
- /// Return true if the object has a member named key.
- bool isMember( const char *key ) const;
- /// Return true if the object has a member named key.
- bool isMember( const std::string &key ) const;
+ /// \brief Remove and return the named member.
+ ///
+ /// Do nothing if it did not exist.
+ /// \return the removed Value, or null.
+ /// \pre type() is objectValue or nullValue
+ /// \post type() is unchanged
+ Value removeMember( const char* key );
+ /// Same as removeMember(const char*)
+ Value removeMember( const std::string &key );
+
+ /// Return true if the object has a member named key.
+ bool isMember( const char *key ) const;
+ /// Return true if the object has a member named key.
+ bool isMember( const std::string &key ) const;
# ifdef JSON_USE_CPPTL
- /// Return true if the object has a member named key.
- bool isMember( const CppTL::ConstString &key ) const;
+ /// Return true if the object has a member named key.
+ bool isMember( const CppTL::ConstString &key ) const;
# endif
- /// \brief Return a list of the member names.
- ///
- /// If null, return an empty list.
- /// \pre type() is objectValue or nullValue
- /// \post if type() was nullValue, it remains nullValue
- Members getMemberNames() const;
+ /// \brief Return a list of the member names.
+ ///
+ /// If null, return an empty list.
+ /// \pre type() is objectValue or nullValue
+ /// \post if type() was nullValue, it remains nullValue
+ Members getMemberNames() const;
//# ifdef JSON_USE_CPPTL
// EnumMemberNames enumMemberNames() const;
// EnumValues enumValues() const;
//# endif
- /// Comments must be //... or /* ... */
- void setComment( const char *comment,
- CommentPlacement placement );
- /// Comments must be //... or /* ... */
- void setComment( const std::string &comment,
- CommentPlacement placement );
- bool hasComment( CommentPlacement placement ) const;
- /// Include delimiters and embedded newlines.
- std::string getComment( CommentPlacement placement ) const;
+ /// Comments must be //... or /* ... */
+ void setComment( const char *comment,
+ CommentPlacement placement );
+ /// Comments must be //... or /* ... */
+ void setComment( const std::string &comment,
+ CommentPlacement placement );
+ bool hasComment( CommentPlacement placement ) const;
+ /// Include delimiters and embedded newlines.
+ std::string getComment( CommentPlacement placement ) const;
- std::string toStyledString() const;
+ std::string toStyledString() const;
- const_iterator begin() const;
- const_iterator end() const;
+ const_iterator begin() const;
+ const_iterator end() const;
- iterator begin();
- iterator end();
+ iterator begin();
+ iterator end();
- private:
- Value &resolveReference( const char *key,
- bool isStatic );
+ private:
+ Value &resolveReference( const char *key,
+ bool isStatic );
# ifdef JSON_VALUE_USE_INTERNAL_MAP
- inline bool isItemAvailable() const
- {
- return itemIsUsed_ == 0;
- }
-
- inline void setItemUsed( bool isUsed = true )
- {
- itemIsUsed_ = isUsed ? 1 : 0;
- }
-
- inline bool isMemberNameStatic() const
- {
- return memberNameIsStatic_ == 0;
- }
-
- inline void setMemberNameIsStatic( bool isStatic )
- {
- memberNameIsStatic_ = isStatic ? 1 : 0;
- }
+ inline bool isItemAvailable() const
+ {
+ return itemIsUsed_ == 0;
+ }
+
+ inline void setItemUsed( bool isUsed = true )
+ {
+ itemIsUsed_ = isUsed ? 1 : 0;
+ }
+
+ inline bool isMemberNameStatic() const
+ {
+ return memberNameIsStatic_ == 0;
+ }
+
+ inline void setMemberNameIsStatic( bool isStatic )
+ {
+ memberNameIsStatic_ = isStatic ? 1 : 0;
+ }
# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
- private:
- struct CommentInfo
- {
- CommentInfo();
- ~CommentInfo();
-
- void setComment( const char *text );
-
- char *comment_;
- };
-
- //struct MemberNamesTransform
- //{
- // typedef const char *result_type;
- // const char *operator()( const CZString &name ) const
- // {
- // return name.c_str();
- // }
- //};
-
- union ValueHolder
- {
- LargestInt int_;
- LargestUInt uint_;
- double real_;
- bool bool_;
- char *string_;
+ private:
+ struct CommentInfo
+ {
+ CommentInfo();
+ ~CommentInfo();
+
+ void setComment( const char *text );
+
+ char *comment_;
+ };
+
+ //struct MemberNamesTransform
+ //{
+ // typedef const char *result_type;
+ // const char *operator()( const CZString &name ) const
+ // {
+ // return name.c_str();
+ // }
+ //};
+
+ union ValueHolder
+ {
+ LargestInt int_;
+ LargestUInt uint_;
+ double real_;
+ bool bool_;
+ char *string_;
# ifdef JSON_VALUE_USE_INTERNAL_MAP
- ValueInternalArray *array_;
- ValueInternalMap *map_;
+ ValueInternalArray *array_;
+ ValueInternalMap *map_;
#else
- ObjectValues *map_;
+ ObjectValues *map_;
# endif
- } value_;
- ValueType type_ : 8;
- int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
+ } value_;
+ ValueType type_ : 8;
+ int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
# ifdef JSON_VALUE_USE_INTERNAL_MAP
- unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
- int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
+ unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
+ int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
# endif
- CommentInfo *comments_;
- };
-
-
- /** \brief Experimental and untested: represents an element of the "path" to access a node.
- */
- class PathArgument
- {
- public:
- friend class Path;
-
- PathArgument();
- PathArgument( ArrayIndex index );
- PathArgument( const char *key );
- PathArgument( const std::string &key );
-
- private:
- enum Kind
- {
- kindNone = 0,
- kindIndex,
- kindKey
- };
- std::string key_;
- ArrayIndex index_;
- Kind kind_;
- };
-
- /** \brief Experimental and untested: represents a "path" to access a node.
- *
- * Syntax:
- * - "." => root node
- * - ".[n]" => elements at index 'n' of root node (an array value)
- * - ".name" => member named 'name' of root node (an object value)
- * - ".name1.name2.name3"
- * - ".[0][1][2].name1[3]"
- * - ".%" => member name is provided as parameter
- * - ".[%]" => index is provied as parameter
- */
- class Path
- {
- public:
- Path( const std::string &path,
- const PathArgument &a1 = PathArgument(),
- const PathArgument &a2 = PathArgument(),
- const PathArgument &a3 = PathArgument(),
- const PathArgument &a4 = PathArgument(),
- const PathArgument &a5 = PathArgument() );
-
- const Value &resolve( const Value &root ) const;
- Value resolve( const Value &root,
- const Value &defaultValue ) const;
- /// Creates the "path" to access the specified node and returns a reference on the node.
- Value &make( Value &root ) const;
-
- private:
- typedef std::vector<const PathArgument *> InArgs;
- typedef std::vector<PathArgument> Args;
-
- void makePath( const std::string &path,
- const InArgs &in );
- void addPathInArg( const std::string &path,
- const InArgs &in,
- InArgs::const_iterator &itInArg,
- PathArgument::Kind kind );
- void invalidPath( const std::string &path,
- int location );
-
- Args args_;
- };
+ CommentInfo *comments_;
+ };
+
+
+ /** \brief Experimental and untested: represents an element of the "path" to access a node.
+ */
+ class PathArgument
+ {
+ public:
+ friend class Path;
+
+ PathArgument();
+ PathArgument( ArrayIndex index );
+ PathArgument( const char *key );
+ PathArgument( const std::string &key );
+
+ private:
+ enum Kind
+ {
+ kindNone = 0,
+ kindIndex,
+ kindKey
+ };
+ std::string key_;
+ ArrayIndex index_;
+ Kind kind_;
+ };
+
+ /** \brief Experimental and untested: represents a "path" to access a node.
+ *
+ * Syntax:
+ * - "." => root node
+ * - ".[n]" => elements at index 'n' of root node (an array value)
+ * - ".name" => member named 'name' of root node (an object value)
+ * - ".name1.name2.name3"
+ * - ".[0][1][2].name1[3]"
+ * - ".%" => member name is provided as parameter
+ * - ".[%]" => index is provied as parameter
+ */
+ class Path
+ {
+ public:
+ Path( const std::string &path,
+ const PathArgument &a1 = PathArgument(),
+ const PathArgument &a2 = PathArgument(),
+ const PathArgument &a3 = PathArgument(),
+ const PathArgument &a4 = PathArgument(),
+ const PathArgument &a5 = PathArgument() );
+
+ const Value &resolve( const Value &root ) const;
+ Value resolve( const Value &root,
+ const Value &defaultValue ) const;
+ /// Creates the "path" to access the specified node and returns a reference on the node.
+ Value &make( Value &root ) const;
+
+ private:
+ typedef std::vector<const PathArgument *> InArgs;
+ typedef std::vector<PathArgument> Args;
+
+ void makePath( const std::string &path,
+ const InArgs &in );
+ void addPathInArg( const std::string &path,
+ const InArgs &in,
+ InArgs::const_iterator &itInArg,
+ PathArgument::Kind kind );
+ void invalidPath( const std::string &path,
+ int location );
+
+ Args args_;
+ };
#ifdef JSON_VALUE_USE_INTERNAL_MAP
- /** \brief Allocator to customize Value internal map.
- * Below is an example of a simple implementation (default implementation actually
- * use memory pool for speed).
- * \code
- class DefaultValueMapAllocator : public ValueMapAllocator
- {
- public: // overridden from ValueMapAllocator
- virtual ValueInternalMap *newMap()
- {
- return new ValueInternalMap();
- }
-
- virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
- {
- return new ValueInternalMap( other );
- }
-
- virtual void destructMap( ValueInternalMap *map )
- {
- delete map;
- }
-
- virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
- {
- return new ValueInternalLink[size];
- }
-
- virtual void releaseMapBuckets( ValueInternalLink *links )
- {
- delete [] links;
- }
-
- virtual ValueInternalLink *allocateMapLink()
- {
- return new ValueInternalLink();
- }
-
- virtual void releaseMapLink( ValueInternalLink *link )
- {
- delete link;
- }
- };
- * \endcode
- */
- class JSON_API ValueMapAllocator
- {
- public:
- virtual ~ValueMapAllocator();
- virtual ValueInternalMap *newMap() = 0;
- virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;
- virtual void destructMap( ValueInternalMap *map ) = 0;
- virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;
- virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
- virtual ValueInternalLink *allocateMapLink() = 0;
- virtual void releaseMapLink( ValueInternalLink *link ) = 0;
- };
-
- /** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
- * \internal previous_ & next_ allows for bidirectional traversal.
- */
- class JSON_API ValueInternalLink
- {
- public:
- enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
- enum InternalFlags {
- flagAvailable = 0,
- flagUsed = 1
- };
-
- ValueInternalLink();
-
- ~ValueInternalLink();
-
- Value items_[itemPerLink];
- char *keys_[itemPerLink];
- ValueInternalLink *previous_;
- ValueInternalLink *next_;
- };
-
-
- /** \brief A linked page based hash-table implementation used internally by Value.
- * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked
- * list in each bucket to handle collision. There is an addional twist in that
- * each node of the collision linked list is a page containing a fixed amount of
- * value. This provides a better compromise between memory usage and speed.
- *
- * Each bucket is made up of a chained list of ValueInternalLink. The last
- * link of a given bucket can be found in the 'previous_' field of the following bucket.
- * The last link of the last bucket is stored in tailLink_ as it has no following bucket.
- * Only the last link of a bucket may contains 'available' item. The last link always
- * contains at least one element unless is it the bucket one very first link.
- */
- class JSON_API ValueInternalMap
- {
- friend class ValueIteratorBase;
- friend class Value;
- public:
- typedef unsigned int HashKey;
- typedef unsigned int BucketIndex;
+ /** \brief Allocator to customize Value internal map.
+ * Below is an example of a simple implementation (default implementation actually
+ * use memory pool for speed).
+ * \code
+ class DefaultValueMapAllocator : public ValueMapAllocator
+ {
+ public: // overridden from ValueMapAllocator
+ virtual ValueInternalMap *newMap()
+ {
+ return new ValueInternalMap();
+ }
+
+ virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
+ {
+ return new ValueInternalMap( other );
+ }
+
+ virtual void destructMap( ValueInternalMap *map )
+ {
+ delete map;
+ }
+
+ virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
+ {
+ return new ValueInternalLink[size];
+ }
+
+ virtual void releaseMapBuckets( ValueInternalLink *links )
+ {
+ delete [] links;
+ }
+
+ virtual ValueInternalLink *allocateMapLink()
+ {
+ return new ValueInternalLink();
+ }
+
+ virtual void releaseMapLink( ValueInternalLink *link )
+ {
+ delete link;
+ }
+ };
+ * \endcode
+ */
+ class JSON_API ValueMapAllocator
+ {
+ public:
+ virtual ~ValueMapAllocator();
+ virtual ValueInternalMap *newMap() = 0;
+ virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;
+ virtual void destructMap( ValueInternalMap *map ) = 0;
+ virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;
+ virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
+ virtual ValueInternalLink *allocateMapLink() = 0;
+ virtual void releaseMapLink( ValueInternalLink *link ) = 0;
+ };
+
+ /** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
+ * \internal previous_ & next_ allows for bidirectional traversal.
+ */
+ class JSON_API ValueInternalLink
+ {
+ public:
+ enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
+ enum InternalFlags {
+ flagAvailable = 0,
+ flagUsed = 1
+ };
+
+ ValueInternalLink();
+
+ ~ValueInternalLink();
+
+ Value items_[itemPerLink];
+ char *keys_[itemPerLink];
+ ValueInternalLink *previous_;
+ ValueInternalLink *next_;
+ };
+
+
+ /** \brief A linked page based hash-table implementation used internally by Value.
+ * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked
+ * list in each bucket to handle collision. There is an addional twist in that
+ * each node of the collision linked list is a page containing a fixed amount of
+ * value. This provides a better compromise between memory usage and speed.
+ *
+ * Each bucket is made up of a chained list of ValueInternalLink. The last
+ * link of a given bucket can be found in the 'previous_' field of the following bucket.
+ * The last link of the last bucket is stored in tailLink_ as it has no following bucket.
+ * Only the last link of a bucket may contains 'available' item. The last link always
+ * contains at least one element unless is it the bucket one very first link.
+ */
+ class JSON_API ValueInternalMap
+ {
+ friend class ValueIteratorBase;
+ friend class Value;
+ public:
+ typedef unsigned int HashKey;
+ typedef unsigned int BucketIndex;
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- struct IteratorState
- {
- IteratorState()
- : map_(0)
- , link_(0)
- , itemIndex_(0)
- , bucketIndex_(0)
- {
- }
- ValueInternalMap *map_;
- ValueInternalLink *link_;
- BucketIndex itemIndex_;
- BucketIndex bucketIndex_;
- };
+ struct IteratorState
+ {
+ IteratorState()
+ : map_(0)
+ , link_(0)
+ , itemIndex_(0)
+ , bucketIndex_(0)
+ {
+ }
+ ValueInternalMap *map_;
+ ValueInternalLink *link_;
+ BucketIndex itemIndex_;
+ BucketIndex bucketIndex_;
+ };
# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- ValueInternalMap();
- ValueInternalMap( const ValueInternalMap &other );
- ValueInternalMap &operator =( const ValueInternalMap &other );
- ~ValueInternalMap();
+ ValueInternalMap();
+ ValueInternalMap( const ValueInternalMap &other );
+ ValueInternalMap &operator =( const ValueInternalMap &other );
+ ~ValueInternalMap();
- void swap( ValueInternalMap &other );
+ void swap( ValueInternalMap &other );
- BucketIndex size() const;
+ BucketIndex size() const;
- void clear();
+ void clear();
- bool reserveDelta( BucketIndex growth );
+ bool reserveDelta( BucketIndex growth );
- bool reserve( BucketIndex newItemCount );
+ bool reserve( BucketIndex newItemCount );
- const Value *find( const char *key ) const;
+ const Value *find( const char *key ) const;
- Value *find( const char *key );
+ Value *find( const char *key );
- Value &resolveReference( const char *key,
- bool isStatic );
+ Value &resolveReference( const char *key,
+ bool isStatic );
- void remove( const char *key );
+ void remove( const char *key );
- void doActualRemove( ValueInternalLink *link,
- BucketIndex index,
- BucketIndex bucketIndex );
+ void doActualRemove( ValueInternalLink *link,
+ BucketIndex index,
+ BucketIndex bucketIndex );
- ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
+ ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
- Value &setNewItem( const char *key,
- bool isStatic,
- ValueInternalLink *link,
- BucketIndex index );
+ Value &setNewItem( const char *key,
+ bool isStatic,
+ ValueInternalLink *link,
+ BucketIndex index );
- Value &unsafeAdd( const char *key,
- bool isStatic,
- HashKey hashedKey );
+ Value &unsafeAdd( const char *key,
+ bool isStatic,
+ HashKey hashedKey );
- HashKey hash( const char *key ) const;
+ HashKey hash( const char *key ) const;
- int compare( const ValueInternalMap &other ) const;
+ int compare( const ValueInternalMap &other ) const;
- private:
- void makeBeginIterator( IteratorState &it ) const;
- void makeEndIterator( IteratorState &it ) const;
- static bool equals( const IteratorState &x, const IteratorState &other );
- static void increment( IteratorState &iterator );
- static void incrementBucket( IteratorState &iterator );
- static void decrement( IteratorState &iterator );
- static const char *key( const IteratorState &iterator );
- static const char *key( const IteratorState &iterator, bool &isStatic );
- static Value &value( const IteratorState &iterator );
- static int distance( const IteratorState &x, const IteratorState &y );
+ private:
+ void makeBeginIterator( IteratorState &it ) const;
+ void makeEndIterator( IteratorState &it ) const;
+ static bool equals( const IteratorState &x, const IteratorState &other );
+ static void increment( IteratorState &iterator );
+ static void incrementBucket( IteratorState &iterator );
+ static void decrement( IteratorState &iterator );
+ static const char *key( const IteratorState &iterator );
+ static const char *key( const IteratorState &iterator, bool &isStatic );
+ static Value &value( const IteratorState &iterator );
+ static int distance( const IteratorState &x, const IteratorState &y );
- private:
- ValueInternalLink *buckets_;
- ValueInternalLink *tailLink_;
- BucketIndex bucketsSize_;
- BucketIndex itemCount_;
- };
+ private:
+ ValueInternalLink *buckets_;
+ ValueInternalLink *tailLink_;
+ BucketIndex bucketsSize_;
+ BucketIndex itemCount_;
+ };
- /** \brief A simplified deque implementation used internally by Value.
- * \internal
- * It is based on a list of fixed "page", each page contains a fixed number of items.
- * Instead of using a linked-list, a array of pointer is used for fast item look-up.
- * Look-up for an element is as follow:
- * - compute page index: pageIndex = itemIndex / itemsPerPage
- * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
- *
- * Insertion is amortized constant time (only the array containing the index of pointers
- * need to be reallocated when items are appended).
- */
- class JSON_API ValueInternalArray
- {
- friend class Value;
- friend class ValueIteratorBase;
- public:
- enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo.
- typedef Value::ArrayIndex ArrayIndex;
- typedef unsigned int PageIndex;
+ /** \brief A simplified deque implementation used internally by Value.
+ * \internal
+ * It is based on a list of fixed "page", each page contains a fixed number of items.
+ * Instead of using a linked-list, a array of pointer is used for fast item look-up.
+ * Look-up for an element is as follow:
+ * - compute page index: pageIndex = itemIndex / itemsPerPage
+ * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
+ *
+ * Insertion is amortized constant time (only the array containing the index of pointers
+ * need to be reallocated when items are appended).
+ */
+ class JSON_API ValueInternalArray
+ {
+ friend class Value;
+ friend class ValueIteratorBase;
+ public:
+ enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo.
+ typedef Value::ArrayIndex ArrayIndex;
+ typedef unsigned int PageIndex;
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- struct IteratorState // Must be a POD
- {
- IteratorState()
- : array_(0)
- , currentPageIndex_(0)
- , currentItemIndex_(0)
- {
- }
- ValueInternalArray *array_;
- Value **currentPageIndex_;
- unsigned int currentItemIndex_;
- };
+ struct IteratorState // Must be a POD
+ {
+ IteratorState()
+ : array_(0)
+ , currentPageIndex_(0)
+ , currentItemIndex_(0)
+ {
+ }
+ ValueInternalArray *array_;
+ Value **currentPageIndex_;
+ unsigned int currentItemIndex_;
+ };
# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- ValueInternalArray();
- ValueInternalArray( const ValueInternalArray &other );
- ValueInternalArray &operator =( const ValueInternalArray &other );
- ~ValueInternalArray();
- void swap( ValueInternalArray &other );
+ ValueInternalArray();
+ ValueInternalArray( const ValueInternalArray &other );
+ ValueInternalArray &operator =( const ValueInternalArray &other );
+ ~ValueInternalArray();
+ void swap( ValueInternalArray &other );
- void clear();
- void resize( ArrayIndex newSize );
+ void clear();
+ void resize( ArrayIndex newSize );
- Value &resolveReference( ArrayIndex index );
+ Value &resolveReference( ArrayIndex index );
- Value *find( ArrayIndex index ) const;
+ Value *find( ArrayIndex index ) const;
- ArrayIndex size() const;
+ ArrayIndex size() const;
- int compare( const ValueInternalArray &other ) const;
+ int compare( const ValueInternalArray &other ) const;
- private:
- static bool equals( const IteratorState &x, const IteratorState &other );
- static void increment( IteratorState &iterator );
- static void decrement( IteratorState &iterator );
- static Value &dereference( const IteratorState &iterator );
- static Value &unsafeDereference( const IteratorState &iterator );
- static int distance( const IteratorState &x, const IteratorState &y );
- static ArrayIndex indexOf( const IteratorState &iterator );
- void makeBeginIterator( IteratorState &it ) const;
- void makeEndIterator( IteratorState &it ) const;
- void makeIterator( IteratorState &it, ArrayIndex index ) const;
+ private:
+ static bool equals( const IteratorState &x, const IteratorState &other );
+ static void increment( IteratorState &iterator );
+ static void decrement( IteratorState &iterator );
+ static Value &dereference( const IteratorState &iterator );
+ static Value &unsafeDereference( const IteratorState &iterator );
+ static int distance( const IteratorState &x, const IteratorState &y );
+ static ArrayIndex indexOf( const IteratorState &iterator );
+ void makeBeginIterator( IteratorState &it ) const;
+ void makeEndIterator( IteratorState &it ) const;
+ void makeIterator( IteratorState &it, ArrayIndex index ) const;
- void makeIndexValid( ArrayIndex index );
+ void makeIndexValid( ArrayIndex index );
- Value **pages_;
- ArrayIndex size_;
- PageIndex pageCount_;
- };
+ Value **pages_;
+ ArrayIndex size_;
+ PageIndex pageCount_;
+ };
- /** \brief Experimental: do not use. Allocator to customize Value internal array.
- * Below is an example of a simple implementation (actual implementation use
- * memory pool).
- \code
+ /** \brief Experimental: do not use. Allocator to customize Value internal array.
+ * Below is an example of a simple implementation (actual implementation use
+ * memory pool).
+ \code
class DefaultValueArrayAllocator : public ValueArrayAllocator
{
public: // overridden from ValueArrayAllocator
- virtual ~DefaultValueArrayAllocator()
- {
- }
-
- virtual ValueInternalArray *newArray()
- {
- return new ValueInternalArray();
- }
-
- virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
- {
- return new ValueInternalArray( other );
- }
-
- virtual void destruct( ValueInternalArray *array )
- {
- delete array;
- }
-
- virtual void reallocateArrayPageIndex( Value **&indexes,
- ValueInternalArray::PageIndex &indexCount,
- ValueInternalArray::PageIndex minNewIndexCount )
- {
- ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
- if ( minNewIndexCount > newIndexCount )
- newIndexCount = minNewIndexCount;
- void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
- if ( !newIndexes )
- throw std::bad_alloc();
- indexCount = newIndexCount;
- indexes = static_cast<Value **>( newIndexes );
- }
- virtual void releaseArrayPageIndex( Value **indexes,
- ValueInternalArray::PageIndex indexCount )
- {
- if ( indexes )
- free( indexes );
- }
-
- virtual Value *allocateArrayPage()
- {
- return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
- }
-
- virtual void releaseArrayPage( Value *value )
- {
- if ( value )
- free( value );
- }
+ virtual ~DefaultValueArrayAllocator()
+ {
+ }
+
+ virtual ValueInternalArray *newArray()
+ {
+ return new ValueInternalArray();
+ }
+
+ virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
+ {
+ return new ValueInternalArray( other );
+ }
+
+ virtual void destruct( ValueInternalArray *array )
+ {
+ delete array;
+ }
+
+ virtual void reallocateArrayPageIndex( Value **&indexes,
+ ValueInternalArray::PageIndex &indexCount,
+ ValueInternalArray::PageIndex minNewIndexCount )
+ {
+ ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
+ if ( minNewIndexCount > newIndexCount )
+ newIndexCount = minNewIndexCount;
+ void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
+ if ( !newIndexes )
+ throw std::bad_alloc();
+ indexCount = newIndexCount;
+ indexes = static_cast<Value **>( newIndexes );
+ }
+ virtual void releaseArrayPageIndex( Value **indexes,
+ ValueInternalArray::PageIndex indexCount )
+ {
+ if ( indexes )
+ free( indexes );
+ }
+
+ virtual Value *allocateArrayPage()
+ {
+ return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
+ }
+
+ virtual void releaseArrayPage( Value *value )
+ {
+ if ( value )
+ free( value );
+ }
};
- \endcode
- */
- class JSON_API ValueArrayAllocator
- {
- public:
- virtual ~ValueArrayAllocator();
- virtual ValueInternalArray *newArray() = 0;
- virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0;
- virtual void destructArray( ValueInternalArray *array ) = 0;
- /** \brief Reallocate array page index.
- * Reallocates an array of pointer on each page.
- * \param indexes [input] pointer on the current index. May be \c NULL.
- * [output] pointer on the new index of at least
- * \a minNewIndexCount pages.
- * \param indexCount [input] current number of pages in the index.
- * [output] number of page the reallocated index can handle.
- * \b MUST be >= \a minNewIndexCount.
- * \param minNewIndexCount Minimum number of page the new index must be able to
- * handle.
- */
- virtual void reallocateArrayPageIndex( Value **&indexes,
- ValueInternalArray::PageIndex &indexCount,
- ValueInternalArray::PageIndex minNewIndexCount ) = 0;
- virtual void releaseArrayPageIndex( Value **indexes,
- ValueInternalArray::PageIndex indexCount ) = 0;
- virtual Value *allocateArrayPage() = 0;
- virtual void releaseArrayPage( Value *value ) = 0;
- };
+ \endcode
+ */
+ class JSON_API ValueArrayAllocator
+ {
+ public:
+ virtual ~ValueArrayAllocator();
+ virtual ValueInternalArray *newArray() = 0;
+ virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0;
+ virtual void destructArray( ValueInternalArray *array ) = 0;
+ /** \brief Reallocate array page index.
+ * Reallocates an array of pointer on each page.
+ * \param indexes [input] pointer on the current index. May be \c NULL.
+ * [output] pointer on the new index of at least
+ * \a minNewIndexCount pages.
+ * \param indexCount [input] current number of pages in the index.
+ * [output] number of page the reallocated index can handle.
+ * \b MUST be >= \a minNewIndexCount.
+ * \param minNewIndexCount Minimum number of page the new index must be able to
+ * handle.
+ */
+ virtual void reallocateArrayPageIndex( Value **&indexes,
+ ValueInternalArray::PageIndex &indexCount,
+ ValueInternalArray::PageIndex minNewIndexCount ) = 0;
+ virtual void releaseArrayPageIndex( Value **indexes,
+ ValueInternalArray::PageIndex indexCount ) = 0;
+ virtual Value *allocateArrayPage() = 0;
+ virtual void releaseArrayPage( Value *value ) = 0;
+ };
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
- /** \brief base class for Value iterators.
- *
- */
- class ValueIteratorBase
- {
- public:
- typedef unsigned int size_t;
- typedef int difference_type;
- typedef ValueIteratorBase SelfType;
+ /** \brief base class for Value iterators.
+ *
+ */
+ class ValueIteratorBase
+ {
+ public:
+ typedef unsigned int size_t;
+ typedef int difference_type;
+ typedef ValueIteratorBase SelfType;
- ValueIteratorBase();
+ ValueIteratorBase();
#ifndef JSON_VALUE_USE_INTERNAL_MAP
- explicit ValueIteratorBase( const Value::ObjectValues::iterator &current );
+ explicit ValueIteratorBase( const Value::ObjectValues::iterator &current );
#else
- ValueIteratorBase( const ValueInternalArray::IteratorState &state );
- ValueIteratorBase( const ValueInternalMap::IteratorState &state );
+ ValueIteratorBase( const ValueInternalArray::IteratorState &state );
+ ValueIteratorBase( const ValueInternalMap::IteratorState &state );
#endif
- bool operator ==( const SelfType &other ) const
- {
- return isEqual( other );
- }
+ bool operator ==( const SelfType &other ) const
+ {
+ return isEqual( other );
+ }
- bool operator !=( const SelfType &other ) const
- {
- return !isEqual( other );
- }
+ bool operator !=( const SelfType &other ) const
+ {
+ return !isEqual( other );
+ }
- difference_type operator -( const SelfType &other ) const
- {
- return computeDistance( other );
- }
+ difference_type operator -( const SelfType &other ) const
+ {
+ return computeDistance( other );
+ }
- /// Return either the index or the member name of the referenced value as a Value.
- Value key() const;
+ /// Return either the index or the member name of the referenced value as a Value.
+ Value key() const;
- /// Return the index of the referenced Value. -1 if it is not an arrayValue.
- UInt index() const;
+ /// Return the index of the referenced Value. -1 if it is not an arrayValue.
+ UInt index() const;
- /// Return the member name of the referenced Value. "" if it is not an objectValue.
- const char *memberName() const;
+ /// Return the member name of the referenced Value. "" if it is not an objectValue.
+ const char *memberName() const;
- protected:
- Value &deref() const;
+ protected:
+ Value &deref() const;
- void increment();
+ void increment();
- void decrement();
+ void decrement();
- difference_type computeDistance( const SelfType &other ) const;
+ difference_type computeDistance( const SelfType &other ) const;
- bool isEqual( const SelfType &other ) const;
+ bool isEqual( const SelfType &other ) const;
- void copy( const SelfType &other );
+ void copy( const SelfType &other );
- private:
+ private:
#ifndef JSON_VALUE_USE_INTERNAL_MAP
- Value::ObjectValues::iterator current_;
- // Indicates that iterator is for a null value.
- bool isNull_;
+ Value::ObjectValues::iterator current_;
+ // Indicates that iterator is for a null value.
+ bool isNull_;
#else
- union
- {
- ValueInternalArray::IteratorState array_;
- ValueInternalMap::IteratorState map_;
- } iterator_;
- bool isArray_;
+ union
+ {
+ ValueInternalArray::IteratorState array_;
+ ValueInternalMap::IteratorState map_;
+ } iterator_;
+ bool isArray_;
#endif
- };
-
- /** \brief const iterator for object and array value.
- *
- */
- class ValueConstIterator : public ValueIteratorBase
- {
- friend class Value;
- public:
- typedef unsigned int size_t;
- typedef int difference_type;
- typedef const Value &reference;
- typedef const Value *pointer;
- typedef ValueConstIterator SelfType;
-
- ValueConstIterator();
- private:
- /*! \internal Use by Value to create an iterator.
- */
+ };
+
+ /** \brief const iterator for object and array value.
+ *
+ */
+ class ValueConstIterator : public ValueIteratorBase
+ {
+ friend class Value;
+ public:
+ typedef unsigned int size_t;
+ typedef int difference_type;
+ typedef const Value &reference;
+ typedef const Value *pointer;
+ typedef ValueConstIterator SelfType;
+
+ ValueConstIterator();
+ private:
+ /*! \internal Use by Value to create an iterator.
+ */
#ifndef JSON_VALUE_USE_INTERNAL_MAP
- explicit ValueConstIterator( const Value::ObjectValues::iterator &current );
+ explicit ValueConstIterator( const Value::ObjectValues::iterator &current );
#else
- ValueConstIterator( const ValueInternalArray::IteratorState &state );
- ValueConstIterator( const ValueInternalMap::IteratorState &state );
+ ValueConstIterator( const ValueInternalArray::IteratorState &state );
+ ValueConstIterator( const ValueInternalMap::IteratorState &state );
#endif
- public:
- SelfType &operator =( const ValueIteratorBase &other );
-
- SelfType operator++( int )
- {
- SelfType temp( *this );
- ++*this;
- return temp;
- }
-
- SelfType operator--( int )
- {
- SelfType temp( *this );
- --*this;
- return temp;
- }
-
- SelfType &operator--()
- {
- decrement();
- return *this;
- }
-
- SelfType &operator++()
- {
- increment();
- return *this;
- }
-
- reference operator *() const
- {
- return deref();
- }
- };
-
-
- /** \brief Iterator for object and array value.
- */
- class ValueIterator : public ValueIteratorBase
- {
- friend class Value;
- public:
- typedef unsigned int size_t;
- typedef int difference_type;
- typedef Value &reference;
- typedef Value *pointer;
- typedef ValueIterator SelfType;
-
- ValueIterator();
- ValueIterator( const ValueConstIterator &other );
- ValueIterator( const ValueIterator &other );
- private:
- /*! \internal Use by Value to create an iterator.
- */
+ public:
+ SelfType &operator =( const ValueIteratorBase &other );
+
+ SelfType operator++( int )
+ {
+ SelfType temp( *this );
+ ++*this;
+ return temp;
+ }
+
+ SelfType operator--( int )
+ {
+ SelfType temp( *this );
+ --*this;
+ return temp;
+ }
+
+ SelfType &operator--()
+ {
+ decrement();
+ return *this;
+ }
+
+ SelfType &operator++()
+ {
+ increment();
+ return *this;
+ }
+
+ reference operator *() const
+ {
+ return deref();
+ }
+ };
+
+
+ /** \brief Iterator for object and array value.
+ */
+ class ValueIterator : public ValueIteratorBase
+ {
+ friend class Value;
+ public:
+ typedef unsigned int size_t;
+ typedef int difference_type;
+ typedef Value &reference;
+ typedef Value *pointer;
+ typedef ValueIterator SelfType;
+
+ ValueIterator();
+ ValueIterator( const ValueConstIterator &other );
+ ValueIterator( const ValueIterator &other );
+ private:
+ /*! \internal Use by Value to create an iterator.
+ */
#ifndef JSON_VALUE_USE_INTERNAL_MAP
- explicit ValueIterator( const Value::ObjectValues::iterator &current );
+ explicit ValueIterator( const Value::ObjectValues::iterator &current );
#else
- ValueIterator( const ValueInternalArray::IteratorState &state );
- ValueIterator( const ValueInternalMap::IteratorState &state );
+ ValueIterator( const ValueInternalArray::IteratorState &state );
+ ValueIterator( const ValueInternalMap::IteratorState &state );
#endif
- public:
-
- SelfType &operator =( const SelfType &other );
-
- SelfType operator++( int )
- {
- SelfType temp( *this );
- ++*this;
- return temp;
- }
-
- SelfType operator--( int )
- {
- SelfType temp( *this );
- --*this;
- return temp;
- }
-
- SelfType &operator--()
- {
- decrement();
- return *this;
- }
-
- SelfType &operator++()
- {
- increment();
- return *this;
- }
-
- reference operator *() const
- {
- return deref();
- }
- };
+ public:
+
+ SelfType &operator =( const SelfType &other );
+
+ SelfType operator++( int )
+ {
+ SelfType temp( *this );
+ ++*this;
+ return temp;
+ }
+
+ SelfType operator--( int )
+ {
+ SelfType temp( *this );
+ --*this;
+ return temp;
+ }
+
+ SelfType &operator--()
+ {
+ decrement();
+ return *this;
+ }
+
+ SelfType &operator++()
+ {
+ increment();
+ return *this;
+ }
+
+ reference operator *() const
+ {
+ return deref();
+ }
+ };
} // namespace Json
diff --git a/src/lib/web/json/writer.h b/src/lib/web/json/writer.h
index 478936365a6..fcbd44950e0 100644
--- a/src/lib/web/json/writer.h
+++ b/src/lib/web/json/writer.h
@@ -14,169 +14,168 @@
# include <iostream>
namespace Json {
-
- class Value;
-
- /** \brief Abstract class for writers.
- */
- class JSON_API Writer
- {
- public:
- virtual ~Writer();
-
- virtual std::string write( const Value &root ) = 0;
- };
-
- /** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly).
- *
- * The JSON document is written in a single line. It is not intended for 'human' consumption,
- * but may be usefull to support feature such as RPC where bandwith is limited.
- * \sa Reader, Value
- */
- class JSON_API FastWriter : public Writer
- {
- public:
- FastWriter();
- virtual ~FastWriter(){}
-
- void enableYAMLCompatibility();
-
- public: // overridden from Writer
- virtual std::string write( const Value &root );
-
- private:
- void writeValue( const Value &value );
-
- std::string document_;
- bool yamlCompatiblityEnabled_;
- };
-
- /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way.
- *
- * The rules for line break and indent are as follow:
- * - Object value:
- * - if empty then print {} without indent and line break
- * - if not empty the print '{', line break & indent, print one value per line
- * and then unindent and line break and print '}'.
- * - Array value:
- * - if empty then print [] without indent and line break
- * - if the array contains no object value, empty array or some other value types,
- * and all the values fit on one lines, then print the array on a single line.
- * - otherwise, it the values do not fit on one line, or the array contains
- * object or non empty array, then print one value per line.
- *
- * If the Value have comments then they are outputed according to their #CommentPlacement.
- *
- * \sa Reader, Value, Value::setComment()
- */
- class JSON_API StyledWriter: public Writer
- {
- public:
- StyledWriter();
- virtual ~StyledWriter(){}
-
- public: // overridden from Writer
- /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
- * \param root Value to serialize.
- * \return String containing the JSON document that represents the root value.
- */
- virtual std::string write( const Value &root );
-
- private:
- void writeValue( const Value &value );
- void writeArrayValue( const Value &value );
- bool isMultineArray( const Value &value );
- void pushValue( const std::string &value );
- void writeIndent();
- void writeWithIndent( const std::string &value );
- void indent();
- void unindent();
- void writeCommentBeforeValue( const Value &root );
- void writeCommentAfterValueOnSameLine( const Value &root );
- bool hasCommentForValue( const Value &value );
- static std::string normalizeEOL( const std::string &text );
-
- typedef std::vector<std::string> ChildValues;
-
- ChildValues childValues_;
- std::string document_;
- std::string indentString_;
- int rightMargin_;
- int indentSize_;
- bool addChildValues_;
- };
-
- /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way,
- to a stream rather than to a string.
- *
- * The rules for line break and indent are as follow:
- * - Object value:
- * - if empty then print {} without indent and line break
- * - if not empty the print '{', line break & indent, print one value per line
- * and then unindent and line break and print '}'.
- * - Array value:
- * - if empty then print [] without indent and line break
- * - if the array contains no object value, empty array or some other value types,
- * and all the values fit on one lines, then print the array on a single line.
- * - otherwise, it the values do not fit on one line, or the array contains
- * object or non empty array, then print one value per line.
- *
- * If the Value have comments then they are outputed according to their #CommentPlacement.
- *
- * \param indentation Each level will be indented by this amount extra.
- * \sa Reader, Value, Value::setComment()
- */
- class JSON_API StyledStreamWriter
- {
- public:
- StyledStreamWriter( std::string indentation="\t" );
- ~StyledStreamWriter(){}
-
- public:
- /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
- * \param out Stream to write to. (Can be ostringstream, e.g.)
- * \param root Value to serialize.
- * \note There is no point in deriving from Writer, since write() should not return a value.
- */
- void write( std::ostream &out, const Value &root );
-
- private:
- void writeValue( const Value &value );
- void writeArrayValue( const Value &value );
- bool isMultineArray( const Value &value );
- void pushValue( const std::string &value );
- void writeIndent();
- void writeWithIndent( const std::string &value );
- void indent();
- void unindent();
- void writeCommentBeforeValue( const Value &root );
- void writeCommentAfterValueOnSameLine( const Value &root );
- bool hasCommentForValue( const Value &value );
- static std::string normalizeEOL( const std::string &text );
-
- typedef std::vector<std::string> ChildValues;
-
- ChildValues childValues_;
- std::ostream* document_;
- std::string indentString_;
- int rightMargin_;
- std::string indentation_;
- bool addChildValues_;
- };
+ class Value;
+
+ /** \brief Abstract class for writers.
+ */
+ class JSON_API Writer
+ {
+ public:
+ virtual ~Writer();
+
+ virtual std::string write( const Value &root ) = 0;
+ };
+
+ /** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly).
+ *
+ * The JSON document is written in a single line. It is not intended for 'human' consumption,
+ * but may be usefull to support feature such as RPC where bandwith is limited.
+ * \sa Reader, Value
+ */
+ class JSON_API FastWriter : public Writer
+ {
+ public:
+ FastWriter();
+ virtual ~FastWriter(){}
+
+ void enableYAMLCompatibility();
+
+ public: // overridden from Writer
+ virtual std::string write( const Value &root );
+
+ private:
+ void writeValue( const Value &value );
+
+ std::string document_;
+ bool yamlCompatiblityEnabled_;
+ };
+
+ /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way.
+ *
+ * The rules for line break and indent are as follow:
+ * - Object value:
+ * - if empty then print {} without indent and line break
+ * - if not empty the print '{', line break & indent, print one value per line
+ * and then unindent and line break and print '}'.
+ * - Array value:
+ * - if empty then print [] without indent and line break
+ * - if the array contains no object value, empty array or some other value types,
+ * and all the values fit on one lines, then print the array on a single line.
+ * - otherwise, it the values do not fit on one line, or the array contains
+ * object or non empty array, then print one value per line.
+ *
+ * If the Value have comments then they are outputed according to their #CommentPlacement.
+ *
+ * \sa Reader, Value, Value::setComment()
+ */
+ class JSON_API StyledWriter: public Writer
+ {
+ public:
+ StyledWriter();
+ virtual ~StyledWriter(){}
+
+ public: // overridden from Writer
+ /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
+ * \param root Value to serialize.
+ * \return String containing the JSON document that represents the root value.
+ */
+ virtual std::string write( const Value &root );
+
+ private:
+ void writeValue( const Value &value );
+ void writeArrayValue( const Value &value );
+ bool isMultineArray( const Value &value );
+ void pushValue( const std::string &value );
+ void writeIndent();
+ void writeWithIndent( const std::string &value );
+ void indent();
+ void unindent();
+ void writeCommentBeforeValue( const Value &root );
+ void writeCommentAfterValueOnSameLine( const Value &root );
+ bool hasCommentForValue( const Value &value );
+ static std::string normalizeEOL( const std::string &text );
+
+ typedef std::vector<std::string> ChildValues;
+
+ ChildValues childValues_;
+ std::string document_;
+ std::string indentString_;
+ int rightMargin_;
+ int indentSize_;
+ bool addChildValues_;
+ };
+
+ /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way,
+ to a stream rather than to a string.
+ *
+ * The rules for line break and indent are as follow:
+ * - Object value:
+ * - if empty then print {} without indent and line break
+ * - if not empty the print '{', line break & indent, print one value per line
+ * and then unindent and line break and print '}'.
+ * - Array value:
+ * - if empty then print [] without indent and line break
+ * - if the array contains no object value, empty array or some other value types,
+ * and all the values fit on one lines, then print the array on a single line.
+ * - otherwise, it the values do not fit on one line, or the array contains
+ * object or non empty array, then print one value per line.
+ *
+ * If the Value have comments then they are outputed according to their #CommentPlacement.
+ *
+ * \param indentation Each level will be indented by this amount extra.
+ * \sa Reader, Value, Value::setComment()
+ */
+ class JSON_API StyledStreamWriter
+ {
+ public:
+ StyledStreamWriter( std::string indentation="\t" );
+ ~StyledStreamWriter(){}
+
+ public:
+ /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
+ * \param out Stream to write to. (Can be ostringstream, e.g.)
+ * \param root Value to serialize.
+ * \note There is no point in deriving from Writer, since write() should not return a value.
+ */
+ void write( std::ostream &out, const Value &root );
+
+ private:
+ void writeValue( const Value &value );
+ void writeArrayValue( const Value &value );
+ bool isMultineArray( const Value &value );
+ void pushValue( const std::string &value );
+ void writeIndent();
+ void writeWithIndent( const std::string &value );
+ void indent();
+ void unindent();
+ void writeCommentBeforeValue( const Value &root );
+ void writeCommentAfterValueOnSameLine( const Value &root );
+ bool hasCommentForValue( const Value &value );
+ static std::string normalizeEOL( const std::string &text );
+
+ typedef std::vector<std::string> ChildValues;
+
+ ChildValues childValues_;
+ std::ostream* document_;
+ std::string indentString_;
+ int rightMargin_;
+ std::string indentation_;
+ bool addChildValues_;
+ };
# if defined(JSON_HAS_INT64)
- std::string JSON_API valueToString( Int value );
- std::string JSON_API valueToString( UInt value );
+ std::string JSON_API valueToString( Int value );
+ std::string JSON_API valueToString( UInt value );
# endif // if defined(JSON_HAS_INT64)
- std::string JSON_API valueToString( LargestInt value );
- std::string JSON_API valueToString( LargestUInt value );
- std::string JSON_API valueToString( double value );
- std::string JSON_API valueToString( bool value );
- std::string JSON_API valueToQuotedString( const char *value );
-
- /// \brief Output using the StyledStreamWriter.
- /// \see Json::operator>>()
- std::ostream& operator<<( std::ostream&, const Value &root );
+ std::string JSON_API valueToString( LargestInt value );
+ std::string JSON_API valueToString( LargestUInt value );
+ std::string JSON_API valueToString( double value );
+ std::string JSON_API valueToString( bool value );
+ std::string JSON_API valueToQuotedString( const char *value );
+
+ /// \brief Output using the StyledStreamWriter.
+ /// \see Json::operator>>()
+ std::ostream& operator<<( std::ostream&, const Value &root );
} // namespace Json
diff --git a/src/lib/web/mongoose.c b/src/lib/web/mongoose.c
index f2e2d6a11ad..1718b2c6faa 100644
--- a/src/lib/web/mongoose.c
+++ b/src/lib/web/mongoose.c
@@ -100,11 +100,11 @@ typedef long off_t;
#endif // _WIN32_WCE
#define MAKEUQUAD(lo, hi) ((uint64_t)(((uint32_t)(lo)) | \
- ((uint64_t)((uint32_t)(hi))) << 32))
+ ((uint64_t)((uint32_t)(hi))) << 32))
#define RATE_DIFF 10000000 // 100 nsecs
#define EPOCH_DIFF MAKEUQUAD(0xd53e8000, 0x019db1de)
#define SYS2UNIX_TIME(lo, hi) \
- (time_t) ((MAKEUQUAD((lo), (hi)) - EPOCH_DIFF) / RATE_DIFF)
+ (time_t) ((MAKEUQUAD((lo), (hi)) - EPOCH_DIFF) / RATE_DIFF)
// Visual Studio 6 does not know __func__ or __FUNCTION__
// The rest of MS compilers use __FUNCTION__, not C99 __func__
@@ -192,20 +192,20 @@ typedef __int64 int64_t;
// POSIX dirent interface
struct dirent {
- char d_name[PATH_MAX];
+ char d_name[PATH_MAX];
};
typedef struct DIR {
- HANDLE handle;
- WIN32_FIND_DATAW info;
- struct dirent result;
+ HANDLE handle;
+ WIN32_FIND_DATAW info;
+ struct dirent result;
} DIR;
#ifndef HAVE_POLL
struct pollfd {
- int fd;
- short events;
- short revents;
+ int fd;
+ short events;
+ short revents;
};
#define POLLIN 1
#endif
@@ -274,7 +274,7 @@ typedef int SOCKET;
static CRITICAL_SECTION global_log_file_lock;
#if !defined(NO_SSL)
static pthread_t pthread_self(void) {
- return GetCurrentThreadId();
+ return GetCurrentThreadId();
}
#endif
#endif // _WIN32
@@ -285,14 +285,14 @@ static pthread_t pthread_self(void) {
#else
#if defined(DEBUG)
#define DEBUG_TRACE(x) do { \
- flockfile(stdout); \
- printf("*** %lu.%p.%s.%d: ", \
- (unsigned long) time(NULL), (void *) pthread_self(), \
- __func__, __LINE__); \
- printf x; \
- putchar('\n'); \
- fflush(stdout); \
- funlockfile(stdout); \
+ flockfile(stdout); \
+ printf("*** %lu.%p.%s.%d: ", \
+ (unsigned long) time(NULL), (void *) pthread_self(), \
+ __func__, __LINE__); \
+ printf x; \
+ putchar('\n'); \
+ fflush(stdout); \
+ funlockfile(stdout); \
} while (0)
#else
#define DEBUG_TRACE(x)
@@ -331,8 +331,8 @@ typedef struct ssl_method_st SSL_METHOD;
typedef struct ssl_ctx_st SSL_CTX;
struct ssl_func {
- const char *name; // SSL function name
- void (*ptr)(void); // Function pointer
+ const char *name; // SSL function name
+ void (*ptr)(void); // Function pointer
};
#define SSL_free (* (void (*)(SSL *)) ssl_sw[0].ptr)
@@ -347,15 +347,15 @@ struct ssl_func {
#define SSLv23_server_method (* (SSL_METHOD * (*)(void)) ssl_sw[9].ptr)
#define SSL_library_init (* (int (*)(void)) ssl_sw[10].ptr)
#define SSL_CTX_use_PrivateKey_file (* (int (*)(SSL_CTX *, \
- const char *, int)) ssl_sw[11].ptr)
+ const char *, int)) ssl_sw[11].ptr)
#define SSL_CTX_use_certificate_file (* (int (*)(SSL_CTX *, \
- const char *, int)) ssl_sw[12].ptr)
+ const char *, int)) ssl_sw[12].ptr)
#define SSL_CTX_set_default_passwd_cb \
- (* (void (*)(SSL_CTX *, mg_callback_t)) ssl_sw[13].ptr)
+ (* (void (*)(SSL_CTX *, mg_callback_t)) ssl_sw[13].ptr)
#define SSL_CTX_free (* (void (*)(SSL_CTX *)) ssl_sw[14].ptr)
#define SSL_load_error_strings (* (void (*)(void)) ssl_sw[15].ptr)
#define SSL_CTX_use_certificate_chain_file \
- (* (int (*)(SSL_CTX *, const char *)) ssl_sw[16].ptr)
+ (* (int (*)(SSL_CTX *, const char *)) ssl_sw[16].ptr)
#define SSLv23_client_method (* (SSL_METHOD * (*)(void)) ssl_sw[17].ptr)
#define SSL_pending (* (int (*)(SSL *)) ssl_sw[18].ptr)
#define SSL_CTX_set_verify (* (void (*)(SSL_CTX *, int, int)) ssl_sw[19].ptr)
@@ -363,9 +363,9 @@ struct ssl_func {
#define CRYPTO_num_locks (* (int (*)(void)) crypto_sw[0].ptr)
#define CRYPTO_set_locking_callback \
- (* (void (*)(void (*)(int, int, const char *, int))) crypto_sw[1].ptr)
+ (* (void (*)(void (*)(int, int, const char *, int))) crypto_sw[1].ptr)
#define CRYPTO_set_id_callback \
- (* (void (*)(unsigned long (*)(void))) crypto_sw[2].ptr)
+ (* (void (*)(unsigned long (*)(void))) crypto_sw[2].ptr)
#define ERR_get_error (* (unsigned long (*)(void)) crypto_sw[3].ptr)
#define ERR_error_string (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr)
@@ -374,370 +374,370 @@ struct ssl_func {
// of respective functions. The macros above (like SSL_connect()) are really
// just calling these functions indirectly via the pointer.
static struct ssl_func ssl_sw[] = {
- {"SSL_free", NULL},
- {"SSL_accept", NULL},
- {"SSL_connect", NULL},
- {"SSL_read", NULL},
- {"SSL_write", NULL},
- {"SSL_get_error", NULL},
- {"SSL_set_fd", NULL},
- {"SSL_new", NULL},
- {"SSL_CTX_new", NULL},
- {"SSLv23_server_method", NULL},
- {"SSL_library_init", NULL},
- {"SSL_CTX_use_PrivateKey_file", NULL},
- {"SSL_CTX_use_certificate_file",NULL},
- {"SSL_CTX_set_default_passwd_cb",NULL},
- {"SSL_CTX_free", NULL},
- {"SSL_load_error_strings", NULL},
- {"SSL_CTX_use_certificate_chain_file", NULL},
- {"SSLv23_client_method", NULL},
- {"SSL_pending", NULL},
- {"SSL_CTX_set_verify", NULL},
- {"SSL_shutdown", NULL},
- {NULL, NULL}
+ {"SSL_free", NULL},
+ {"SSL_accept", NULL},
+ {"SSL_connect", NULL},
+ {"SSL_read", NULL},
+ {"SSL_write", NULL},
+ {"SSL_get_error", NULL},
+ {"SSL_set_fd", NULL},
+ {"SSL_new", NULL},
+ {"SSL_CTX_new", NULL},
+ {"SSLv23_server_method", NULL},
+ {"SSL_library_init", NULL},
+ {"SSL_CTX_use_PrivateKey_file", NULL},
+ {"SSL_CTX_use_certificate_file",NULL},
+ {"SSL_CTX_set_default_passwd_cb",NULL},
+ {"SSL_CTX_free", NULL},
+ {"SSL_load_error_strings", NULL},
+ {"SSL_CTX_use_certificate_chain_file", NULL},
+ {"SSLv23_client_method", NULL},
+ {"SSL_pending", NULL},
+ {"SSL_CTX_set_verify", NULL},
+ {"SSL_shutdown", NULL},
+ {NULL, NULL}
};
// Similar array as ssl_sw. These functions could be located in different lib.
#if !defined(NO_SSL)
static struct ssl_func crypto_sw[] = {
- {"CRYPTO_num_locks", NULL},
- {"CRYPTO_set_locking_callback", NULL},
- {"CRYPTO_set_id_callback", NULL},
- {"ERR_get_error", NULL},
- {"ERR_error_string", NULL},
- {NULL, NULL}
+ {"CRYPTO_num_locks", NULL},
+ {"CRYPTO_set_locking_callback", NULL},
+ {"CRYPTO_set_id_callback", NULL},
+ {"ERR_get_error", NULL},
+ {"ERR_error_string", NULL},
+ {NULL, NULL}
};
#endif // NO_SSL
#endif // NO_SSL_DL
static const char *month_names[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
// Unified socket address. For IPv6 support, add IPv6 address structure
// in the union u.
union usa {
- struct sockaddr sa;
- struct sockaddr_in sin;
+ struct sockaddr sa;
+ struct sockaddr_in sin;
#if defined(USE_IPV6)
- struct sockaddr_in6 sin6;
+ struct sockaddr_in6 sin6;
#endif
};
// Describes a string (chunk of memory).
struct vec {
- const char *ptr;
- size_t len;
+ const char *ptr;
+ size_t len;
};
struct file {
- int is_directory;
- time_t modification_time;
- int64_t size;
- FILE *fp;
- const char *membuf; // Non-NULL if file data is in memory
- // set to 1 if the content is gzipped
- // in which case we need a content-encoding: gzip header
- int gzipped;
+ int is_directory;
+ time_t modification_time;
+ int64_t size;
+ FILE *fp;
+ const char *membuf; // Non-NULL if file data is in memory
+ // set to 1 if the content is gzipped
+ // in which case we need a content-encoding: gzip header
+ int gzipped;
};
#define STRUCT_FILE_INITIALIZER {0, 0, 0, NULL, NULL, 0}
// Describes listening socket, or socket which was accept()-ed by the master
// thread and queued for future handling by the worker thread.
struct socket {
- SOCKET sock; // Listening socket
- union usa lsa; // Local socket address
- union usa rsa; // Remote socket address
- unsigned is_ssl:1; // Is port SSL-ed
- unsigned ssl_redir:1; // Is port supposed to redirect everything to SSL port
+ SOCKET sock; // Listening socket
+ union usa lsa; // Local socket address
+ union usa rsa; // Remote socket address
+ unsigned is_ssl:1; // Is port SSL-ed
+ unsigned ssl_redir:1; // Is port supposed to redirect everything to SSL port
};
// NOTE(lsm): this enum shoulds be in sync with the config_options below.
enum {
- CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER,
- PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, THROTTLE,
- ACCESS_LOG_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE,
- GLOBAL_PASSWORDS_FILE, INDEX_FILES, ENABLE_KEEP_ALIVE, ACCESS_CONTROL_LIST,
- EXTRA_MIME_TYPES, LISTENING_PORTS, DOCUMENT_ROOT, SSL_CERTIFICATE,
- NUM_THREADS, RUN_AS_USER, REWRITE, HIDE_FILES, REQUEST_TIMEOUT,
- NUM_OPTIONS
+ CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER,
+ PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, THROTTLE,
+ ACCESS_LOG_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE,
+ GLOBAL_PASSWORDS_FILE, INDEX_FILES, ENABLE_KEEP_ALIVE, ACCESS_CONTROL_LIST,
+ EXTRA_MIME_TYPES, LISTENING_PORTS, DOCUMENT_ROOT, SSL_CERTIFICATE,
+ NUM_THREADS, RUN_AS_USER, REWRITE, HIDE_FILES, REQUEST_TIMEOUT,
+ NUM_OPTIONS
};
static const char *config_options[] = {
- "cgi_pattern", "**.cgi$|**.pl$|**.php$",
- "cgi_environment", NULL,
- "put_delete_auth_file", NULL,
- "cgi_interpreter", NULL,
- "protect_uri", NULL,
- "authentication_domain", "mydomain.com",
- "ssi_pattern", "**.shtml$|**.shtm$",
- "throttle", NULL,
- "access_log_file", NULL,
- "enable_directory_listing", "yes",
- "error_log_file", NULL,
- "global_auth_file", NULL,
- "index_files",
- "index.html,index.htm,index.cgi,index.shtml,index.php,index.lp",
- "enable_keep_alive", "no",
- "access_control_list", NULL,
- "extra_mime_types", NULL,
- "listening_ports", "8080",
- "document_root", ".",
- "ssl_certificate", NULL,
- "num_threads", "50",
- "run_as_user", NULL,
- "url_rewrite_patterns", NULL,
- "hide_files_patterns", NULL,
- "request_timeout_ms", "30000",
- NULL
+ "cgi_pattern", "**.cgi$|**.pl$|**.php$",
+ "cgi_environment", NULL,
+ "put_delete_auth_file", NULL,
+ "cgi_interpreter", NULL,
+ "protect_uri", NULL,
+ "authentication_domain", "mydomain.com",
+ "ssi_pattern", "**.shtml$|**.shtm$",
+ "throttle", NULL,
+ "access_log_file", NULL,
+ "enable_directory_listing", "yes",
+ "error_log_file", NULL,
+ "global_auth_file", NULL,
+ "index_files",
+ "index.html,index.htm,index.cgi,index.shtml,index.php,index.lp",
+ "enable_keep_alive", "no",
+ "access_control_list", NULL,
+ "extra_mime_types", NULL,
+ "listening_ports", "8080",
+ "document_root", ".",
+ "ssl_certificate", NULL,
+ "num_threads", "50",
+ "run_as_user", NULL,
+ "url_rewrite_patterns", NULL,
+ "hide_files_patterns", NULL,
+ "request_timeout_ms", "30000",
+ NULL
};
struct mg_context {
- volatile int stop_flag; // Should we stop event loop
- SSL_CTX *ssl_ctx; // SSL context
- char *config[NUM_OPTIONS]; // Mongoose configuration parameters
- struct mg_callbacks callbacks; // User-defined callback function
- void *user_data; // User-defined data
-
- struct socket *listening_sockets;
- int num_listening_sockets;
-
- volatile int num_threads; // Number of threads
- pthread_mutex_t mutex; // Protects (max|num)_threads
- pthread_cond_t cond; // Condvar for tracking workers terminations
-
- struct socket queue[20]; // Accepted sockets
- volatile int sq_head; // Head of the socket queue
- volatile int sq_tail; // Tail of the socket queue
- pthread_cond_t sq_full; // Signaled when socket is produced
- pthread_cond_t sq_empty; // Signaled when socket is consumed
+ volatile int stop_flag; // Should we stop event loop
+ SSL_CTX *ssl_ctx; // SSL context
+ char *config[NUM_OPTIONS]; // Mongoose configuration parameters
+ struct mg_callbacks callbacks; // User-defined callback function
+ void *user_data; // User-defined data
+
+ struct socket *listening_sockets;
+ int num_listening_sockets;
+
+ volatile int num_threads; // Number of threads
+ pthread_mutex_t mutex; // Protects (max|num)_threads
+ pthread_cond_t cond; // Condvar for tracking workers terminations
+
+ struct socket queue[20]; // Accepted sockets
+ volatile int sq_head; // Head of the socket queue
+ volatile int sq_tail; // Tail of the socket queue
+ pthread_cond_t sq_full; // Signaled when socket is produced
+ pthread_cond_t sq_empty; // Signaled when socket is consumed
};
struct mg_connection {
- struct mg_request_info request_info;
- struct mg_context *ctx;
- SSL *ssl; // SSL descriptor
- SSL_CTX *client_ssl_ctx; // SSL context for client connections
- struct socket client; // Connected client
- time_t birth_time; // Time when request was received
- int64_t num_bytes_sent; // Total bytes sent to client
- int64_t content_len; // Content-Length header value
- int64_t consumed_content; // How many bytes of content have been read
- char *buf; // Buffer for received data
- char *path_info; // PATH_INFO part of the URL
- int must_close; // 1 if connection must be closed
- int buf_size; // Buffer size
- int request_len; // Size of the request + headers in a buffer
- int data_len; // Total size of data in a buffer
- int status_code; // HTTP reply status code, e.g. 200
- int throttle; // Throttling, bytes/sec. <= 0 means no throttle
- time_t last_throttle_time; // Last time throttled data was sent
- int64_t last_throttle_bytes;// Bytes sent this second
+ struct mg_request_info request_info;
+ struct mg_context *ctx;
+ SSL *ssl; // SSL descriptor
+ SSL_CTX *client_ssl_ctx; // SSL context for client connections
+ struct socket client; // Connected client
+ time_t birth_time; // Time when request was received
+ int64_t num_bytes_sent; // Total bytes sent to client
+ int64_t content_len; // Content-Length header value
+ int64_t consumed_content; // How many bytes of content have been read
+ char *buf; // Buffer for received data
+ char *path_info; // PATH_INFO part of the URL
+ int must_close; // 1 if connection must be closed
+ int buf_size; // Buffer size
+ int request_len; // Size of the request + headers in a buffer
+ int data_len; // Total size of data in a buffer
+ int status_code; // HTTP reply status code, e.g. 200
+ int throttle; // Throttling, bytes/sec. <= 0 means no throttle
+ time_t last_throttle_time; // Last time throttled data was sent
+ int64_t last_throttle_bytes;// Bytes sent this second
};
// Directory entry
struct de {
- struct mg_connection *conn;
- char *file_name;
- struct file file;
+ struct mg_connection *conn;
+ char *file_name;
+ struct file file;
};
const char **mg_get_valid_option_names(void) {
- return config_options;
+ return config_options;
}
static int is_file_in_memory(struct mg_connection *conn, const char *path,
- struct file *filep) {
- size_t size = 0;
- if ((filep->membuf = conn->ctx->callbacks.open_file == NULL ? NULL :
- conn->ctx->callbacks.open_file(conn, path, &size)) != NULL) {
- // NOTE: override filep->size only on success. Otherwise, it might break
- // constructs like if (!mg_stat() || !mg_fopen()) ...
- filep->size = size;
- }
- return filep->membuf != NULL;
+ struct file *filep) {
+ size_t size = 0;
+ if ((filep->membuf = conn->ctx->callbacks.open_file == NULL ? NULL :
+ conn->ctx->callbacks.open_file(conn, path, &size)) != NULL) {
+ // NOTE: override filep->size only on success. Otherwise, it might break
+ // constructs like if (!mg_stat() || !mg_fopen()) ...
+ filep->size = size;
+ }
+ return filep->membuf != NULL;
}
static int is_file_opened(const struct file *filep) {
- return filep->membuf != NULL || filep->fp != NULL;
+ return filep->membuf != NULL || filep->fp != NULL;
}
static int mg_fopen(struct mg_connection *conn, const char *path,
- const char *mode, struct file *filep) {
- if (!is_file_in_memory(conn, path, filep)) {
+ const char *mode, struct file *filep) {
+ if (!is_file_in_memory(conn, path, filep)) {
#ifdef _WIN32
- wchar_t wbuf[PATH_MAX], wmode[20];
- to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
- MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, ARRAY_SIZE(wmode));
- filep->fp = _wfopen(wbuf, wmode);
+ wchar_t wbuf[PATH_MAX], wmode[20];
+ to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
+ MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, ARRAY_SIZE(wmode));
+ filep->fp = _wfopen(wbuf, wmode);
#else
- filep->fp = fopen(path, mode);
+ filep->fp = fopen(path, mode);
#endif
- }
+ }
- return is_file_opened(filep);
+ return is_file_opened(filep);
}
static void mg_fclose(struct file *filep) {
- if (filep != NULL && filep->fp != NULL) {
- fclose(filep->fp);
- }
+ if (filep != NULL && filep->fp != NULL) {
+ fclose(filep->fp);
+ }
}
static int get_option_index(const char *name) {
- int i;
+ int i;
- for (i = 0; config_options[i * 2] != NULL; i++) {
- if (strcmp(config_options[i * 2], name) == 0) {
- return i;
- }
- }
- return -1;
+ for (i = 0; config_options[i * 2] != NULL; i++) {
+ if (strcmp(config_options[i * 2], name) == 0) {
+ return i;
+ }
+ }
+ return -1;
}
const char *mg_get_option(const struct mg_context *ctx, const char *name) {
- int i;
- if ((i = get_option_index(name)) == -1) {
- return NULL;
- } else if (ctx->config[i] == NULL) {
- return "";
- } else {
- return ctx->config[i];
- }
+ int i;
+ if ((i = get_option_index(name)) == -1) {
+ return NULL;
+ } else if (ctx->config[i] == NULL) {
+ return "";
+ } else {
+ return ctx->config[i];
+ }
}
static void sockaddr_to_string(char *buf, size_t len,
- const union usa *usa) {
- buf[0] = '\0';
+ const union usa *usa) {
+ buf[0] = '\0';
#if defined(USE_IPV6)
- inet_ntop(usa->sa.sa_family, usa->sa.sa_family == AF_INET ?
- (void *) &usa->sin.sin_addr :
- (void *) &usa->sin6.sin6_addr, buf, len);
+ inet_ntop(usa->sa.sa_family, usa->sa.sa_family == AF_INET ?
+ (void *) &usa->sin.sin_addr :
+ (void *) &usa->sin6.sin6_addr, buf, len);
#elif defined(_WIN32)
- // Only Windoze Vista (and newer) have inet_ntop()
- strncpy(buf, inet_ntoa(usa->sin.sin_addr), len);
+ // Only Windoze Vista (and newer) have inet_ntop()
+ strncpy(buf, inet_ntoa(usa->sin.sin_addr), len);
#else
- inet_ntop(usa->sa.sa_family, (void *) &usa->sin.sin_addr, buf, len);
+ inet_ntop(usa->sa.sa_family, (void *) &usa->sin.sin_addr, buf, len);
#endif
}
static void cry(struct mg_connection *conn,
- PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
+ PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
// Print error message to the opened error log stream.
static void cry(struct mg_connection *conn, const char *fmt, ...) {
- char buf[MG_BUF_LEN], src_addr[IP_ADDR_STR_LEN];
- va_list ap;
- FILE *fp;
- time_t timestamp;
-
- va_start(ap, fmt);
- (void) vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- // Do not lock when getting the callback value, here and below.
- // I suppose this is fine, since function cannot disappear in the
- // same way string option can.
- if (conn->ctx->callbacks.log_message == NULL ||
- conn->ctx->callbacks.log_message(conn, buf) == 0) {
- fp = conn->ctx == NULL || conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL :
- fopen(conn->ctx->config[ERROR_LOG_FILE], "a+");
-
- if (fp != NULL) {
- flockfile(fp);
- timestamp = time(NULL);
-
- sockaddr_to_string(src_addr, sizeof(src_addr), &conn->client.rsa);
- fprintf(fp, "[%010lu] [error] [client %s] ", (unsigned long) timestamp,
- src_addr);
-
- if (conn->request_info.request_method != NULL) {
- fprintf(fp, "%s %s: ", conn->request_info.request_method,
- conn->request_info.uri);
- }
-
- fprintf(fp, "%s", buf);
- fputc('\n', fp);
- funlockfile(fp);
- fclose(fp);
- }
- }
+ char buf[MG_BUF_LEN], src_addr[IP_ADDR_STR_LEN];
+ va_list ap;
+ FILE *fp;
+ time_t timestamp;
+
+ va_start(ap, fmt);
+ (void) vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ // Do not lock when getting the callback value, here and below.
+ // I suppose this is fine, since function cannot disappear in the
+ // same way string option can.
+ if (conn->ctx->callbacks.log_message == NULL ||
+ conn->ctx->callbacks.log_message(conn, buf) == 0) {
+ fp = conn->ctx == NULL || conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL :
+ fopen(conn->ctx->config[ERROR_LOG_FILE], "a+");
+
+ if (fp != NULL) {
+ flockfile(fp);
+ timestamp = time(NULL);
+
+ sockaddr_to_string(src_addr, sizeof(src_addr), &conn->client.rsa);
+ fprintf(fp, "[%010lu] [error] [client %s] ", (unsigned long) timestamp,
+ src_addr);
+
+ if (conn->request_info.request_method != NULL) {
+ fprintf(fp, "%s %s: ", conn->request_info.request_method,
+ conn->request_info.uri);
+ }
+
+ fprintf(fp, "%s", buf);
+ fputc('\n', fp);
+ funlockfile(fp);
+ fclose(fp);
+ }
+ }
}
// Return fake connection structure. Used for logging, if connection
// is not applicable at the moment of logging.
static struct mg_connection *fc(struct mg_context *ctx) {
- static struct mg_connection fake_connection;
- fake_connection.ctx = ctx;
- return &fake_connection;
+ static struct mg_connection fake_connection;
+ fake_connection.ctx = ctx;
+ return &fake_connection;
}
const char *mg_version(void) {
- return MONGOOSE_VERSION;
+ return MONGOOSE_VERSION;
}
struct mg_request_info *mg_get_request_info(struct mg_connection *conn) {
- return &conn->request_info;
+ return &conn->request_info;
}
static void mg_strlcpy(register char *dst, register const char *src, size_t n) {
- for (; *src != '\0' && n > 1; n--) {
- *dst++ = *src++;
- }
- *dst = '\0';
+ for (; *src != '\0' && n > 1; n--) {
+ *dst++ = *src++;
+ }
+ *dst = '\0';
}
static int lowercase(const char *s) {
- return tolower(* (const unsigned char *) s);
+ return tolower(* (const unsigned char *) s);
}
static int mg_strncasecmp(const char *s1, const char *s2, size_t len) {
- int diff = 0;
+ int diff = 0;
- if (len > 0)
- do {
- diff = lowercase(s1++) - lowercase(s2++);
- } while (diff == 0 && s1[-1] != '\0' && --len > 0);
+ if (len > 0)
+ do {
+ diff = lowercase(s1++) - lowercase(s2++);
+ } while (diff == 0 && s1[-1] != '\0' && --len > 0);
- return diff;
+ return diff;
}
static int mg_strcasecmp(const char *s1, const char *s2) {
- int diff;
+ int diff;
- do {
- diff = lowercase(s1++) - lowercase(s2++);
- } while (diff == 0 && s1[-1] != '\0');
+ do {
+ diff = lowercase(s1++) - lowercase(s2++);
+ } while (diff == 0 && s1[-1] != '\0');
- return diff;
+ return diff;
}
static char * mg_strndup(const char *ptr, size_t len) {
- char *p;
+ char *p;
- if ((p = (char *) malloc(len + 1)) != NULL) {
- mg_strlcpy(p, ptr, len + 1);
- }
+ if ((p = (char *) malloc(len + 1)) != NULL) {
+ mg_strlcpy(p, ptr, len + 1);
+ }
- return p;
+ return p;
}
static char * mg_strdup(const char *str) {
- return mg_strndup(str, strlen(str));
+ return mg_strndup(str, strlen(str));
}
static const char *mg_strcasestr(const char *big_str, const char *small_str) {
- int i, big_len = strlen(big_str), small_len = strlen(small_str);
+ int i, big_len = strlen(big_str), small_len = strlen(small_str);
- for (i = 0; i <= big_len - small_len; i++) {
- if (mg_strncasecmp(big_str + i, small_str, small_len) == 0) {
- return big_str + i;
- }
- }
+ for (i = 0; i <= big_len - small_len; i++) {
+ if (mg_strncasecmp(big_str + i, small_str, small_len) == 0) {
+ return big_str + i;
+ }
+ }
- return NULL;
+ return NULL;
}
// Like snprintf(), but never returns negative value, or a value
@@ -745,41 +745,41 @@ static const char *mg_strcasestr(const char *big_str, const char *small_str) {
// Thanks to Adam Zeldis to pointing snprintf()-caused vulnerability
// in his audit report.
static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
- const char *fmt, va_list ap) {
- int n;
+ const char *fmt, va_list ap) {
+ int n;
- if (buflen == 0)
- return 0;
+ if (buflen == 0)
+ return 0;
- n = vsnprintf(buf, buflen, fmt, ap);
+ n = vsnprintf(buf, buflen, fmt, ap);
- if (n < 0) {
- cry(conn, "vsnprintf error");
- n = 0;
- } else if (n >= (int) buflen) {
- cry(conn, "truncating vsnprintf buffer: [%.*s]",
- n > 200 ? 200 : n, buf);
- n = (int) buflen - 1;
- }
- buf[n] = '\0';
+ if (n < 0) {
+ cry(conn, "vsnprintf error");
+ n = 0;
+ } else if (n >= (int) buflen) {
+ cry(conn, "truncating vsnprintf buffer: [%.*s]",
+ n > 200 ? 200 : n, buf);
+ n = (int) buflen - 1;
+ }
+ buf[n] = '\0';
- return n;
+ return n;
}
static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
- PRINTF_FORMAT_STRING(const char *fmt), ...)
- PRINTF_ARGS(4, 5);
+ PRINTF_FORMAT_STRING(const char *fmt), ...)
+ PRINTF_ARGS(4, 5);
static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
- const char *fmt, ...) {
- va_list ap;
- int n;
+ const char *fmt, ...) {
+ va_list ap;
+ int n;
- va_start(ap, fmt);
- n = mg_vsnprintf(conn, buf, buflen, fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ n = mg_vsnprintf(conn, buf, buflen, fmt, ap);
+ va_end(ap);
- return n;
+ return n;
}
// Skip the characters until one of the delimiters characters found.
@@ -787,68 +787,68 @@ static int mg_snprintf(struct mg_connection *conn, char *buf, size_t buflen,
// Advance pointer to buffer to the next word. Return found 0-terminated word.
// Delimiters can be quoted with quotechar.
static char *skip_quoted(char **buf, const char *delimiters,
- const char *whitespace, char quotechar) {
- char *p, *begin_word, *end_word, *end_whitespace;
-
- begin_word = *buf;
- end_word = begin_word + strcspn(begin_word, delimiters);
-
- // Check for quotechar
- if (end_word > begin_word) {
- p = end_word - 1;
- while (*p == quotechar) {
- // If there is anything beyond end_word, copy it
- if (*end_word == '\0') {
- *p = '\0';
- break;
- } else {
- size_t end_off = strcspn(end_word + 1, delimiters);
- memmove (p, end_word, end_off + 1);
- p += end_off; // p must correspond to end_word - 1
- end_word += end_off + 1;
- }
- }
- for (p++; p < end_word; p++) {
- *p = '\0';
- }
- }
-
- if (*end_word == '\0') {
- *buf = end_word;
- } else {
- end_whitespace = end_word + 1 + strspn(end_word + 1, whitespace);
-
- for (p = end_word; p < end_whitespace; p++) {
- *p = '\0';
- }
-
- *buf = end_whitespace;
- }
-
- return begin_word;
+ const char *whitespace, char quotechar) {
+ char *p, *begin_word, *end_word, *end_whitespace;
+
+ begin_word = *buf;
+ end_word = begin_word + strcspn(begin_word, delimiters);
+
+ // Check for quotechar
+ if (end_word > begin_word) {
+ p = end_word - 1;
+ while (*p == quotechar) {
+ // If there is anything beyond end_word, copy it
+ if (*end_word == '\0') {
+ *p = '\0';
+ break;
+ } else {
+ size_t end_off = strcspn(end_word + 1, delimiters);
+ memmove (p, end_word, end_off + 1);
+ p += end_off; // p must correspond to end_word - 1
+ end_word += end_off + 1;
+ }
+ }
+ for (p++; p < end_word; p++) {
+ *p = '\0';
+ }
+ }
+
+ if (*end_word == '\0') {
+ *buf = end_word;
+ } else {
+ end_whitespace = end_word + 1 + strspn(end_word + 1, whitespace);
+
+ for (p = end_word; p < end_whitespace; p++) {
+ *p = '\0';
+ }
+
+ *buf = end_whitespace;
+ }
+
+ return begin_word;
}
// Simplified version of skip_quoted without quote char
// and whitespace == delimiters
static char *skip(char **buf, const char *delimiters) {
- return skip_quoted(buf, delimiters, delimiters, 0);
+ return skip_quoted(buf, delimiters, delimiters, 0);
}
// Return HTTP header value, or NULL if not found.
static const char *get_header(const struct mg_request_info *ri,
- const char *name) {
- int i;
+ const char *name) {
+ int i;
- for (i = 0; i < ri->num_headers; i++)
- if (!mg_strcasecmp(name, ri->http_headers[i].name))
- return ri->http_headers[i].value;
+ for (i = 0; i < ri->num_headers; i++)
+ if (!mg_strcasecmp(name, ri->http_headers[i].name))
+ return ri->http_headers[i].value;
- return NULL;
+ return NULL;
}
const char *mg_get_header(const struct mg_connection *conn, const char *name) {
- return get_header(&conn->request_info, name);
+ return get_header(&conn->request_info, name);
}
// A helper function for traversing a comma separated list of values.
@@ -858,266 +858,266 @@ const char *mg_get_header(const struct mg_connection *conn, const char *name) {
// vector is initialized to point to the "y" part, and val vector length
// is adjusted to point only to "x".
static const char *next_option(const char *list, struct vec *val,
- struct vec *eq_val) {
- if (list == NULL || *list == '\0') {
- // End of the list
- list = NULL;
- } else {
- val->ptr = list;
- if ((list = strchr(val->ptr, ',')) != NULL) {
- // Comma found. Store length and shift the list ptr
- val->len = list - val->ptr;
- list++;
- } else {
- // This value is the last one
- list = val->ptr + strlen(val->ptr);
- val->len = list - val->ptr;
- }
-
- if (eq_val != NULL) {
- // Value has form "x=y", adjust pointers and lengths
- // so that val points to "x", and eq_val points to "y".
- eq_val->len = 0;
- eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
- if (eq_val->ptr != NULL) {
- eq_val->ptr++; // Skip over '=' character
- eq_val->len = val->ptr + val->len - eq_val->ptr;
- val->len = (eq_val->ptr - val->ptr) - 1;
- }
- }
- }
-
- return list;
+ struct vec *eq_val) {
+ if (list == NULL || *list == '\0') {
+ // End of the list
+ list = NULL;
+ } else {
+ val->ptr = list;
+ if ((list = strchr(val->ptr, ',')) != NULL) {
+ // Comma found. Store length and shift the list ptr
+ val->len = list - val->ptr;
+ list++;
+ } else {
+ // This value is the last one
+ list = val->ptr + strlen(val->ptr);
+ val->len = list - val->ptr;
+ }
+
+ if (eq_val != NULL) {
+ // Value has form "x=y", adjust pointers and lengths
+ // so that val points to "x", and eq_val points to "y".
+ eq_val->len = 0;
+ eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len);
+ if (eq_val->ptr != NULL) {
+ eq_val->ptr++; // Skip over '=' character
+ eq_val->len = val->ptr + val->len - eq_val->ptr;
+ val->len = (eq_val->ptr - val->ptr) - 1;
+ }
+ }
+ }
+
+ return list;
}
static int match_prefix(const char *pattern, int pattern_len, const char *str) {
- const char *or_str;
- int i, j, len, res;
-
- if ((or_str = (const char *) memchr(pattern, '|', pattern_len)) != NULL) {
- res = match_prefix(pattern, or_str - pattern, str);
- return res > 0 ? res :
- match_prefix(or_str + 1, (pattern + pattern_len) - (or_str + 1), str);
- }
-
- i = j = 0;
- res = -1;
- for (; i < pattern_len; i++, j++) {
- if (pattern[i] == '?' && str[j] != '\0') {
- continue;
- } else if (pattern[i] == '$') {
- return str[j] == '\0' ? j : -1;
- } else if (pattern[i] == '*') {
- i++;
- if (pattern[i] == '*') {
- i++;
- len = (int) strlen(str + j);
- } else {
- len = (int) strcspn(str + j, "/");
- }
- if (i == pattern_len) {
- return j + len;
- }
- do {
- res = match_prefix(pattern + i, pattern_len - i, str + j + len);
- } while (res == -1 && len-- > 0);
- return res == -1 ? -1 : j + res + len;
- } else if (pattern[i] != str[j]) {
- return -1;
- }
- }
- return j;
+ const char *or_str;
+ int i, j, len, res;
+
+ if ((or_str = (const char *) memchr(pattern, '|', pattern_len)) != NULL) {
+ res = match_prefix(pattern, or_str - pattern, str);
+ return res > 0 ? res :
+ match_prefix(or_str + 1, (pattern + pattern_len) - (or_str + 1), str);
+ }
+
+ i = j = 0;
+ res = -1;
+ for (; i < pattern_len; i++, j++) {
+ if (pattern[i] == '?' && str[j] != '\0') {
+ continue;
+ } else if (pattern[i] == '$') {
+ return str[j] == '\0' ? j : -1;
+ } else if (pattern[i] == '*') {
+ i++;
+ if (pattern[i] == '*') {
+ i++;
+ len = (int) strlen(str + j);
+ } else {
+ len = (int) strcspn(str + j, "/");
+ }
+ if (i == pattern_len) {
+ return j + len;
+ }
+ do {
+ res = match_prefix(pattern + i, pattern_len - i, str + j + len);
+ } while (res == -1 && len-- > 0);
+ return res == -1 ? -1 : j + res + len;
+ } else if (pattern[i] != str[j]) {
+ return -1;
+ }
+ }
+ return j;
}
// HTTP 1.1 assumes keep alive if "Connection:" header is not set
// This function must tolerate situations when connection info is not
// set up, for example if request parsing failed.
static int should_keep_alive(const struct mg_connection *conn) {
- const char *http_version = conn->request_info.http_version;
- const char *header = mg_get_header(conn, "Connection");
- if (conn->must_close ||
- conn->status_code == 401 ||
- mg_strcasecmp(conn->ctx->config[ENABLE_KEEP_ALIVE], "yes") != 0 ||
- (header != NULL && mg_strcasecmp(header, "keep-alive") != 0) ||
- (header == NULL && http_version && strcmp(http_version, "1.1"))) {
- return 0;
- }
- return 1;
+ const char *http_version = conn->request_info.http_version;
+ const char *header = mg_get_header(conn, "Connection");
+ if (conn->must_close ||
+ conn->status_code == 401 ||
+ mg_strcasecmp(conn->ctx->config[ENABLE_KEEP_ALIVE], "yes") != 0 ||
+ (header != NULL && mg_strcasecmp(header, "keep-alive") != 0) ||
+ (header == NULL && http_version && strcmp(http_version, "1.1"))) {
+ return 0;
+ }
+ return 1;
}
static const char *suggest_connection_header(const struct mg_connection *conn) {
- return should_keep_alive(conn) ? "keep-alive" : "close";
+ return should_keep_alive(conn) ? "keep-alive" : "close";
}
static void send_http_error(struct mg_connection *, int, const char *,
- PRINTF_FORMAT_STRING(const char *fmt), ...)
- PRINTF_ARGS(4, 5);
+ PRINTF_FORMAT_STRING(const char *fmt), ...)
+ PRINTF_ARGS(4, 5);
static void send_http_error(struct mg_connection *conn, int status,
- const char *reason, const char *fmt, ...) {
- char buf[MG_BUF_LEN];
- va_list ap;
- int len = 0;
-
- conn->status_code = status;
- if (conn->ctx->callbacks.http_error == NULL ||
- conn->ctx->callbacks.http_error(conn, status)) {
- buf[0] = '\0';
-
- // Errors 1xx, 204 and 304 MUST NOT send a body
- if (status > 199 && status != 204 && status != 304) {
- len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason);
- buf[len++] = '\n';
-
- va_start(ap, fmt);
- len += mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap);
- va_end(ap);
- }
- DEBUG_TRACE(("[%s]", buf));
-
- mg_printf(conn, "HTTP/1.1 %d %s\r\n"
- "Content-Length: %d\r\n"
- "Connection: %s\r\n\r\n", status, reason, len,
- suggest_connection_header(conn));
- conn->num_bytes_sent += mg_printf(conn, "%s", buf);
- }
+ const char *reason, const char *fmt, ...) {
+ char buf[MG_BUF_LEN];
+ va_list ap;
+ int len = 0;
+
+ conn->status_code = status;
+ if (conn->ctx->callbacks.http_error == NULL ||
+ conn->ctx->callbacks.http_error(conn, status)) {
+ buf[0] = '\0';
+
+ // Errors 1xx, 204 and 304 MUST NOT send a body
+ if (status > 199 && status != 204 && status != 304) {
+ len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason);
+ buf[len++] = '\n';
+
+ va_start(ap, fmt);
+ len += mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap);
+ va_end(ap);
+ }
+ DEBUG_TRACE(("[%s]", buf));
+
+ mg_printf(conn, "HTTP/1.1 %d %s\r\n"
+ "Content-Length: %d\r\n"
+ "Connection: %s\r\n\r\n", status, reason, len,
+ suggest_connection_header(conn));
+ conn->num_bytes_sent += mg_printf(conn, "%s", buf);
+ }
}
#if defined(_WIN32) && !defined(__SYMBIAN32__)
static int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
- (void) unused;
- *mutex = CreateMutex(NULL, FALSE, NULL);
- return *mutex == NULL ? -1 : 0;
+ (void) unused;
+ *mutex = CreateMutex(NULL, FALSE, NULL);
+ return *mutex == NULL ? -1 : 0;
}
static int pthread_mutex_destroy(pthread_mutex_t *mutex) {
- return CloseHandle(*mutex) == 0 ? -1 : 0;
+ return CloseHandle(*mutex) == 0 ? -1 : 0;
}
static int pthread_mutex_lock(pthread_mutex_t *mutex) {
- return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1;
+ return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1;
}
static int pthread_mutex_unlock(pthread_mutex_t *mutex) {
- return ReleaseMutex(*mutex) == 0 ? -1 : 0;
+ return ReleaseMutex(*mutex) == 0 ? -1 : 0;
}
static int pthread_cond_init(pthread_cond_t *cv, const void *unused) {
- (void) unused;
- cv->signal = CreateEvent(NULL, FALSE, FALSE, NULL);
- cv->broadcast = CreateEvent(NULL, TRUE, FALSE, NULL);
- return cv->signal != NULL && cv->broadcast != NULL ? 0 : -1;
+ (void) unused;
+ cv->signal = CreateEvent(NULL, FALSE, FALSE, NULL);
+ cv->broadcast = CreateEvent(NULL, TRUE, FALSE, NULL);
+ return cv->signal != NULL && cv->broadcast != NULL ? 0 : -1;
}
static int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex) {
- HANDLE handles[] = {cv->signal, cv->broadcast};
- ReleaseMutex(*mutex);
- WaitForMultipleObjects(2, handles, FALSE, INFINITE);
- return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1;
+ HANDLE handles[] = {cv->signal, cv->broadcast};
+ ReleaseMutex(*mutex);
+ WaitForMultipleObjects(2, handles, FALSE, INFINITE);
+ return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1;
}
static int pthread_cond_signal(pthread_cond_t *cv) {
- return SetEvent(cv->signal) == 0 ? -1 : 0;
+ return SetEvent(cv->signal) == 0 ? -1 : 0;
}
static int pthread_cond_broadcast(pthread_cond_t *cv) {
- // Implementation with PulseEvent() has race condition, see
- // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
- return PulseEvent(cv->broadcast) == 0 ? -1 : 0;
+ // Implementation with PulseEvent() has race condition, see
+ // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
+ return PulseEvent(cv->broadcast) == 0 ? -1 : 0;
}
static int pthread_cond_destroy(pthread_cond_t *cv) {
- return CloseHandle(cv->signal) && CloseHandle(cv->broadcast) ? 0 : -1;
+ return CloseHandle(cv->signal) && CloseHandle(cv->broadcast) ? 0 : -1;
}
// For Windows, change all slashes to backslashes in path names.
static void change_slashes_to_backslashes(char *path) {
- int i;
+ int i;
- for (i = 0; path[i] != '\0'; i++) {
- if (path[i] == '/')
- path[i] = '\\';
- // i > 0 check is to preserve UNC paths, like \\server\file.txt
- if (path[i] == '\\' && i > 0)
- while (path[i + 1] == '\\' || path[i + 1] == '/')
- (void) memmove(path + i + 1,
- path + i + 2, strlen(path + i + 1));
- }
+ for (i = 0; path[i] != '\0'; i++) {
+ if (path[i] == '/')
+ path[i] = '\\';
+ // i > 0 check is to preserve UNC paths, like \\server\file.txt
+ if (path[i] == '\\' && i > 0)
+ while (path[i + 1] == '\\' || path[i + 1] == '/')
+ (void) memmove(path + i + 1,
+ path + i + 2, strlen(path + i + 1));
+ }
}
// Encode 'path' which is assumed UTF-8 string, into UNICODE string.
// wbuf and wbuf_len is a target buffer and its length.
static void to_unicode(const char *path, wchar_t *wbuf, size_t wbuf_len) {
- char buf[PATH_MAX], buf2[PATH_MAX];
+ char buf[PATH_MAX], buf2[PATH_MAX];
- mg_strlcpy(buf, path, sizeof(buf));
- change_slashes_to_backslashes(buf);
+ mg_strlcpy(buf, path, sizeof(buf));
+ change_slashes_to_backslashes(buf);
- // Convert to Unicode and back. If doubly-converted string does not
- // match the original, something is fishy, reject.
- memset(wbuf, 0, wbuf_len * sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len);
- WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2),
- NULL, NULL);
- if (strcmp(buf, buf2) != 0) {
- wbuf[0] = L'\0';
- }
+ // Convert to Unicode and back. If doubly-converted string does not
+ // match the original, something is fishy, reject.
+ memset(wbuf, 0, wbuf_len * sizeof(wchar_t));
+ MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len);
+ WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2),
+ NULL, NULL);
+ if (strcmp(buf, buf2) != 0) {
+ wbuf[0] = L'\0';
+ }
}
#if defined(_WIN32_WCE)
static time_t time(time_t *ptime) {
- time_t t;
- SYSTEMTIME st;
- FILETIME ft;
+ time_t t;
+ SYSTEMTIME st;
+ FILETIME ft;
- GetSystemTime(&st);
- SystemTimeToFileTime(&st, &ft);
- t = SYS2UNIX_TIME(ft.dwLowDateTime, ft.dwHighDateTime);
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &ft);
+ t = SYS2UNIX_TIME(ft.dwLowDateTime, ft.dwHighDateTime);
- if (ptime != NULL) {
- *ptime = t;
- }
+ if (ptime != NULL) {
+ *ptime = t;
+ }
- return t;
+ return t;
}
static struct tm *localtime(const time_t *ptime, struct tm *ptm) {
- int64_t t = ((int64_t) *ptime) * RATE_DIFF + EPOCH_DIFF;
- FILETIME ft, lft;
- SYSTEMTIME st;
- TIME_ZONE_INFORMATION tzinfo;
-
- if (ptm == NULL) {
- return NULL;
- }
-
- * (int64_t *) &ft = t;
- FileTimeToLocalFileTime(&ft, &lft);
- FileTimeToSystemTime(&lft, &st);
- ptm->tm_year = st.wYear - 1900;
- ptm->tm_mon = st.wMonth - 1;
- ptm->tm_wday = st.wDayOfWeek;
- ptm->tm_mday = st.wDay;
- ptm->tm_hour = st.wHour;
- ptm->tm_min = st.wMinute;
- ptm->tm_sec = st.wSecond;
- ptm->tm_yday = 0; // hope nobody uses this
- ptm->tm_isdst =
- GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT ? 1 : 0;
-
- return ptm;
+ int64_t t = ((int64_t) *ptime) * RATE_DIFF + EPOCH_DIFF;
+ FILETIME ft, lft;
+ SYSTEMTIME st;
+ TIME_ZONE_INFORMATION tzinfo;
+
+ if (ptm == NULL) {
+ return NULL;
+ }
+
+ * (int64_t *) &ft = t;
+ FileTimeToLocalFileTime(&ft, &lft);
+ FileTimeToSystemTime(&lft, &st);
+ ptm->tm_year = st.wYear - 1900;
+ ptm->tm_mon = st.wMonth - 1;
+ ptm->tm_wday = st.wDayOfWeek;
+ ptm->tm_mday = st.wDay;
+ ptm->tm_hour = st.wHour;
+ ptm->tm_min = st.wMinute;
+ ptm->tm_sec = st.wSecond;
+ ptm->tm_yday = 0; // hope nobody uses this
+ ptm->tm_isdst =
+ GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT ? 1 : 0;
+
+ return ptm;
}
static struct tm *gmtime(const time_t *ptime, struct tm *ptm) {
- // FIXME(lsm): fix this.
- return localtime(ptime, ptm);
+ // FIXME(lsm): fix this.
+ return localtime(ptime, ptm);
}
static size_t strftime(char *dst, size_t dst_size, const char *fmt,
- const struct tm *tm) {
- (void) snprintf(dst, dst_size, "implement strftime() for WinCE");
- return 0;
+ const struct tm *tm) {
+ (void) snprintf(dst, dst_size, "implement strftime() for WinCE");
+ return 0;
}
#endif
@@ -1126,737 +1126,735 @@ static size_t strftime(char *dst, size_t dst_size, const char *fmt,
// "a.cgi", despite one would expect an error back.
// This function returns non-0 if path ends with some garbage.
static int path_cannot_disclose_cgi(const char *path) {
- static const char *allowed_last_characters = "_-";
- int last = path[strlen(path) - 1];
- return isalnum(last) || strchr(allowed_last_characters, last) != NULL;
+ static const char *allowed_last_characters = "_-";
+ int last = path[strlen(path) - 1];
+ return isalnum(last) || strchr(allowed_last_characters, last) != NULL;
}
static int mg_stat(struct mg_connection *conn, const char *path,
- struct file *filep) {
- wchar_t wbuf[PATH_MAX];
- WIN32_FILE_ATTRIBUTE_DATA info;
-
- if (!is_file_in_memory(conn, path, filep)) {
- to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
- if (GetFileAttributesExW(wbuf, GetFileExInfoStandard, &info) != 0) {
- filep->size = MAKEUQUAD(info.nFileSizeLow, info.nFileSizeHigh);
- filep->modification_time = SYS2UNIX_TIME(
- info.ftLastWriteTime.dwLowDateTime,
- info.ftLastWriteTime.dwHighDateTime);
- filep->is_directory = info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
- // If file name is fishy, reset the file structure and return error.
- // Note it is important to reset, not just return the error, cause
- // functions like is_file_opened() check the struct.
- if (!filep->is_directory && !path_cannot_disclose_cgi(path)) {
- memset(filep, 0, sizeof(*filep));
- }
- }
- }
-
- return filep->membuf != NULL || filep->modification_time != 0;
+ struct file *filep) {
+ wchar_t wbuf[PATH_MAX];
+ WIN32_FILE_ATTRIBUTE_DATA info;
+
+ if (!is_file_in_memory(conn, path, filep)) {
+ to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
+ if (GetFileAttributesExW(wbuf, GetFileExInfoStandard, &info) != 0) {
+ filep->size = MAKEUQUAD(info.nFileSizeLow, info.nFileSizeHigh);
+ filep->modification_time = SYS2UNIX_TIME(
+ info.ftLastWriteTime.dwLowDateTime,
+ info.ftLastWriteTime.dwHighDateTime);
+ filep->is_directory = info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+ // If file name is fishy, reset the file structure and return error.
+ // Note it is important to reset, not just return the error, cause
+ // functions like is_file_opened() check the struct.
+ if (!filep->is_directory && !path_cannot_disclose_cgi(path)) {
+ memset(filep, 0, sizeof(*filep));
+ }
+ }
+ }
+
+ return filep->membuf != NULL || filep->modification_time != 0;
}
static int mg_remove(const char *path) {
- wchar_t wbuf[PATH_MAX];
- to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
- return DeleteFileW(wbuf) ? 0 : -1;
+ wchar_t wbuf[PATH_MAX];
+ to_unicode(path, wbuf, ARRAY_SIZE(wbuf));
+ return DeleteFileW(wbuf) ? 0 : -1;
}
static int mg_mkdir(const char *path, int mode) {
- char buf[PATH_MAX];
- wchar_t wbuf[PATH_MAX];
+ char buf[PATH_MAX];
+ wchar_t wbuf[PATH_MAX];
- (void) mode;
- mg_strlcpy(buf, path, sizeof(buf));
- change_slashes_to_backslashes(buf);
+ (void) mode;
+ mg_strlcpy(buf, path, sizeof(buf));
+ change_slashes_to_backslashes(buf);
- (void) MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, ARRAY_SIZE(wbuf));
+ (void) MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, ARRAY_SIZE(wbuf));
- return CreateDirectoryW(wbuf, NULL) ? 0 : -1;
+ return CreateDirectoryW(wbuf, NULL) ? 0 : -1;
}
// Implementation of POSIX opendir/closedir/readdir for Windows.
static DIR * opendir(const char *name) {
- DIR *dir = NULL;
- wchar_t wpath[PATH_MAX];
- DWORD attrs;
-
- if (name == NULL) {
- SetLastError(ERROR_BAD_ARGUMENTS);
- } else if ((dir = (DIR *) malloc(sizeof(*dir))) == NULL) {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- } else {
- to_unicode(name, wpath, ARRAY_SIZE(wpath));
- attrs = GetFileAttributesW(wpath);
- if (attrs != 0xFFFFFFFF &&
- ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) {
- (void) wcscat(wpath, L"\\*");
- dir->handle = FindFirstFileW(wpath, &dir->info);
- dir->result.d_name[0] = '\0';
- } else {
- free(dir);
- dir = NULL;
- }
- }
-
- return dir;
+ DIR *dir = NULL;
+ wchar_t wpath[PATH_MAX];
+ DWORD attrs;
+
+ if (name == NULL) {
+ SetLastError(ERROR_BAD_ARGUMENTS);
+ } else if ((dir = (DIR *) malloc(sizeof(*dir))) == NULL) {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ } else {
+ to_unicode(name, wpath, ARRAY_SIZE(wpath));
+ attrs = GetFileAttributesW(wpath);
+ if (attrs != 0xFFFFFFFF &&
+ ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) {
+ (void) wcscat(wpath, L"\\*");
+ dir->handle = FindFirstFileW(wpath, &dir->info);
+ dir->result.d_name[0] = '\0';
+ } else {
+ free(dir);
+ dir = NULL;
+ }
+ }
+
+ return dir;
}
static int closedir(DIR *dir) {
- int result = 0;
+ int result = 0;
- if (dir != NULL) {
- if (dir->handle != INVALID_HANDLE_VALUE)
- result = FindClose(dir->handle) ? 0 : -1;
+ if (dir != NULL) {
+ if (dir->handle != INVALID_HANDLE_VALUE)
+ result = FindClose(dir->handle) ? 0 : -1;
- free(dir);
- } else {
- result = -1;
- SetLastError(ERROR_BAD_ARGUMENTS);
- }
+ free(dir);
+ } else {
+ result = -1;
+ SetLastError(ERROR_BAD_ARGUMENTS);
+ }
- return result;
+ return result;
}
static struct dirent *readdir(DIR *dir) {
- struct dirent *result = 0;
+ struct dirent *result = 0;
- if (dir) {
- if (dir->handle != INVALID_HANDLE_VALUE) {
- result = &dir->result;
- (void) WideCharToMultiByte(CP_UTF8, 0,
- dir->info.cFileName, -1, result->d_name,
- sizeof(result->d_name), NULL, NULL);
+ if (dir) {
+ if (dir->handle != INVALID_HANDLE_VALUE) {
+ result = &dir->result;
+ (void) WideCharToMultiByte(CP_UTF8, 0,
+ dir->info.cFileName, -1, result->d_name,
+ sizeof(result->d_name), NULL, NULL);
- if (!FindNextFileW(dir->handle, &dir->info)) {
- (void) FindClose(dir->handle);
- dir->handle = INVALID_HANDLE_VALUE;
- }
+ if (!FindNextFileW(dir->handle, &dir->info)) {
+ (void) FindClose(dir->handle);
+ dir->handle = INVALID_HANDLE_VALUE;
+ }
- } else {
- SetLastError(ERROR_FILE_NOT_FOUND);
- }
- } else {
- SetLastError(ERROR_BAD_ARGUMENTS);
- }
+ } else {
+ SetLastError(ERROR_FILE_NOT_FOUND);
+ }
+ } else {
+ SetLastError(ERROR_BAD_ARGUMENTS);
+ }
- return result;
+ return result;
}
#ifndef HAVE_POLL
static int poll(struct pollfd *pfd, int n, int milliseconds) {
- struct timeval tv;
- fd_set set;
- int i, result, maxfd = 0;
+ struct timeval tv;
+ fd_set set;
+ int i, result, maxfd = 0;
- tv.tv_sec = milliseconds / 1000;
- tv.tv_usec = (milliseconds % 1000) * 1000;
- FD_ZERO(&set);
+ tv.tv_sec = milliseconds / 1000;
+ tv.tv_usec = (milliseconds % 1000) * 1000;
+ FD_ZERO(&set);
- for (i = 0; i < n; i++) {
- FD_SET((SOCKET) pfd[i].fd, &set);
- pfd[i].revents = 0;
+ for (i = 0; i < n; i++) {
+ FD_SET((SOCKET) pfd[i].fd, &set);
+ pfd[i].revents = 0;
- if (pfd[i].fd > maxfd) {
- maxfd = pfd[i].fd;
- }
- }
+ if (pfd[i].fd > maxfd) {
+ maxfd = pfd[i].fd;
+ }
+ }
- if ((result = select(maxfd + 1, &set, NULL, NULL, &tv)) > 0) {
- for (i = 0; i < n; i++) {
- if (FD_ISSET(pfd[i].fd, &set)) {
- pfd[i].revents = POLLIN;
- }
- }
- }
+ if ((result = select(maxfd + 1, &set, NULL, NULL, &tv)) > 0) {
+ for (i = 0; i < n; i++) {
+ if (FD_ISSET(pfd[i].fd, &set)) {
+ pfd[i].revents = POLLIN;
+ }
+ }
+ }
- return result;
+ return result;
}
#endif // HAVE_POLL
#define set_close_on_exec(x) // No FD_CLOEXEC on Windows
int mg_start_thread(mg_thread_func_t f, void *p) {
- return (long)_beginthread((void (__cdecl *)(void *)) f, 0, p) == -1L ? -1 : 0;
+ return (long)_beginthread((void (__cdecl *)(void *)) f, 0, p) == -1L ? -1 : 0;
}
#if !defined(NO_SSL)
static HANDLE dlopen(const char *dll_name, int flags) {
- wchar_t wbuf[PATH_MAX];
- (void) flags;
- to_unicode(dll_name, wbuf, ARRAY_SIZE(wbuf));
- return LoadLibraryW(wbuf);
+ wchar_t wbuf[PATH_MAX];
+ (void) flags;
+ to_unicode(dll_name, wbuf, ARRAY_SIZE(wbuf));
+ return LoadLibraryW(wbuf);
}
#endif
#if !defined(NO_CGI)
#define SIGKILL 0
static int kill(pid_t pid, int sig_num) {
- (void) TerminateProcess(pid, sig_num);
- (void) CloseHandle(pid);
- return 0;
+ (void) TerminateProcess(pid, sig_num);
+ (void) CloseHandle(pid);
+ return 0;
}
static void trim_trailing_whitespaces(char *s) {
- char *e = s + strlen(s) - 1;
- while (e > s && isspace(* (unsigned char *) e)) {
- *e-- = '\0';
- }
+ char *e = s + strlen(s) - 1;
+ while (e > s && isspace(* (unsigned char *) e)) {
+ *e-- = '\0';
+ }
}
static pid_t spawn_process(struct mg_connection *conn, const char *prog,
- char *envblk, char *envp[], int fd_stdin,
- int fd_stdout, const char *dir) {
- HANDLE me;
- char *p, *interp, full_interp[PATH_MAX], full_dir[PATH_MAX],
- cmdline[PATH_MAX], buf[PATH_MAX];
- struct file file = STRUCT_FILE_INITIALIZER;
- STARTUPINFOA si;
- PROCESS_INFORMATION pi = { 0 };
-
- (void) envp;
-
- memset(&si, 0, sizeof(si));
- si.cb = sizeof(si);
-
- // TODO(lsm): redirect CGI errors to the error log file
- si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
- si.wShowWindow = SW_HIDE;
-
- me = GetCurrentProcess();
- DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdin), me,
- &si.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
- DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdout), me,
- &si.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
-
- // If CGI file is a script, try to read the interpreter line
- interp = conn->ctx->config[CGI_INTERPRETER];
- if (interp == NULL) {
- buf[0] = buf[1] = '\0';
-
- // Read the first line of the script into the buffer
- snprintf(cmdline, sizeof(cmdline), "%s%c%s", dir, '/', prog);
- if (mg_fopen(conn, cmdline, "r", &file)) {
- p = (char *) file.membuf;
- mg_fgets(buf, sizeof(buf), &file, &p);
- mg_fclose(&file);
- buf[sizeof(buf) - 1] = '\0';
- }
-
- if (buf[0] == '#' && buf[1] == '!') {
- trim_trailing_whitespaces(buf + 2);
- } else {
- buf[2] = '\0';
- }
- interp = buf + 2;
- }
-
- if (interp[0] != '\0') {
- GetFullPathNameA(interp, sizeof(full_interp), full_interp, NULL);
- interp = full_interp;
- }
- GetFullPathNameA(dir, sizeof(full_dir), full_dir, NULL);
-
- mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%s%s\\%s",
- interp, interp[0] == '\0' ? "" : " ", full_dir, prog);
-
- DEBUG_TRACE(("Running [%s]", cmdline));
- if (CreateProcessA(NULL, cmdline, NULL, NULL, TRUE,
- CREATE_NEW_PROCESS_GROUP, envblk, NULL, &si, &pi) == 0) {
- cry(conn, "%s: CreateProcess(%s): %ld",
- __func__, cmdline, ERRNO);
- pi.hProcess = (pid_t) -1;
- }
-
- // Always close these to prevent handle leakage.
- (void) close(fd_stdin);
- (void) close(fd_stdout);
-
- (void) CloseHandle(si.hStdOutput);
- (void) CloseHandle(si.hStdInput);
- (void) CloseHandle(pi.hThread);
-
- return (pid_t) pi.hProcess;
+ char *envblk, char *envp[], int fd_stdin,
+ int fd_stdout, const char *dir) {
+ HANDLE me;
+ char *p, *interp, full_interp[PATH_MAX], full_dir[PATH_MAX],
+ cmdline[PATH_MAX], buf[PATH_MAX];
+ struct file file = STRUCT_FILE_INITIALIZER;
+ STARTUPINFOA si;
+ PROCESS_INFORMATION pi = { 0 };
+
+ (void) envp;
+
+ memset(&si, 0, sizeof(si));
+ si.cb = sizeof(si);
+
+ // TODO(lsm): redirect CGI errors to the error log file
+ si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+ si.wShowWindow = SW_HIDE;
+
+ me = GetCurrentProcess();
+ DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdin), me,
+ &si.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+ DuplicateHandle(me, (HANDLE) _get_osfhandle(fd_stdout), me,
+ &si.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
+
+ // If CGI file is a script, try to read the interpreter line
+ interp = conn->ctx->config[CGI_INTERPRETER];
+ if (interp == NULL) {
+ buf[0] = buf[1] = '\0';
+
+ // Read the first line of the script into the buffer
+ snprintf(cmdline, sizeof(cmdline), "%s%c%s", dir, '/', prog);
+ if (mg_fopen(conn, cmdline, "r", &file)) {
+ p = (char *) file.membuf;
+ mg_fgets(buf, sizeof(buf), &file, &p);
+ mg_fclose(&file);
+ buf[sizeof(buf) - 1] = '\0';
+ }
+
+ if (buf[0] == '#' && buf[1] == '!') {
+ trim_trailing_whitespaces(buf + 2);
+ } else {
+ buf[2] = '\0';
+ }
+ interp = buf + 2;
+ }
+
+ if (interp[0] != '\0') {
+ GetFullPathNameA(interp, sizeof(full_interp), full_interp, NULL);
+ interp = full_interp;
+ }
+ GetFullPathNameA(dir, sizeof(full_dir), full_dir, NULL);
+
+ mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%s%s\\%s",
+ interp, interp[0] == '\0' ? "" : " ", full_dir, prog);
+
+ DEBUG_TRACE(("Running [%s]", cmdline));
+ if (CreateProcessA(NULL, cmdline, NULL, NULL, TRUE,
+ CREATE_NEW_PROCESS_GROUP, envblk, NULL, &si, &pi) == 0) {
+ cry(conn, "%s: CreateProcess(%s): %ld",
+ __func__, cmdline, ERRNO);
+ pi.hProcess = (pid_t) -1;
+ }
+
+ // Always close these to prevent handle leakage.
+ (void) close(fd_stdin);
+ (void) close(fd_stdout);
+
+ (void) CloseHandle(si.hStdOutput);
+ (void) CloseHandle(si.hStdInput);
+ (void) CloseHandle(pi.hThread);
+
+ return (pid_t) pi.hProcess;
}
#endif // !NO_CGI
static int set_non_blocking_mode(SOCKET sock) {
- unsigned long on = 1;
- return ioctlsocket(sock, FIONBIO, &on);
+ unsigned long on = 1;
+ return ioctlsocket(sock, FIONBIO, &on);
}
#else
static int mg_stat(struct mg_connection *conn, const char *path,
- struct file *filep) {
- struct stat st;
+ struct file *filep) {
+ struct stat st;
- if (!is_file_in_memory(conn, path, filep) && !stat(path, &st)) {
- filep->size = st.st_size;
- filep->modification_time = st.st_mtime;
- filep->is_directory = S_ISDIR(st.st_mode);
- } else {
- filep->modification_time = (time_t) 0;
- }
+ if (!is_file_in_memory(conn, path, filep) && !stat(path, &st)) {
+ filep->size = st.st_size;
+ filep->modification_time = st.st_mtime;
+ filep->is_directory = S_ISDIR(st.st_mode);
+ } else {
+ filep->modification_time = (time_t) 0;
+ }
- return filep->membuf != NULL || filep->modification_time != (time_t) 0;
+ return filep->membuf != NULL || filep->modification_time != (time_t) 0;
}
static void set_close_on_exec(int fd) {
- fcntl(fd, F_SETFD, FD_CLOEXEC);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
}
int mg_start_thread(mg_thread_func_t func, void *param) {
- pthread_t thread_id;
- pthread_attr_t attr;
- int result;
+ pthread_t thread_id;
+ pthread_attr_t attr;
+ int result;
- (void) pthread_attr_init(&attr);
- (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- // TODO(lsm): figure out why mongoose dies on Linux if next line is enabled
- // (void) pthread_attr_setstacksize(&attr, sizeof(struct mg_connection) * 5);
+ (void) pthread_attr_init(&attr);
+ (void) pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ // TODO(lsm): figure out why mongoose dies on Linux if next line is enabled
+ // (void) pthread_attr_setstacksize(&attr, sizeof(struct mg_connection) * 5);
- result = pthread_create(&thread_id, &attr, func, param);
- pthread_attr_destroy(&attr);
+ result = pthread_create(&thread_id, &attr, func, param);
+ pthread_attr_destroy(&attr);
- return result;
+ return result;
}
#ifndef NO_CGI
static pid_t spawn_process(struct mg_connection *conn, const char *prog,
- char *envblk, char *envp[], int fd_stdin,
- int fd_stdout, const char *dir) {
- pid_t pid;
- const char *interp;
-
- (void) envblk;
-
- if ((pid = fork()) == -1) {
- // Parent
- send_http_error(conn, 500, http_500_error, "fork(): %s", strerror(ERRNO));
- } else if (pid == 0) {
- // Child
- if (chdir(dir) != 0) {
- cry(conn, "%s: chdir(%s): %s", __func__, dir, strerror(ERRNO));
- } else if (dup2(fd_stdin, 0) == -1) {
- cry(conn, "%s: dup2(%d, 0): %s", __func__, fd_stdin, strerror(ERRNO));
- } else if (dup2(fd_stdout, 1) == -1) {
- cry(conn, "%s: dup2(%d, 1): %s", __func__, fd_stdout, strerror(ERRNO));
- } else {
- // Not redirecting stderr to stdout, to avoid output being littered
- // with the error messages.
- (void) close(fd_stdin);
- (void) close(fd_stdout);
-
- // After exec, all signal handlers are restored to their default values,
- // with one exception of SIGCHLD. According to POSIX.1-2001 and Linux's
- // implementation, SIGCHLD's handler will leave unchanged after exec
- // if it was set to be ignored. Restore it to default action.
- signal(SIGCHLD, SIG_DFL);
-
- interp = conn->ctx->config[CGI_INTERPRETER];
- if (interp == NULL) {
- (void) execle(prog, prog, NULL, envp);
- cry(conn, "%s: execle(%s): %s", __func__, prog, strerror(ERRNO));
- } else {
- (void) execle(interp, interp, prog, NULL, envp);
- cry(conn, "%s: execle(%s %s): %s", __func__, interp, prog,
- strerror(ERRNO));
- }
- }
- exit(EXIT_FAILURE);
- }
-
- // Parent. Close stdio descriptors
- (void) close(fd_stdin);
- (void) close(fd_stdout);
-
- return pid;
+ char *envblk, char *envp[], int fd_stdin,
+ int fd_stdout, const char *dir) {
+ pid_t pid;
+ const char *interp;
+
+ (void) envblk;
+
+ if ((pid = fork()) == -1) {
+ // Parent
+ send_http_error(conn, 500, http_500_error, "fork(): %s", strerror(ERRNO));
+ } else if (pid == 0) {
+ // Child
+ if (chdir(dir) != 0) {
+ cry(conn, "%s: chdir(%s): %s", __func__, dir, strerror(ERRNO));
+ } else if (dup2(fd_stdin, 0) == -1) {
+ cry(conn, "%s: dup2(%d, 0): %s", __func__, fd_stdin, strerror(ERRNO));
+ } else if (dup2(fd_stdout, 1) == -1) {
+ cry(conn, "%s: dup2(%d, 1): %s", __func__, fd_stdout, strerror(ERRNO));
+ } else {
+ // Not redirecting stderr to stdout, to avoid output being littered
+ // with the error messages.
+ (void) close(fd_stdin);
+ (void) close(fd_stdout);
+
+ // After exec, all signal handlers are restored to their default values,
+ // with one exception of SIGCHLD. According to POSIX.1-2001 and Linux's
+ // implementation, SIGCHLD's handler will leave unchanged after exec
+ // if it was set to be ignored. Restore it to default action.
+ signal(SIGCHLD, SIG_DFL);
+
+ interp = conn->ctx->config[CGI_INTERPRETER];
+ if (interp == NULL) {
+ (void) execle(prog, prog, NULL, envp);
+ cry(conn, "%s: execle(%s): %s", __func__, prog, strerror(ERRNO));
+ } else {
+ (void) execle(interp, interp, prog, NULL, envp);
+ cry(conn, "%s: execle(%s %s): %s", __func__, interp, prog,
+ strerror(ERRNO));
+ }
+ }
+ exit(EXIT_FAILURE);
+ }
+
+ // Parent. Close stdio descriptors
+ (void) close(fd_stdin);
+ (void) close(fd_stdout);
+
+ return pid;
}
#endif // !NO_CGI
static int set_non_blocking_mode(SOCKET sock) {
- int flags;
+ int flags;
- flags = fcntl(sock, F_GETFL, 0);
- (void) fcntl(sock, F_SETFL, flags | O_NONBLOCK);
+ flags = fcntl(sock, F_GETFL, 0);
+ (void) fcntl(sock, F_SETFL, flags | O_NONBLOCK);
- return 0;
+ return 0;
}
#endif // _WIN32
// Write data to the IO channel - opened file descriptor, socket or SSL
// descriptor. Return number of bytes written.
static int64_t push(FILE *fp, SOCKET sock, SSL *ssl, const char *buf,
- int64_t len) {
- int64_t sent;
- int n, k;
+ int64_t len) {
+ int64_t sent;
+ int n, k;
- (void) ssl; // Get rid of warning
- sent = 0;
- while (sent < len) {
-
- // How many bytes we send in this iteration
- k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent);
+ (void) ssl; // Get rid of warning
+ sent = 0;
+ while (sent < len) {
+ // How many bytes we send in this iteration
+ k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent);
#ifndef NO_SSL
- if (ssl != NULL) {
- n = SSL_write(ssl, buf + sent, k);
- } else
+ if (ssl != NULL) {
+ n = SSL_write(ssl, buf + sent, k);
+ } else
#endif
- if (fp != NULL) {
- n = (int) fwrite(buf + sent, 1, (size_t) k, fp);
- if (ferror(fp))
- n = -1;
- } else {
- n = send(sock, buf + sent, (size_t) k, MSG_NOSIGNAL);
- }
+ if (fp != NULL) {
+ n = (int) fwrite(buf + sent, 1, (size_t) k, fp);
+ if (ferror(fp))
+ n = -1;
+ } else {
+ n = send(sock, buf + sent, (size_t) k, MSG_NOSIGNAL);
+ }
- if (n <= 0)
- break;
+ if (n <= 0)
+ break;
- sent += n;
- }
+ sent += n;
+ }
- return sent;
+ return sent;
}
// Read from IO channel - opened file descriptor, socket, or SSL descriptor.
// Return negative value on error, or number of bytes read on success.
static int pull(FILE *fp, struct mg_connection *conn, char *buf, int len) {
- int nread;
+ int nread;
- if (fp != NULL) {
- // Use read() instead of fread(), because if we're reading from the CGI
- // pipe, fread() may block until IO buffer is filled up. We cannot afford
- // to block and must pass all read bytes immediately to the client.
- nread = read(fileno(fp), buf, (size_t) len);
+ if (fp != NULL) {
+ // Use read() instead of fread(), because if we're reading from the CGI
+ // pipe, fread() may block until IO buffer is filled up. We cannot afford
+ // to block and must pass all read bytes immediately to the client.
+ nread = read(fileno(fp), buf, (size_t) len);
#ifndef NO_SSL
- } else if (conn->ssl != NULL) {
- nread = SSL_read(conn->ssl, buf, len);
+ } else if (conn->ssl != NULL) {
+ nread = SSL_read(conn->ssl, buf, len);
#endif
- } else {
- nread = recv(conn->client.sock, buf, (size_t) len, 0);
- }
+ } else {
+ nread = recv(conn->client.sock, buf, (size_t) len, 0);
+ }
- return conn->ctx->stop_flag ? -1 : nread;
+ return conn->ctx->stop_flag ? -1 : nread;
}
static int pull_all(FILE *fp, struct mg_connection *conn, char *buf, int len) {
- int n, nread = 0;
+ int n, nread = 0;
- while (len > 0) {
- n = pull(fp, conn, buf + nread, len);
- if (n < 0) {
- nread = n; // Propagate the error
- break;
- } else if (n == 0) {
- break; // No more data to read
- } else {
- conn->consumed_content += n;
- nread += n;
- len -= n;
- }
- }
+ while (len > 0) {
+ n = pull(fp, conn, buf + nread, len);
+ if (n < 0) {
+ nread = n; // Propagate the error
+ break;
+ } else if (n == 0) {
+ break; // No more data to read
+ } else {
+ conn->consumed_content += n;
+ nread += n;
+ len -= n;
+ }
+ }
- return nread;
+ return nread;
}
int mg_read(struct mg_connection *conn, void *buf, size_t len) {
- int n, buffered_len, nread;
- const char *body;
-
- // If Content-Length is not set, read until socket is closed
- if (conn->consumed_content == 0 && conn->content_len == 0) {
- conn->content_len = INT64_MAX;
- conn->must_close = 1;
- }
-
- nread = 0;
- if (conn->consumed_content < conn->content_len) {
- // Adjust number of bytes to read.
- int64_t to_read = conn->content_len - conn->consumed_content;
- if (to_read < (int64_t) len) {
- len = (size_t) to_read;
- }
-
- // Return buffered data
- body = conn->buf + conn->request_len + conn->consumed_content;
- buffered_len = &conn->buf[conn->data_len] - body;
- if (buffered_len > 0) {
- if (len < (size_t) buffered_len) {
- buffered_len = (int) len;
- }
- memcpy(buf, body, (size_t) buffered_len);
- len -= buffered_len;
- conn->consumed_content += buffered_len;
- nread += buffered_len;
- buf = (char *) buf + buffered_len;
- }
-
- // We have returned all buffered data. Read new data from the remote socket.
- n = pull_all(NULL, conn, (char *) buf, (int) len);
- nread = n >= 0 ? nread + n : n;
- }
- return nread;
+ int n, buffered_len, nread;
+ const char *body;
+
+ // If Content-Length is not set, read until socket is closed
+ if (conn->consumed_content == 0 && conn->content_len == 0) {
+ conn->content_len = INT64_MAX;
+ conn->must_close = 1;
+ }
+
+ nread = 0;
+ if (conn->consumed_content < conn->content_len) {
+ // Adjust number of bytes to read.
+ int64_t to_read = conn->content_len - conn->consumed_content;
+ if (to_read < (int64_t) len) {
+ len = (size_t) to_read;
+ }
+
+ // Return buffered data
+ body = conn->buf + conn->request_len + conn->consumed_content;
+ buffered_len = &conn->buf[conn->data_len] - body;
+ if (buffered_len > 0) {
+ if (len < (size_t) buffered_len) {
+ buffered_len = (int) len;
+ }
+ memcpy(buf, body, (size_t) buffered_len);
+ len -= buffered_len;
+ conn->consumed_content += buffered_len;
+ nread += buffered_len;
+ buf = (char *) buf + buffered_len;
+ }
+
+ // We have returned all buffered data. Read new data from the remote socket.
+ n = pull_all(NULL, conn, (char *) buf, (int) len);
+ nread = n >= 0 ? nread + n : n;
+ }
+ return nread;
}
int mg_write(struct mg_connection *conn, const void *buf, size_t len) {
- time_t now;
- int64_t n, total, allowed;
-
- if (conn->throttle > 0) {
- if ((now = time(NULL)) != conn->last_throttle_time) {
- conn->last_throttle_time = now;
- conn->last_throttle_bytes = 0;
- }
- allowed = conn->throttle - conn->last_throttle_bytes;
- if (allowed > (int64_t) len) {
- allowed = len;
- }
- if ((total = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
- (int64_t) allowed)) == allowed) {
- buf = (char *) buf + total;
- conn->last_throttle_bytes += total;
- while (total < (int64_t) len && conn->ctx->stop_flag == 0) {
- allowed = conn->throttle > (int64_t) len - total ?
- (int64_t) len - total : conn->throttle;
- if ((n = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
- (int64_t) allowed)) != allowed) {
- break;
- }
- sleep(1);
- conn->last_throttle_bytes = allowed;
- conn->last_throttle_time = time(NULL);
- buf = (char *) buf + n;
- total += n;
- }
- }
- } else {
- total = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
- (int64_t) len);
- }
- return (int) total;
+ time_t now;
+ int64_t n, total, allowed;
+
+ if (conn->throttle > 0) {
+ if ((now = time(NULL)) != conn->last_throttle_time) {
+ conn->last_throttle_time = now;
+ conn->last_throttle_bytes = 0;
+ }
+ allowed = conn->throttle - conn->last_throttle_bytes;
+ if (allowed > (int64_t) len) {
+ allowed = len;
+ }
+ if ((total = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
+ (int64_t) allowed)) == allowed) {
+ buf = (char *) buf + total;
+ conn->last_throttle_bytes += total;
+ while (total < (int64_t) len && conn->ctx->stop_flag == 0) {
+ allowed = conn->throttle > (int64_t) len - total ?
+ (int64_t) len - total : conn->throttle;
+ if ((n = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
+ (int64_t) allowed)) != allowed) {
+ break;
+ }
+ sleep(1);
+ conn->last_throttle_bytes = allowed;
+ conn->last_throttle_time = time(NULL);
+ buf = (char *) buf + n;
+ total += n;
+ }
+ }
+ } else {
+ total = push(NULL, conn->client.sock, conn->ssl, (const char *) buf,
+ (int64_t) len);
+ }
+ return (int) total;
}
// Print message to buffer. If buffer is large enough to hold the message,
// return buffer. If buffer is to small, allocate large enough buffer on heap,
// and return allocated buffer.
static int alloc_vprintf(char **buf, size_t size, const char *fmt, va_list ap) {
- va_list ap_copy;
- int len;
+ va_list ap_copy;
+ int len;
- // Windows is not standard-compliant, and vsnprintf() returns -1 if
- // buffer is too small. Also, older versions of msvcrt.dll do not have
- // _vscprintf(). However, if size is 0, vsnprintf() behaves correctly.
- // Therefore, we make two passes: on first pass, get required message length.
- // On second pass, actually print the message.
- va_copy(ap_copy, ap);
- len = vsnprintf(NULL, 0, fmt, ap_copy);
+ // Windows is not standard-compliant, and vsnprintf() returns -1 if
+ // buffer is too small. Also, older versions of msvcrt.dll do not have
+ // _vscprintf(). However, if size is 0, vsnprintf() behaves correctly.
+ // Therefore, we make two passes: on first pass, get required message length.
+ // On second pass, actually print the message.
+ va_copy(ap_copy, ap);
+ len = vsnprintf(NULL, 0, fmt, ap_copy);
- if (len > (int) size &&
- (size = len + 1) > 0 &&
- (*buf = (char *) malloc(size)) == NULL) {
- len = -1; // Allocation failed, mark failure
- } else {
- va_copy(ap_copy, ap);
- vsnprintf(*buf, size, fmt, ap_copy);
- }
+ if (len > (int) size &&
+ (size = len + 1) > 0 &&
+ (*buf = (char *) malloc(size)) == NULL) {
+ len = -1; // Allocation failed, mark failure
+ } else {
+ va_copy(ap_copy, ap);
+ vsnprintf(*buf, size, fmt, ap_copy);
+ }
- return len;
+ return len;
}
int mg_vprintf(struct mg_connection *conn, const char *fmt, va_list ap) {
- char mem[MG_BUF_LEN], *buf = mem;
- int len;
+ char mem[MG_BUF_LEN], *buf = mem;
+ int len;
- if ((len = alloc_vprintf(&buf, sizeof(mem), fmt, ap)) > 0) {
- len = mg_write(conn, buf, (size_t) len);
- }
- if (buf != mem && buf != NULL) {
- free(buf);
- }
+ if ((len = alloc_vprintf(&buf, sizeof(mem), fmt, ap)) > 0) {
+ len = mg_write(conn, buf, (size_t) len);
+ }
+ if (buf != mem && buf != NULL) {
+ free(buf);
+ }
- return len;
+ return len;
}
int mg_printf(struct mg_connection *conn, const char *fmt, ...) {
- va_list ap;
- va_start(ap, fmt);
- return mg_vprintf(conn, fmt, ap);
+ va_list ap;
+ va_start(ap, fmt);
+ return mg_vprintf(conn, fmt, ap);
}
int mg_url_decode(const char *src, int src_len, char *dst,
- int dst_len, int is_form_url_encoded) {
- int i, j, a, b;
+ int dst_len, int is_form_url_encoded) {
+ int i, j, a, b;
#define HEXTOI(x) (isdigit(x) ? x - '0' : x - 'W')
- for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
- if (src[i] == '%' && i < src_len - 2 &&
- isxdigit(* (const unsigned char *) (src + i + 1)) &&
- isxdigit(* (const unsigned char *) (src + i + 2))) {
- a = tolower(* (const unsigned char *) (src + i + 1));
- b = tolower(* (const unsigned char *) (src + i + 2));
- dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
- i += 2;
- } else if (is_form_url_encoded && src[i] == '+') {
- dst[j] = ' ';
- } else {
- dst[j] = src[i];
- }
- }
+ for (i = j = 0; i < src_len && j < dst_len - 1; i++, j++) {
+ if (src[i] == '%' && i < src_len - 2 &&
+ isxdigit(* (const unsigned char *) (src + i + 1)) &&
+ isxdigit(* (const unsigned char *) (src + i + 2))) {
+ a = tolower(* (const unsigned char *) (src + i + 1));
+ b = tolower(* (const unsigned char *) (src + i + 2));
+ dst[j] = (char) ((HEXTOI(a) << 4) | HEXTOI(b));
+ i += 2;
+ } else if (is_form_url_encoded && src[i] == '+') {
+ dst[j] = ' ';
+ } else {
+ dst[j] = src[i];
+ }
+ }
- dst[j] = '\0'; // Null-terminate the destination
+ dst[j] = '\0'; // Null-terminate the destination
- return i >= src_len ? j : -1;
+ return i >= src_len ? j : -1;
}
int mg_get_var(const char *data, size_t data_len, const char *name,
- char *dst, size_t dst_len) {
- const char *p, *e, *s;
- size_t name_len;
- int len;
-
- if (dst == NULL || dst_len == 0) {
- len = -2;
- } else if (data == NULL || name == NULL || data_len == 0) {
- len = -1;
- dst[0] = '\0';
- } else {
- name_len = strlen(name);
- e = data + data_len;
- len = -1;
- dst[0] = '\0';
-
- // data is "var1=val1&var2=val2...". Find variable first
- for (p = data; p + name_len < e; p++) {
- if ((p == data || p[-1] == '&') && p[name_len] == '=' &&
- !mg_strncasecmp(name, p, name_len)) {
-
- // Point p to variable value
- p += name_len + 1;
-
- // Point s to the end of the value
- s = (const char *) memchr(p, '&', (size_t)(e - p));
- if (s == NULL) {
- s = e;
- }
- assert(s >= p);
-
- // Decode variable into destination buffer
- len = mg_url_decode(p, (size_t)(s - p), dst, dst_len, 1);
-
- // Redirect error code from -1 to -2 (destination buffer too small).
- if (len == -1) {
- len = -2;
- }
- break;
- }
- }
- }
-
- return len;
+ char *dst, size_t dst_len) {
+ const char *p, *e, *s;
+ size_t name_len;
+ int len;
+
+ if (dst == NULL || dst_len == 0) {
+ len = -2;
+ } else if (data == NULL || name == NULL || data_len == 0) {
+ len = -1;
+ dst[0] = '\0';
+ } else {
+ name_len = strlen(name);
+ e = data + data_len;
+ len = -1;
+ dst[0] = '\0';
+
+ // data is "var1=val1&var2=val2...". Find variable first
+ for (p = data; p + name_len < e; p++) {
+ if ((p == data || p[-1] == '&') && p[name_len] == '=' &&
+ !mg_strncasecmp(name, p, name_len)) {
+ // Point p to variable value
+ p += name_len + 1;
+
+ // Point s to the end of the value
+ s = (const char *) memchr(p, '&', (size_t)(e - p));
+ if (s == NULL) {
+ s = e;
+ }
+ assert(s >= p);
+
+ // Decode variable into destination buffer
+ len = mg_url_decode(p, (size_t)(s - p), dst, dst_len, 1);
+
+ // Redirect error code from -1 to -2 (destination buffer too small).
+ if (len == -1) {
+ len = -2;
+ }
+ break;
+ }
+ }
+ }
+
+ return len;
}
int mg_get_cookie(const char *cookie_header, const char *var_name,
- char *dst, size_t dst_size) {
- const char *s, *p, *end;
- int name_len, len = -1;
-
- if (dst == NULL || dst_size == 0) {
- len = -2;
- } else if (var_name == NULL || (s = cookie_header) == NULL) {
- len = -1;
- dst[0] = '\0';
- } else {
- name_len = (int) strlen(var_name);
- end = s + strlen(s);
- dst[0] = '\0';
-
- for (; (s = mg_strcasestr(s, var_name)) != NULL; s += name_len) {
- if (s[name_len] == '=') {
- s += name_len + 1;
- if ((p = strchr(s, ' ')) == NULL)
- p = end;
- if (p[-1] == ';')
- p--;
- if (*s == '"' && p[-1] == '"' && p > s + 1) {
- s++;
- p--;
- }
- if ((size_t) (p - s) < dst_size) {
- len = p - s;
- mg_strlcpy(dst, s, (size_t) len + 1);
- } else {
- len = -3;
- }
- break;
- }
- }
- }
- return len;
+ char *dst, size_t dst_size) {
+ const char *s, *p, *end;
+ int name_len, len = -1;
+
+ if (dst == NULL || dst_size == 0) {
+ len = -2;
+ } else if (var_name == NULL || (s = cookie_header) == NULL) {
+ len = -1;
+ dst[0] = '\0';
+ } else {
+ name_len = (int) strlen(var_name);
+ end = s + strlen(s);
+ dst[0] = '\0';
+
+ for (; (s = mg_strcasestr(s, var_name)) != NULL; s += name_len) {
+ if (s[name_len] == '=') {
+ s += name_len + 1;
+ if ((p = strchr(s, ' ')) == NULL)
+ p = end;
+ if (p[-1] == ';')
+ p--;
+ if (*s == '"' && p[-1] == '"' && p > s + 1) {
+ s++;
+ p--;
+ }
+ if ((size_t) (p - s) < dst_size) {
+ len = p - s;
+ mg_strlcpy(dst, s, (size_t) len + 1);
+ } else {
+ len = -3;
+ }
+ break;
+ }
+ }
+ }
+ return len;
}
static void convert_uri_to_file_name(struct mg_connection *conn, char *buf,
- size_t buf_len, struct file *filep) {
- struct vec a, b;
- const char *rewrite, *uri = conn->request_info.uri;
- char *p;
- int match_len;
- char gz_path[PATH_MAX];
- char const* accept_encoding;
-
- // Using buf_len - 1 because memmove() for PATH_INFO may shift part
- // of the path one byte on the right.
- mg_snprintf(conn, buf, buf_len - 1, "%s%s", conn->ctx->config[DOCUMENT_ROOT],
- uri);
-
- rewrite = conn->ctx->config[REWRITE];
- while ((rewrite = next_option(rewrite, &a, &b)) != NULL) {
- if ((match_len = match_prefix(a.ptr, a.len, uri)) > 0) {
- mg_snprintf(conn, buf, buf_len - 1, "%.*s%s", (int) b.len, b.ptr,
- uri + match_len);
- break;
- }
- }
-
- if (mg_stat(conn, buf, filep)) return;
-
- // if we can't find the actual file, look for the file
- // with the same name but a .gz extension. If we find it,
- // use that and set the gzipped flag in the file struct
- // to indicate that the response need to have the content-
- // encoding: gzip header
- // we can only do this if the browser declares support
- if ((accept_encoding = mg_get_header(conn, "Accept-Encoding")) != NULL) {
- if (strstr(accept_encoding,"gzip") != NULL) {
- snprintf(gz_path, sizeof(gz_path), "%s.gz", buf);
- if (mg_stat(conn, gz_path, filep)) {
- filep->gzipped = 1;
- return;
- }
- }
- }
-
- // Support PATH_INFO for CGI scripts.
- for (p = buf + strlen(buf); p > buf + 1; p--) {
- if (*p == '/') {
- *p = '\0';
- if (match_prefix(conn->ctx->config[CGI_EXTENSIONS],
- strlen(conn->ctx->config[CGI_EXTENSIONS]), buf) > 0 &&
- mg_stat(conn, buf, filep)) {
- // Shift PATH_INFO block one character right, e.g.
- // "/x.cgi/foo/bar\x00" => "/x.cgi\x00/foo/bar\x00"
- // conn->path_info is pointing to the local variable "path" declared
- // in handle_request(), so PATH_INFO is not valid after
- // handle_request returns.
- conn->path_info = p + 1;
- memmove(p + 2, p + 1, strlen(p + 1) + 1); // +1 is for trailing \0
- p[1] = '/';
- break;
- } else {
- *p = '/';
- }
- }
- }
+ size_t buf_len, struct file *filep) {
+ struct vec a, b;
+ const char *rewrite, *uri = conn->request_info.uri;
+ char *p;
+ int match_len;
+ char gz_path[PATH_MAX];
+ char const* accept_encoding;
+
+ // Using buf_len - 1 because memmove() for PATH_INFO may shift part
+ // of the path one byte on the right.
+ mg_snprintf(conn, buf, buf_len - 1, "%s%s", conn->ctx->config[DOCUMENT_ROOT],
+ uri);
+
+ rewrite = conn->ctx->config[REWRITE];
+ while ((rewrite = next_option(rewrite, &a, &b)) != NULL) {
+ if ((match_len = match_prefix(a.ptr, a.len, uri)) > 0) {
+ mg_snprintf(conn, buf, buf_len - 1, "%.*s%s", (int) b.len, b.ptr,
+ uri + match_len);
+ break;
+ }
+ }
+
+ if (mg_stat(conn, buf, filep)) return;
+
+ // if we can't find the actual file, look for the file
+ // with the same name but a .gz extension. If we find it,
+ // use that and set the gzipped flag in the file struct
+ // to indicate that the response need to have the content-
+ // encoding: gzip header
+ // we can only do this if the browser declares support
+ if ((accept_encoding = mg_get_header(conn, "Accept-Encoding")) != NULL) {
+ if (strstr(accept_encoding,"gzip") != NULL) {
+ snprintf(gz_path, sizeof(gz_path), "%s.gz", buf);
+ if (mg_stat(conn, gz_path, filep)) {
+ filep->gzipped = 1;
+ return;
+ }
+ }
+ }
+
+ // Support PATH_INFO for CGI scripts.
+ for (p = buf + strlen(buf); p > buf + 1; p--) {
+ if (*p == '/') {
+ *p = '\0';
+ if (match_prefix(conn->ctx->config[CGI_EXTENSIONS],
+ strlen(conn->ctx->config[CGI_EXTENSIONS]), buf) > 0 &&
+ mg_stat(conn, buf, filep)) {
+ // Shift PATH_INFO block one character right, e.g.
+ // "/x.cgi/foo/bar\x00" => "/x.cgi\x00/foo/bar\x00"
+ // conn->path_info is pointing to the local variable "path" declared
+ // in handle_request(), so PATH_INFO is not valid after
+ // handle_request returns.
+ conn->path_info = p + 1;
+ memmove(p + 2, p + 1, strlen(p + 1) + 1); // +1 is for trailing \0
+ p[1] = '/';
+ break;
+ } else {
+ *p = '/';
+ }
+ }
+ }
}
// Check whether full request is buffered. Return:
@@ -1864,214 +1862,214 @@ static void convert_uri_to_file_name(struct mg_connection *conn, char *buf,
// 0 if request is not yet fully buffered
// >0 actual request length, including last \r\n\r\n
static int get_request_len(const char *buf, int buflen) {
- const char *s, *e;
- int len = 0;
-
- for (s = buf, e = s + buflen - 1; len <= 0 && s < e; s++)
- // Control characters are not allowed but >=128 is.
- if (!isprint(* (const unsigned char *) s) && *s != '\r' &&
- *s != '\n' && * (const unsigned char *) s < 128) {
- len = -1;
- break; // [i_a] abort scan as soon as one malformed character is found;
- // don't let subsequent \r\n\r\n win us over anyhow
- } else if (s[0] == '\n' && s[1] == '\n') {
- len = (int) (s - buf) + 2;
- } else if (s[0] == '\n' && &s[1] < e &&
- s[1] == '\r' && s[2] == '\n') {
- len = (int) (s - buf) + 3;
- }
-
- return len;
+ const char *s, *e;
+ int len = 0;
+
+ for (s = buf, e = s + buflen - 1; len <= 0 && s < e; s++)
+ // Control characters are not allowed but >=128 is.
+ if (!isprint(* (const unsigned char *) s) && *s != '\r' &&
+ *s != '\n' && * (const unsigned char *) s < 128) {
+ len = -1;
+ break; // [i_a] abort scan as soon as one malformed character is found;
+ // don't let subsequent \r\n\r\n win us over anyhow
+ } else if (s[0] == '\n' && s[1] == '\n') {
+ len = (int) (s - buf) + 2;
+ } else if (s[0] == '\n' && &s[1] < e &&
+ s[1] == '\r' && s[2] == '\n') {
+ len = (int) (s - buf) + 3;
+ }
+
+ return len;
}
// Convert month to the month number. Return -1 on error, or month number
static int get_month_index(const char *s) {
- size_t i;
+ size_t i;
- for (i = 0; i < ARRAY_SIZE(month_names); i++)
- if (!strcmp(s, month_names[i]))
- return (int) i;
+ for (i = 0; i < ARRAY_SIZE(month_names); i++)
+ if (!strcmp(s, month_names[i]))
+ return (int) i;
- return -1;
+ return -1;
}
static int num_leap_years(int year) {
- return year / 4 - year / 100 + year / 400;
+ return year / 4 - year / 100 + year / 400;
}
// Parse UTC date-time string, and return the corresponding time_t value.
static time_t parse_date_string(const char *datetime) {
- static const unsigned short days_before_month[] = {
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
- };
- char month_str[32];
- int second, minute, hour, day, month, year, leap_days, days;
- time_t result = (time_t) 0;
-
- if (((sscanf(datetime, "%d/%3s/%d %d:%d:%d",
- &day, month_str, &year, &hour, &minute, &second) == 6) ||
- (sscanf(datetime, "%d %3s %d %d:%d:%d",
- &day, month_str, &year, &hour, &minute, &second) == 6) ||
- (sscanf(datetime, "%*3s, %d %3s %d %d:%d:%d",
- &day, month_str, &year, &hour, &minute, &second) == 6) ||
- (sscanf(datetime, "%d-%3s-%d %d:%d:%d",
- &day, month_str, &year, &hour, &minute, &second) == 6)) &&
- year > 1970 &&
- (month = get_month_index(month_str)) != -1) {
- leap_days = num_leap_years(year) - num_leap_years(1970);
- year -= 1970;
- days = year * 365 + days_before_month[month] + (day - 1) + leap_days;
- result = days * 24 * 3600 + hour * 3600 + minute * 60 + second;
- }
-
- return result;
+ static const unsigned short days_before_month[] = {
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
+ };
+ char month_str[32];
+ int second, minute, hour, day, month, year, leap_days, days;
+ time_t result = (time_t) 0;
+
+ if (((sscanf(datetime, "%d/%3s/%d %d:%d:%d",
+ &day, month_str, &year, &hour, &minute, &second) == 6) ||
+ (sscanf(datetime, "%d %3s %d %d:%d:%d",
+ &day, month_str, &year, &hour, &minute, &second) == 6) ||
+ (sscanf(datetime, "%*3s, %d %3s %d %d:%d:%d",
+ &day, month_str, &year, &hour, &minute, &second) == 6) ||
+ (sscanf(datetime, "%d-%3s-%d %d:%d:%d",
+ &day, month_str, &year, &hour, &minute, &second) == 6)) &&
+ year > 1970 &&
+ (month = get_month_index(month_str)) != -1) {
+ leap_days = num_leap_years(year) - num_leap_years(1970);
+ year -= 1970;
+ days = year * 365 + days_before_month[month] + (day - 1) + leap_days;
+ result = days * 24 * 3600 + hour * 3600 + minute * 60 + second;
+ }
+
+ return result;
}
// Protect against directory disclosure attack by removing '..',
// excessive '/' and '\' characters
static void remove_double_dots_and_double_slashes(char *s) {
- char *p = s;
-
- while (*s != '\0') {
- *p++ = *s++;
- if (s[-1] == '/' || s[-1] == '\\') {
- // Skip all following slashes, backslashes and double-dots
- while (s[0] != '\0') {
- if (s[0] == '/' || s[0] == '\\') {
- s++;
- } else if (s[0] == '.' && s[1] == '.') {
- s += 2;
- } else {
- break;
- }
- }
- }
- }
- *p = '\0';
+ char *p = s;
+
+ while (*s != '\0') {
+ *p++ = *s++;
+ if (s[-1] == '/' || s[-1] == '\\') {
+ // Skip all following slashes, backslashes and double-dots
+ while (s[0] != '\0') {
+ if (s[0] == '/' || s[0] == '\\') {
+ s++;
+ } else if (s[0] == '.' && s[1] == '.') {
+ s += 2;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ *p = '\0';
}
static const struct {
- const char *extension;
- size_t ext_len;
- const char *mime_type;
+ const char *extension;
+ size_t ext_len;
+ const char *mime_type;
} builtin_mime_types[] = {
- {".html", 5, "text/html"},
- {".htm", 4, "text/html"},
- {".shtm", 5, "text/html"},
- {".shtml", 6, "text/html"},
- {".css", 4, "text/css"},
- {".js", 3, "application/x-javascript"},
- {".ico", 4, "image/x-icon"},
- {".gif", 4, "image/gif"},
- {".jpg", 4, "image/jpeg"},
- {".jpeg", 5, "image/jpeg"},
- {".png", 4, "image/png"},
- {".svg", 4, "image/svg+xml"},
- {".txt", 4, "text/plain"},
- {".torrent", 8, "application/x-bittorrent"},
- {".wav", 4, "audio/x-wav"},
- {".mp3", 4, "audio/x-mp3"},
- {".mid", 4, "audio/mid"},
- {".m3u", 4, "audio/x-mpegurl"},
- {".ogg", 4, "audio/ogg"},
- {".ram", 4, "audio/x-pn-realaudio"},
- {".xml", 4, "text/xml"},
- {".json", 5, "text/json"},
- {".xslt", 5, "application/xml"},
- {".xsl", 4, "application/xml"},
- {".ra", 3, "audio/x-pn-realaudio"},
- {".doc", 4, "application/msword"},
- {".exe", 4, "application/octet-stream"},
- {".zip", 4, "application/x-zip-compressed"},
- {".xls", 4, "application/excel"},
- {".tgz", 4, "application/x-tar-gz"},
- {".tar", 4, "application/x-tar"},
- {".gz", 3, "application/x-gunzip"},
- {".arj", 4, "application/x-arj-compressed"},
- {".rar", 4, "application/x-arj-compressed"},
- {".rtf", 4, "application/rtf"},
- {".pdf", 4, "application/pdf"},
- {".swf", 4, "application/x-shockwave-flash"},
- {".mpg", 4, "video/mpeg"},
- {".webm", 5, "video/webm"},
- {".mpeg", 5, "video/mpeg"},
- {".mov", 4, "video/quicktime"},
- {".mp4", 4, "video/mp4"},
- {".m4v", 4, "video/x-m4v"},
- {".asf", 4, "video/x-ms-asf"},
- {".avi", 4, "video/x-msvideo"},
- {".bmp", 4, "image/bmp"},
- {".ttf", 4, "application/x-font-ttf"},
- {NULL, 0, NULL}
+ {".html", 5, "text/html"},
+ {".htm", 4, "text/html"},
+ {".shtm", 5, "text/html"},
+ {".shtml", 6, "text/html"},
+ {".css", 4, "text/css"},
+ {".js", 3, "application/x-javascript"},
+ {".ico", 4, "image/x-icon"},
+ {".gif", 4, "image/gif"},
+ {".jpg", 4, "image/jpeg"},
+ {".jpeg", 5, "image/jpeg"},
+ {".png", 4, "image/png"},
+ {".svg", 4, "image/svg+xml"},
+ {".txt", 4, "text/plain"},
+ {".torrent", 8, "application/x-bittorrent"},
+ {".wav", 4, "audio/x-wav"},
+ {".mp3", 4, "audio/x-mp3"},
+ {".mid", 4, "audio/mid"},
+ {".m3u", 4, "audio/x-mpegurl"},
+ {".ogg", 4, "audio/ogg"},
+ {".ram", 4, "audio/x-pn-realaudio"},
+ {".xml", 4, "text/xml"},
+ {".json", 5, "text/json"},
+ {".xslt", 5, "application/xml"},
+ {".xsl", 4, "application/xml"},
+ {".ra", 3, "audio/x-pn-realaudio"},
+ {".doc", 4, "application/msword"},
+ {".exe", 4, "application/octet-stream"},
+ {".zip", 4, "application/x-zip-compressed"},
+ {".xls", 4, "application/excel"},
+ {".tgz", 4, "application/x-tar-gz"},
+ {".tar", 4, "application/x-tar"},
+ {".gz", 3, "application/x-gunzip"},
+ {".arj", 4, "application/x-arj-compressed"},
+ {".rar", 4, "application/x-arj-compressed"},
+ {".rtf", 4, "application/rtf"},
+ {".pdf", 4, "application/pdf"},
+ {".swf", 4, "application/x-shockwave-flash"},
+ {".mpg", 4, "video/mpeg"},
+ {".webm", 5, "video/webm"},
+ {".mpeg", 5, "video/mpeg"},
+ {".mov", 4, "video/quicktime"},
+ {".mp4", 4, "video/mp4"},
+ {".m4v", 4, "video/x-m4v"},
+ {".asf", 4, "video/x-ms-asf"},
+ {".avi", 4, "video/x-msvideo"},
+ {".bmp", 4, "image/bmp"},
+ {".ttf", 4, "application/x-font-ttf"},
+ {NULL, 0, NULL}
};
const char *mg_get_builtin_mime_type(const char *path) {
- const char *ext;
- size_t i, path_len;
+ const char *ext;
+ size_t i, path_len;
- path_len = strlen(path);
+ path_len = strlen(path);
- for (i = 0; builtin_mime_types[i].extension != NULL; i++) {
- ext = path + (path_len - builtin_mime_types[i].ext_len);
- if (path_len > builtin_mime_types[i].ext_len &&
- mg_strcasecmp(ext, builtin_mime_types[i].extension) == 0) {
- return builtin_mime_types[i].mime_type;
- }
- }
+ for (i = 0; builtin_mime_types[i].extension != NULL; i++) {
+ ext = path + (path_len - builtin_mime_types[i].ext_len);
+ if (path_len > builtin_mime_types[i].ext_len &&
+ mg_strcasecmp(ext, builtin_mime_types[i].extension) == 0) {
+ return builtin_mime_types[i].mime_type;
+ }
+ }
- return "text/plain";
+ return "text/plain";
}
// Look at the "path" extension and figure what mime type it has.
// Store mime type in the vector.
static void get_mime_type(struct mg_context *ctx, const char *path,
- struct vec *vec) {
- struct vec ext_vec, mime_vec;
- const char *list, *ext;
- size_t path_len;
+ struct vec *vec) {
+ struct vec ext_vec, mime_vec;
+ const char *list, *ext;
+ size_t path_len;
- path_len = strlen(path);
+ path_len = strlen(path);
- // Scan user-defined mime types first, in case user wants to
- // override default mime types.
- list = ctx->config[EXTRA_MIME_TYPES];
- while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) {
- // ext now points to the path suffix
- ext = path + path_len - ext_vec.len;
- if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) {
- *vec = mime_vec;
- return;
- }
- }
+ // Scan user-defined mime types first, in case user wants to
+ // override default mime types.
+ list = ctx->config[EXTRA_MIME_TYPES];
+ while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) {
+ // ext now points to the path suffix
+ ext = path + path_len - ext_vec.len;
+ if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) {
+ *vec = mime_vec;
+ return;
+ }
+ }
- vec->ptr = mg_get_builtin_mime_type(path);
- vec->len = strlen(vec->ptr);
+ vec->ptr = mg_get_builtin_mime_type(path);
+ vec->len = strlen(vec->ptr);
}
static int is_big_endian(void) {
- static const int n = 1;
- return ((char *) &n)[0] == 0;
+ static const int n = 1;
+ return ((char *) &n)[0] == 0;
}
#ifndef HAVE_MD5
typedef struct MD5Context {
- uint32_t buf[4];
- uint32_t bits[2];
- unsigned char in[64];
+ uint32_t buf[4];
+ uint32_t bits[2];
+ unsigned char in[64];
} MD5_CTX;
static void byteReverse(unsigned char *buf, unsigned longs) {
- uint32_t t;
+ uint32_t t;
- // Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN
- if (is_big_endian()) {
- do {
- t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- * (uint32_t *) buf = t;
- buf += 4;
- } while (--longs);
- }
+ // Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN
+ if (is_big_endian()) {
+ do {
+ t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ * (uint32_t *) buf = t;
+ buf += 4;
+ } while (--longs);
+ }
}
#define F1(x, y, z) (z ^ (x & (y ^ z)))
@@ -2080,570 +2078,570 @@ static void byteReverse(unsigned char *buf, unsigned longs) {
#define F4(x, y, z) (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
// Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
// initialization constants.
static void MD5Init(MD5_CTX *ctx) {
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
}
static void MD5Transform(uint32_t buf[4], uint32_t const in[16]) {
- register uint32_t a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+ register uint32_t a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
static void MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len) {
- uint32_t t;
+ uint32_t t;
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
- ctx->bits[1]++;
- ctx->bits[1] += len >> 29;
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
+ ctx->bits[1]++;
+ ctx->bits[1] += len >> 29;
- t = (t >> 3) & 0x3f;
+ t = (t >> 3) & 0x3f;
- if (t) {
- unsigned char *p = (unsigned char *) ctx->in + t;
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
- t = 64 - t;
- if (len < t) {
- memcpy(p, buf, len);
- return;
- }
- memcpy(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += t;
- len -= t;
- }
+ t = 64 - t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ buf += t;
+ len -= t;
+ }
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += 64;
- len -= 64;
- }
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ buf += 64;
+ len -= 64;
+ }
- memcpy(ctx->in, buf, len);
+ memcpy(ctx->in, buf, len);
}
static void MD5Final(unsigned char digest[16], MD5_CTX *ctx) {
- unsigned count;
- unsigned char *p;
- uint32_t *a;
-
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- p = ctx->in + count;
- *p++ = 0x80;
- count = 64 - 1 - count;
- if (count < 8) {
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- memset(ctx->in, 0, 56);
- } else {
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- a = (uint32_t *)ctx->in;
- a[14] = ctx->bits[0];
- a[15] = ctx->bits[1];
-
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- byteReverse((unsigned char *) ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset((char *) ctx, 0, sizeof(*ctx));
+ unsigned count;
+ unsigned char *p;
+ uint32_t *a;
+
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ p = ctx->in + count;
+ *p++ = 0x80;
+ count = 64 - 1 - count;
+ if (count < 8) {
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ memset(ctx->in, 0, 56);
+ } else {
+ memset(p, 0, count - 8);
+ }
+ byteReverse(ctx->in, 14);
+
+ a = (uint32_t *)ctx->in;
+ a[14] = ctx->bits[0];
+ a[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+ byteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset((char *) ctx, 0, sizeof(*ctx));
}
#endif // !HAVE_MD5
// Stringify binary data. Output buffer must be twice as big as input,
// because each byte takes 2 bytes in string representation
static void bin2str(char *to, const unsigned char *p, size_t len) {
- static const char *hex = "0123456789abcdef";
+ static const char *hex = "0123456789abcdef";
- for (; len--; p++) {
- *to++ = hex[p[0] >> 4];
- *to++ = hex[p[0] & 0x0f];
- }
- *to = '\0';
+ for (; len--; p++) {
+ *to++ = hex[p[0] >> 4];
+ *to++ = hex[p[0] & 0x0f];
+ }
+ *to = '\0';
}
// Return stringified MD5 hash for list of strings. Buffer must be 33 bytes.
char *mg_md5(char buf[33], ...) {
- unsigned char hash[16];
- const char *p;
- va_list ap;
- MD5_CTX ctx;
+ unsigned char hash[16];
+ const char *p;
+ va_list ap;
+ MD5_CTX ctx;
- MD5Init(&ctx);
+ MD5Init(&ctx);
- va_start(ap, buf);
- while ((p = va_arg(ap, const char *)) != NULL) {
- MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p));
- }
- va_end(ap);
+ va_start(ap, buf);
+ while ((p = va_arg(ap, const char *)) != NULL) {
+ MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p));
+ }
+ va_end(ap);
- MD5Final(hash, &ctx);
- bin2str(buf, hash, sizeof(hash));
- return buf;
+ MD5Final(hash, &ctx);
+ bin2str(buf, hash, sizeof(hash));
+ return buf;
}
// Check the user's password, return 1 if OK
static int check_password(const char *method, const char *ha1, const char *uri,
- const char *nonce, const char *nc, const char *cnonce,
- const char *qop, const char *response) {
- char ha2[32 + 1], expected_response[32 + 1];
+ const char *nonce, const char *nc, const char *cnonce,
+ const char *qop, const char *response) {
+ char ha2[32 + 1], expected_response[32 + 1];
- // Some of the parameters may be NULL
- if (method == NULL || nonce == NULL || nc == NULL || cnonce == NULL ||
- qop == NULL || response == NULL) {
- return 0;
- }
+ // Some of the parameters may be NULL
+ if (method == NULL || nonce == NULL || nc == NULL || cnonce == NULL ||
+ qop == NULL || response == NULL) {
+ return 0;
+ }
- // NOTE(lsm): due to a bug in MSIE, we do not compare the URI
- // TODO(lsm): check for authentication timeout
- if (// strcmp(dig->uri, c->ouri) != 0 ||
- strlen(response) != 32
- // || now - strtoul(dig->nonce, NULL, 10) > 3600
- ) {
- return 0;
- }
+ // NOTE(lsm): due to a bug in MSIE, we do not compare the URI
+ // TODO(lsm): check for authentication timeout
+ if (// strcmp(dig->uri, c->ouri) != 0 ||
+ strlen(response) != 32
+ // || now - strtoul(dig->nonce, NULL, 10) > 3600
+ ) {
+ return 0;
+ }
- mg_md5(ha2, method, ":", uri, NULL);
- mg_md5(expected_response, ha1, ":", nonce, ":", nc,
- ":", cnonce, ":", qop, ":", ha2, NULL);
+ mg_md5(ha2, method, ":", uri, NULL);
+ mg_md5(expected_response, ha1, ":", nonce, ":", nc,
+ ":", cnonce, ":", qop, ":", ha2, NULL);
- return mg_strcasecmp(response, expected_response) == 0;
+ return mg_strcasecmp(response, expected_response) == 0;
}
// Use the global passwords file, if specified by auth_gpass option,
// or search for .htpasswd in the requested directory.
static void open_auth_file(struct mg_connection *conn, const char *path,
- struct file *filep) {
- char name[PATH_MAX];
- const char *p, *e, *gpass = conn->ctx->config[GLOBAL_PASSWORDS_FILE];
- struct file file = STRUCT_FILE_INITIALIZER;
-
- if (gpass != NULL) {
- // Use global passwords file
- if (!mg_fopen(conn, gpass, "r", filep)) {
- cry(conn, "fopen(%s): %s", gpass, strerror(ERRNO));
- }
- // Important: using local struct file to test path for is_directory flag.
- // If filep is used, mg_stat() makes it appear as if auth file was opened.
- } else if (mg_stat(conn, path, &file) && file.is_directory) {
- mg_snprintf(conn, name, sizeof(name), "%s%c%s",
- path, '/', PASSWORDS_FILE_NAME);
- mg_fopen(conn, name, "r", filep);
- } else {
- // Try to find .htpasswd in requested directory.
- for (p = path, e = p + strlen(p) - 1; e > p; e--)
- if (e[0] == '/')
- break;
- mg_snprintf(conn, name, sizeof(name), "%.*s%c%s",
- (int) (e - p), p, '/', PASSWORDS_FILE_NAME);
- mg_fopen(conn, name, "r", filep);
- }
+ struct file *filep) {
+ char name[PATH_MAX];
+ const char *p, *e, *gpass = conn->ctx->config[GLOBAL_PASSWORDS_FILE];
+ struct file file = STRUCT_FILE_INITIALIZER;
+
+ if (gpass != NULL) {
+ // Use global passwords file
+ if (!mg_fopen(conn, gpass, "r", filep)) {
+ cry(conn, "fopen(%s): %s", gpass, strerror(ERRNO));
+ }
+ // Important: using local struct file to test path for is_directory flag.
+ // If filep is used, mg_stat() makes it appear as if auth file was opened.
+ } else if (mg_stat(conn, path, &file) && file.is_directory) {
+ mg_snprintf(conn, name, sizeof(name), "%s%c%s",
+ path, '/', PASSWORDS_FILE_NAME);
+ mg_fopen(conn, name, "r", filep);
+ } else {
+ // Try to find .htpasswd in requested directory.
+ for (p = path, e = p + strlen(p) - 1; e > p; e--)
+ if (e[0] == '/')
+ break;
+ mg_snprintf(conn, name, sizeof(name), "%.*s%c%s",
+ (int) (e - p), p, '/', PASSWORDS_FILE_NAME);
+ mg_fopen(conn, name, "r", filep);
+ }
}
// Parsed Authorization header
struct ah {
- char *user, *uri, *cnonce, *response, *qop, *nc, *nonce;
+ char *user, *uri, *cnonce, *response, *qop, *nc, *nonce;
};
// Return 1 on success. Always initializes the ah structure.
static int parse_auth_header(struct mg_connection *conn, char *buf,
- size_t buf_size, struct ah *ah) {
- char *name, *value, *s;
- const char *auth_header;
-
- (void) memset(ah, 0, sizeof(*ah));
- if ((auth_header = mg_get_header(conn, "Authorization")) == NULL ||
- mg_strncasecmp(auth_header, "Digest ", 7) != 0) {
- return 0;
- }
-
- // Make modifiable copy of the auth header
- (void) mg_strlcpy(buf, auth_header + 7, buf_size);
- s = buf;
-
- // Parse authorization header
- for (;;) {
- // Gobble initial spaces
- while (isspace(* (unsigned char *) s)) {
- s++;
- }
- name = skip_quoted(&s, "=", " ", 0);
- // Value is either quote-delimited, or ends at first comma or space.
- if (s[0] == '\"') {
- s++;
- value = skip_quoted(&s, "\"", " ", '\\');
- if (s[0] == ',') {
- s++;
- }
- } else {
- value = skip_quoted(&s, ", ", " ", 0); // IE uses commas, FF uses spaces
- }
- if (*name == '\0') {
- break;
- }
-
- if (!strcmp(name, "username")) {
- ah->user = value;
- } else if (!strcmp(name, "cnonce")) {
- ah->cnonce = value;
- } else if (!strcmp(name, "response")) {
- ah->response = value;
- } else if (!strcmp(name, "uri")) {
- ah->uri = value;
- } else if (!strcmp(name, "qop")) {
- ah->qop = value;
- } else if (!strcmp(name, "nc")) {
- ah->nc = value;
- } else if (!strcmp(name, "nonce")) {
- ah->nonce = value;
- }
- }
-
- // CGI needs it as REMOTE_USER
- if (ah->user != NULL) {
- conn->request_info.remote_user = mg_strdup(ah->user);
- } else {
- return 0;
- }
-
- return 1;
+ size_t buf_size, struct ah *ah) {
+ char *name, *value, *s;
+ const char *auth_header;
+
+ (void) memset(ah, 0, sizeof(*ah));
+ if ((auth_header = mg_get_header(conn, "Authorization")) == NULL ||
+ mg_strncasecmp(auth_header, "Digest ", 7) != 0) {
+ return 0;
+ }
+
+ // Make modifiable copy of the auth header
+ (void) mg_strlcpy(buf, auth_header + 7, buf_size);
+ s = buf;
+
+ // Parse authorization header
+ for (;;) {
+ // Gobble initial spaces
+ while (isspace(* (unsigned char *) s)) {
+ s++;
+ }
+ name = skip_quoted(&s, "=", " ", 0);
+ // Value is either quote-delimited, or ends at first comma or space.
+ if (s[0] == '\"') {
+ s++;
+ value = skip_quoted(&s, "\"", " ", '\\');
+ if (s[0] == ',') {
+ s++;
+ }
+ } else {
+ value = skip_quoted(&s, ", ", " ", 0); // IE uses commas, FF uses spaces
+ }
+ if (*name == '\0') {
+ break;
+ }
+
+ if (!strcmp(name, "username")) {
+ ah->user = value;
+ } else if (!strcmp(name, "cnonce")) {
+ ah->cnonce = value;
+ } else if (!strcmp(name, "response")) {
+ ah->response = value;
+ } else if (!strcmp(name, "uri")) {
+ ah->uri = value;
+ } else if (!strcmp(name, "qop")) {
+ ah->qop = value;
+ } else if (!strcmp(name, "nc")) {
+ ah->nc = value;
+ } else if (!strcmp(name, "nonce")) {
+ ah->nonce = value;
+ }
+ }
+
+ // CGI needs it as REMOTE_USER
+ if (ah->user != NULL) {
+ conn->request_info.remote_user = mg_strdup(ah->user);
+ } else {
+ return 0;
+ }
+
+ return 1;
}
static char *mg_fgets(char *buf, size_t size, struct file *filep, char **p) {
- char *eof;
- size_t len;
-
- if (filep->membuf != NULL && *p != NULL) {
- eof = (char*)memchr(*p, '\n', &filep->membuf[filep->size] - *p);
- len = (size_t) (eof - *p) > size - 1 ? size - 1 : (size_t) (eof - *p);
- memcpy(buf, *p, len);
- buf[len] = '\0';
- *p = eof;
- return eof;
- } else if (filep->fp != NULL) {
- return fgets(buf, size, filep->fp);
- } else {
- return NULL;
- }
+ char *eof;
+ size_t len;
+
+ if (filep->membuf != NULL && *p != NULL) {
+ eof = (char*)memchr(*p, '\n', &filep->membuf[filep->size] - *p);
+ len = (size_t) (eof - *p) > size - 1 ? size - 1 : (size_t) (eof - *p);
+ memcpy(buf, *p, len);
+ buf[len] = '\0';
+ *p = eof;
+ return eof;
+ } else if (filep->fp != NULL) {
+ return fgets(buf, size, filep->fp);
+ } else {
+ return NULL;
+ }
}
// Authorize against the opened passwords file. Return 1 if authorized.
static int authorize(struct mg_connection *conn, struct file *filep) {
- struct ah ah;
- char line[256], f_user[256], ha1[256], f_domain[256], buf[MG_BUF_LEN], *p;
+ struct ah ah;
+ char line[256], f_user[256], ha1[256], f_domain[256], buf[MG_BUF_LEN], *p;
- if (!parse_auth_header(conn, buf, sizeof(buf), &ah)) {
- return 0;
- }
+ if (!parse_auth_header(conn, buf, sizeof(buf), &ah)) {
+ return 0;
+ }
- // Loop over passwords file
- p = (char *) filep->membuf;
- while (mg_fgets(line, sizeof(line), filep, &p) != NULL) {
- if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) != 3) {
- continue;
- }
+ // Loop over passwords file
+ p = (char *) filep->membuf;
+ while (mg_fgets(line, sizeof(line), filep, &p) != NULL) {
+ if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) != 3) {
+ continue;
+ }
- if (!strcmp(ah.user, f_user) &&
- !strcmp(conn->ctx->config[AUTHENTICATION_DOMAIN], f_domain))
- return check_password(conn->request_info.request_method, ha1, ah.uri,
- ah.nonce, ah.nc, ah.cnonce, ah.qop, ah.response);
- }
+ if (!strcmp(ah.user, f_user) &&
+ !strcmp(conn->ctx->config[AUTHENTICATION_DOMAIN], f_domain))
+ return check_password(conn->request_info.request_method, ha1, ah.uri,
+ ah.nonce, ah.nc, ah.cnonce, ah.qop, ah.response);
+ }
- return 0;
+ return 0;
}
// Return 1 if request is authorised, 0 otherwise.
static int check_authorization(struct mg_connection *conn, const char *path) {
- char fname[PATH_MAX];
- struct vec uri_vec, filename_vec;
- const char *list;
- struct file file = STRUCT_FILE_INITIALIZER;
- int authorized = 1;
-
- list = conn->ctx->config[PROTECT_URI];
- while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
- if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
- mg_snprintf(conn, fname, sizeof(fname), "%.*s",
- (int) filename_vec.len, filename_vec.ptr);
- if (!mg_fopen(conn, fname, "r", &file)) {
- cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno));
- }
- break;
- }
- }
-
- if (!is_file_opened(&file)) {
- open_auth_file(conn, path, &file);
- }
-
- if (is_file_opened(&file)) {
- authorized = authorize(conn, &file);
- mg_fclose(&file);
- }
-
- return authorized;
+ char fname[PATH_MAX];
+ struct vec uri_vec, filename_vec;
+ const char *list;
+ struct file file = STRUCT_FILE_INITIALIZER;
+ int authorized = 1;
+
+ list = conn->ctx->config[PROTECT_URI];
+ while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
+ if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
+ mg_snprintf(conn, fname, sizeof(fname), "%.*s",
+ (int) filename_vec.len, filename_vec.ptr);
+ if (!mg_fopen(conn, fname, "r", &file)) {
+ cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno));
+ }
+ break;
+ }
+ }
+
+ if (!is_file_opened(&file)) {
+ open_auth_file(conn, path, &file);
+ }
+
+ if (is_file_opened(&file)) {
+ authorized = authorize(conn, &file);
+ mg_fclose(&file);
+ }
+
+ return authorized;
}
static void send_authorization_request(struct mg_connection *conn) {
- conn->status_code = 401;
- mg_printf(conn,
- "HTTP/1.1 401 Unauthorized\r\n"
- "Content-Length: 0\r\n"
- "WWW-Authenticate: Digest qop=\"auth\", "
- "realm=\"%s\", nonce=\"%lu\"\r\n\r\n",
- conn->ctx->config[AUTHENTICATION_DOMAIN],
- (unsigned long) time(NULL));
+ conn->status_code = 401;
+ mg_printf(conn,
+ "HTTP/1.1 401 Unauthorized\r\n"
+ "Content-Length: 0\r\n"
+ "WWW-Authenticate: Digest qop=\"auth\", "
+ "realm=\"%s\", nonce=\"%lu\"\r\n\r\n",
+ conn->ctx->config[AUTHENTICATION_DOMAIN],
+ (unsigned long) time(NULL));
}
static int is_authorized_for_put(struct mg_connection *conn) {
- struct file file = STRUCT_FILE_INITIALIZER;
- const char *passfile = conn->ctx->config[PUT_DELETE_PASSWORDS_FILE];
- int ret = 0;
+ struct file file = STRUCT_FILE_INITIALIZER;
+ const char *passfile = conn->ctx->config[PUT_DELETE_PASSWORDS_FILE];
+ int ret = 0;
- if (passfile != NULL && mg_fopen(conn, passfile, "r", &file)) {
- ret = authorize(conn, &file);
- mg_fclose(&file);
- }
+ if (passfile != NULL && mg_fopen(conn, passfile, "r", &file)) {
+ ret = authorize(conn, &file);
+ mg_fclose(&file);
+ }
- return ret;
+ return ret;
}
int mg_modify_passwords_file(const char *fname, const char *domain,
- const char *user, const char *pass) {
- int found;
- char line[512], u[512], d[512], ha1[33], tmp[PATH_MAX];
- FILE *fp, *fp2;
-
- found = 0;
- fp = fp2 = NULL;
-
- // Regard empty password as no password - remove user record.
- if (pass != NULL && pass[0] == '\0') {
- pass = NULL;
- }
-
- (void) snprintf(tmp, sizeof(tmp), "%s.tmp", fname);
-
- // Create the file if does not exist
- if ((fp = fopen(fname, "a+")) != NULL) {
- (void) fclose(fp);
- }
-
- // Open the given file and temporary file
- if ((fp = fopen(fname, "r")) == NULL) {
- return 0;
- } else if ((fp2 = fopen(tmp, "w+")) == NULL) {
- fclose(fp);
- return 0;
- }
-
- // Copy the stuff to temporary file
- while (fgets(line, sizeof(line), fp) != NULL) {
- if (sscanf(line, "%[^:]:%[^:]:%*s", u, d) != 2) {
- continue;
- }
-
- if (!strcmp(u, user) && !strcmp(d, domain)) {
- found++;
- if (pass != NULL) {
- mg_md5(ha1, user, ":", domain, ":", pass, NULL);
- fprintf(fp2, "%s:%s:%s\n", user, domain, ha1);
- }
- } else {
- fprintf(fp2, "%s", line);
- }
- }
-
- // If new user, just add it
- if (!found && pass != NULL) {
- mg_md5(ha1, user, ":", domain, ":", pass, NULL);
- fprintf(fp2, "%s:%s:%s\n", user, domain, ha1);
- }
-
- // Close files
- fclose(fp);
- fclose(fp2);
-
- // Put the temp file in place of real file
- remove(fname);
- rename(tmp, fname);
-
- return 1;
+ const char *user, const char *pass) {
+ int found;
+ char line[512], u[512], d[512], ha1[33], tmp[PATH_MAX];
+ FILE *fp, *fp2;
+
+ found = 0;
+ fp = fp2 = NULL;
+
+ // Regard empty password as no password - remove user record.
+ if (pass != NULL && pass[0] == '\0') {
+ pass = NULL;
+ }
+
+ (void) snprintf(tmp, sizeof(tmp), "%s.tmp", fname);
+
+ // Create the file if does not exist
+ if ((fp = fopen(fname, "a+")) != NULL) {
+ (void) fclose(fp);
+ }
+
+ // Open the given file and temporary file
+ if ((fp = fopen(fname, "r")) == NULL) {
+ return 0;
+ } else if ((fp2 = fopen(tmp, "w+")) == NULL) {
+ fclose(fp);
+ return 0;
+ }
+
+ // Copy the stuff to temporary file
+ while (fgets(line, sizeof(line), fp) != NULL) {
+ if (sscanf(line, "%[^:]:%[^:]:%*s", u, d) != 2) {
+ continue;
+ }
+
+ if (!strcmp(u, user) && !strcmp(d, domain)) {
+ found++;
+ if (pass != NULL) {
+ mg_md5(ha1, user, ":", domain, ":", pass, NULL);
+ fprintf(fp2, "%s:%s:%s\n", user, domain, ha1);
+ }
+ } else {
+ fprintf(fp2, "%s", line);
+ }
+ }
+
+ // If new user, just add it
+ if (!found && pass != NULL) {
+ mg_md5(ha1, user, ":", domain, ":", pass, NULL);
+ fprintf(fp2, "%s:%s:%s\n", user, domain, ha1);
+ }
+
+ // Close files
+ fclose(fp);
+ fclose(fp2);
+
+ // Put the temp file in place of real file
+ remove(fname);
+ rename(tmp, fname);
+
+ return 1;
}
static int conn2(const char *host, int port, int use_ssl,
- char *ebuf, size_t ebuf_len) {
- struct sockaddr_in sin;
- struct hostent *he;
- SOCKET sock = INVALID_SOCKET;
-
- if (host == NULL) {
- snprintf(ebuf, ebuf_len, "%s", "NULL host");
- } else if (use_ssl && SSLv23_client_method == NULL) {
- snprintf(ebuf, ebuf_len, "%s", "SSL is not initialized");
- // TODO(lsm): use something threadsafe instead of gethostbyname()
- } else if ((he = gethostbyname(host)) == NULL) {
- snprintf(ebuf, ebuf_len, "gethostbyname(%s): %s", host, strerror(ERRNO));
- } else if ((sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
- snprintf(ebuf, ebuf_len, "socket(): %s", strerror(ERRNO));
- } else {
- sin.sin_family = AF_INET;
- sin.sin_port = htons((uint16_t) port);
- sin.sin_addr = * (struct in_addr *) he->h_addr_list[0];
- if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) != 0) {
- snprintf(ebuf, ebuf_len, "connect(%s:%d): %s",
- host, port, strerror(ERRNO));
- closesocket(sock);
- sock = INVALID_SOCKET;
- }
- }
- return sock;
+ char *ebuf, size_t ebuf_len) {
+ struct sockaddr_in sin;
+ struct hostent *he;
+ SOCKET sock = INVALID_SOCKET;
+
+ if (host == NULL) {
+ snprintf(ebuf, ebuf_len, "%s", "NULL host");
+ } else if (use_ssl && SSLv23_client_method == NULL) {
+ snprintf(ebuf, ebuf_len, "%s", "SSL is not initialized");
+ // TODO(lsm): use something threadsafe instead of gethostbyname()
+ } else if ((he = gethostbyname(host)) == NULL) {
+ snprintf(ebuf, ebuf_len, "gethostbyname(%s): %s", host, strerror(ERRNO));
+ } else if ((sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
+ snprintf(ebuf, ebuf_len, "socket(): %s", strerror(ERRNO));
+ } else {
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons((uint16_t) port);
+ sin.sin_addr = * (struct in_addr *) he->h_addr_list[0];
+ if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) != 0) {
+ snprintf(ebuf, ebuf_len, "connect(%s:%d): %s",
+ host, port, strerror(ERRNO));
+ closesocket(sock);
+ sock = INVALID_SOCKET;
+ }
+ }
+ return sock;
}
void mg_url_encode(const char *src, char *dst, size_t dst_len) {
- static const char *dont_escape = "._-$,;~()";
- static const char *hex = "0123456789abcdef";
- const char *end = dst + dst_len - 1;
+ static const char *dont_escape = "._-$,;~()";
+ static const char *hex = "0123456789abcdef";
+ const char *end = dst + dst_len - 1;
- for (; *src != '\0' && dst < end; src++, dst++) {
- if (isalnum(*(const unsigned char *) src) ||
- strchr(dont_escape, * (const unsigned char *) src) != NULL) {
- *dst = *src;
- } else if (dst + 2 < end) {
- dst[0] = '%';
- dst[1] = hex[(* (const unsigned char *) src) >> 4];
- dst[2] = hex[(* (const unsigned char *) src) & 0xf];
- dst += 2;
- }
- }
+ for (; *src != '\0' && dst < end; src++, dst++) {
+ if (isalnum(*(const unsigned char *) src) ||
+ strchr(dont_escape, * (const unsigned char *) src) != NULL) {
+ *dst = *src;
+ } else if (dst + 2 < end) {
+ dst[0] = '%';
+ dst[1] = hex[(* (const unsigned char *) src) >> 4];
+ dst[2] = hex[(* (const unsigned char *) src) & 0xf];
+ dst += 2;
+ }
+ }
- *dst = '\0';
+ *dst = '\0';
}
static void print_dir_entry(struct de *de) {
- char size[64], mod[64], href[PATH_MAX];
-
- if (de->file.is_directory) {
- mg_snprintf(de->conn, size, sizeof(size), "%s", "[DIRECTORY]");
- } else {
- // We use (signed) cast below because MSVC 6 compiler cannot
- // convert unsigned __int64 to double. Sigh.
- if (de->file.size < 1024) {
- mg_snprintf(de->conn, size, sizeof(size), "%d", (int) de->file.size);
- } else if (de->file.size < 0x100000) {
- mg_snprintf(de->conn, size, sizeof(size),
- "%.1fk", (double) de->file.size / 1024.0);
- } else if (de->file.size < 0x40000000) {
- mg_snprintf(de->conn, size, sizeof(size),
- "%.1fM", (double) de->file.size / 1048576);
- } else {
- mg_snprintf(de->conn, size, sizeof(size),
- "%.1fG", (double) de->file.size / 1073741824);
- }
- }
- strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M",
- localtime(&de->file.modification_time));
- mg_url_encode(de->file_name, href, sizeof(href));
- de->conn->num_bytes_sent += mg_printf(de->conn,
- "<tr><td><a href=\"%s%s%s\">%s%s</a></td>"
- "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
- de->conn->request_info.uri, href, de->file.is_directory ? "/" : "",
- de->file_name, de->file.is_directory ? "/" : "", mod, size);
+ char size[64], mod[64], href[PATH_MAX];
+
+ if (de->file.is_directory) {
+ mg_snprintf(de->conn, size, sizeof(size), "%s", "[DIRECTORY]");
+ } else {
+ // We use (signed) cast below because MSVC 6 compiler cannot
+ // convert unsigned __int64 to double. Sigh.
+ if (de->file.size < 1024) {
+ mg_snprintf(de->conn, size, sizeof(size), "%d", (int) de->file.size);
+ } else if (de->file.size < 0x100000) {
+ mg_snprintf(de->conn, size, sizeof(size),
+ "%.1fk", (double) de->file.size / 1024.0);
+ } else if (de->file.size < 0x40000000) {
+ mg_snprintf(de->conn, size, sizeof(size),
+ "%.1fM", (double) de->file.size / 1048576);
+ } else {
+ mg_snprintf(de->conn, size, sizeof(size),
+ "%.1fG", (double) de->file.size / 1073741824);
+ }
+ }
+ strftime(mod, sizeof(mod), "%d-%b-%Y %H:%M",
+ localtime(&de->file.modification_time));
+ mg_url_encode(de->file_name, href, sizeof(href));
+ de->conn->num_bytes_sent += mg_printf(de->conn,
+ "<tr><td><a href=\"%s%s%s\">%s%s</a></td>"
+ "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
+ de->conn->request_info.uri, href, de->file.is_directory ? "/" : "",
+ de->file_name, de->file.is_directory ? "/" : "", mod, size);
}
// This function is called from send_directory() and used for
@@ -2651,409 +2649,409 @@ static void print_dir_entry(struct de *de) {
// On windows, __cdecl specification is needed in case if project is built
// with __stdcall convention. qsort always requires __cdels callback.
static int WINCDECL compare_dir_entries(const void *p1, const void *p2) {
- const struct de *a = (const struct de *) p1, *b = (const struct de *) p2;
- const char *query_string = a->conn->request_info.query_string;
- int cmp_result = 0;
-
- if (query_string == NULL) {
- query_string = "na";
- }
-
- if (a->file.is_directory && !b->file.is_directory) {
- return -1; // Always put directories on top
- } else if (!a->file.is_directory && b->file.is_directory) {
- return 1; // Always put directories on top
- } else if (*query_string == 'n') {
- cmp_result = strcmp(a->file_name, b->file_name);
- } else if (*query_string == 's') {
- cmp_result = a->file.size == b->file.size ? 0 :
- a->file.size > b->file.size ? 1 : -1;
- } else if (*query_string == 'd') {
- cmp_result = a->file.modification_time == b->file.modification_time ? 0 :
- a->file.modification_time > b->file.modification_time ? 1 : -1;
- }
-
- return query_string[1] == 'd' ? -cmp_result : cmp_result;
+ const struct de *a = (const struct de *) p1, *b = (const struct de *) p2;
+ const char *query_string = a->conn->request_info.query_string;
+ int cmp_result = 0;
+
+ if (query_string == NULL) {
+ query_string = "na";
+ }
+
+ if (a->file.is_directory && !b->file.is_directory) {
+ return -1; // Always put directories on top
+ } else if (!a->file.is_directory && b->file.is_directory) {
+ return 1; // Always put directories on top
+ } else if (*query_string == 'n') {
+ cmp_result = strcmp(a->file_name, b->file_name);
+ } else if (*query_string == 's') {
+ cmp_result = a->file.size == b->file.size ? 0 :
+ a->file.size > b->file.size ? 1 : -1;
+ } else if (*query_string == 'd') {
+ cmp_result = a->file.modification_time == b->file.modification_time ? 0 :
+ a->file.modification_time > b->file.modification_time ? 1 : -1;
+ }
+
+ return query_string[1] == 'd' ? -cmp_result : cmp_result;
}
static int must_hide_file(struct mg_connection *conn, const char *path) {
- const char *pw_pattern = "**" PASSWORDS_FILE_NAME "$";
- const char *pattern = conn->ctx->config[HIDE_FILES];
- return match_prefix(pw_pattern, strlen(pw_pattern), path) > 0 ||
- (pattern != NULL && match_prefix(pattern, strlen(pattern), path) > 0);
+ const char *pw_pattern = "**" PASSWORDS_FILE_NAME "$";
+ const char *pattern = conn->ctx->config[HIDE_FILES];
+ return match_prefix(pw_pattern, strlen(pw_pattern), path) > 0 ||
+ (pattern != NULL && match_prefix(pattern, strlen(pattern), path) > 0);
}
static int scan_directory(struct mg_connection *conn, const char *dir,
- void *data, void (*cb)(struct de *, void *)) {
- char path[PATH_MAX];
- struct dirent *dp;
- DIR *dirp;
- struct de de;
-
- if ((dirp = opendir(dir)) == NULL) {
- return 0;
- } else {
- de.conn = conn;
-
- while ((dp = readdir(dirp)) != NULL) {
- // Do not show current dir and hidden files
- if (!strcmp(dp->d_name, ".") ||
- !strcmp(dp->d_name, "..") ||
- must_hide_file(conn, dp->d_name)) {
- continue;
- }
-
- mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, '/', dp->d_name);
-
- // If we don't memset stat structure to zero, mtime will have
- // garbage and strftime() will segfault later on in
- // print_dir_entry(). memset is required only if mg_stat()
- // fails. For more details, see
- // http://code.google.com/p/mongoose/issues/detail?id=79
- memset(&de.file, 0, sizeof(de.file));
- mg_stat(conn, path, &de.file);
-
- de.file_name = dp->d_name;
- cb(&de, data);
- }
- (void) closedir(dirp);
- }
- return 1;
+ void *data, void (*cb)(struct de *, void *)) {
+ char path[PATH_MAX];
+ struct dirent *dp;
+ DIR *dirp;
+ struct de de;
+
+ if ((dirp = opendir(dir)) == NULL) {
+ return 0;
+ } else {
+ de.conn = conn;
+
+ while ((dp = readdir(dirp)) != NULL) {
+ // Do not show current dir and hidden files
+ if (!strcmp(dp->d_name, ".") ||
+ !strcmp(dp->d_name, "..") ||
+ must_hide_file(conn, dp->d_name)) {
+ continue;
+ }
+
+ mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, '/', dp->d_name);
+
+ // If we don't memset stat structure to zero, mtime will have
+ // garbage and strftime() will segfault later on in
+ // print_dir_entry(). memset is required only if mg_stat()
+ // fails. For more details, see
+ // http://code.google.com/p/mongoose/issues/detail?id=79
+ memset(&de.file, 0, sizeof(de.file));
+ mg_stat(conn, path, &de.file);
+
+ de.file_name = dp->d_name;
+ cb(&de, data);
+ }
+ (void) closedir(dirp);
+ }
+ return 1;
}
static int remove_directory(struct mg_connection *conn, const char *dir) {
- char path[PATH_MAX];
- struct dirent *dp;
- DIR *dirp;
- struct de de;
-
- if ((dirp = opendir(dir)) == NULL) {
- return 0;
- } else {
- de.conn = conn;
-
- while ((dp = readdir(dirp)) != NULL) {
- // Do not show current dir (but show hidden files as they will also be removed)
- if (!strcmp(dp->d_name, ".") ||
- !strcmp(dp->d_name, "..")) {
- continue;
- }
-
- mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, '/', dp->d_name);
-
- // If we don't memset stat structure to zero, mtime will have
- // garbage and strftime() will segfault later on in
- // print_dir_entry(). memset is required only if mg_stat()
- // fails. For more details, see
- // http://code.google.com/p/mongoose/issues/detail?id=79
- memset(&de.file, 0, sizeof(de.file));
- mg_stat(conn, path, &de.file);
- if(de.file.modification_time) {
- if(de.file.is_directory) {
- remove_directory(conn, path);
- } else {
- mg_remove(path);
- }
- }
-
- }
- (void) closedir(dirp);
-
- rmdir(dir);
- }
-
- return 1;
+ char path[PATH_MAX];
+ struct dirent *dp;
+ DIR *dirp;
+ struct de de;
+
+ if ((dirp = opendir(dir)) == NULL) {
+ return 0;
+ } else {
+ de.conn = conn;
+
+ while ((dp = readdir(dirp)) != NULL) {
+ // Do not show current dir (but show hidden files as they will also be removed)
+ if (!strcmp(dp->d_name, ".") ||
+ !strcmp(dp->d_name, "..")) {
+ continue;
+ }
+
+ mg_snprintf(conn, path, sizeof(path), "%s%c%s", dir, '/', dp->d_name);
+
+ // If we don't memset stat structure to zero, mtime will have
+ // garbage and strftime() will segfault later on in
+ // print_dir_entry(). memset is required only if mg_stat()
+ // fails. For more details, see
+ // http://code.google.com/p/mongoose/issues/detail?id=79
+ memset(&de.file, 0, sizeof(de.file));
+ mg_stat(conn, path, &de.file);
+ if(de.file.modification_time) {
+ if(de.file.is_directory) {
+ remove_directory(conn, path);
+ } else {
+ mg_remove(path);
+ }
+ }
+
+ }
+ (void) closedir(dirp);
+
+ rmdir(dir);
+ }
+
+ return 1;
}
struct dir_scan_data {
- struct de *entries;
- int num_entries;
- int arr_size;
+ struct de *entries;
+ int num_entries;
+ int arr_size;
};
// Behaves like realloc(), but frees original pointer on failure
static void *realloc2(void *ptr, size_t size) {
- void *new_ptr = realloc(ptr, size);
- if (new_ptr == NULL) {
- free(ptr);
- }
- return new_ptr;
+ void *new_ptr = realloc(ptr, size);
+ if (new_ptr == NULL) {
+ free(ptr);
+ }
+ return new_ptr;
}
static void dir_scan_callback(struct de *de, void *data) {
- struct dir_scan_data *dsd = (struct dir_scan_data *) data;
-
- if (dsd->entries == NULL || dsd->num_entries >= dsd->arr_size) {
- dsd->arr_size *= 2;
- dsd->entries = (struct de *) realloc2(dsd->entries, dsd->arr_size *
- sizeof(dsd->entries[0]));
- }
- if (dsd->entries == NULL) {
- // TODO(lsm): propagate an error to the caller
- dsd->num_entries = 0;
- } else {
- dsd->entries[dsd->num_entries].file_name = mg_strdup(de->file_name);
- dsd->entries[dsd->num_entries].file = de->file;
- dsd->entries[dsd->num_entries].conn = de->conn;
- dsd->num_entries++;
- }
+ struct dir_scan_data *dsd = (struct dir_scan_data *) data;
+
+ if (dsd->entries == NULL || dsd->num_entries >= dsd->arr_size) {
+ dsd->arr_size *= 2;
+ dsd->entries = (struct de *) realloc2(dsd->entries, dsd->arr_size *
+ sizeof(dsd->entries[0]));
+ }
+ if (dsd->entries == NULL) {
+ // TODO(lsm): propagate an error to the caller
+ dsd->num_entries = 0;
+ } else {
+ dsd->entries[dsd->num_entries].file_name = mg_strdup(de->file_name);
+ dsd->entries[dsd->num_entries].file = de->file;
+ dsd->entries[dsd->num_entries].conn = de->conn;
+ dsd->num_entries++;
+ }
}
static void handle_directory_request(struct mg_connection *conn,
- const char *dir) {
- int i, sort_direction;
- struct dir_scan_data data = { NULL, 0, 128 };
-
- if (!scan_directory(conn, dir, &data, dir_scan_callback)) {
- send_http_error(conn, 500, "Cannot open directory",
- "Error: opendir(%s): %s", dir, strerror(ERRNO));
- return;
- }
-
- sort_direction = conn->request_info.query_string != NULL &&
- conn->request_info.query_string[1] == 'd' ? 'a' : 'd';
-
- conn->must_close = 1;
- mg_printf(conn, "%s",
- "HTTP/1.1 200 OK\r\n"
- "Connection: close\r\n"
- "Content-Type: text/html; charset=utf-8\r\n\r\n");
-
- conn->num_bytes_sent += mg_printf(conn,
- "<html><head><title>Index of %s</title>"
- "<style>th {text-align: left;}</style></head>"
- "<body><h1>Index of %s</h1><pre><table cellpadding=\"0\">"
- "<tr><th><a href=\"?n%c\">Name</a></th>"
- "<th><a href=\"?d%c\">Modified</a></th>"
- "<th><a href=\"?s%c\">Size</a></th></tr>"
- "<tr><td colspan=\"3\"><hr></td></tr>",
- conn->request_info.uri, conn->request_info.uri,
- sort_direction, sort_direction, sort_direction);
-
- // Print first entry - link to a parent directory
- conn->num_bytes_sent += mg_printf(conn,
- "<tr><td><a href=\"%s%s\">%s</a></td>"
- "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
- conn->request_info.uri, "..", "Parent directory", "-", "-");
-
- // Sort and print directory entries
- qsort(data.entries, (size_t) data.num_entries, sizeof(data.entries[0]),
- compare_dir_entries);
- for (i = 0; i < data.num_entries; i++) {
- print_dir_entry(&data.entries[i]);
- free(data.entries[i].file_name);
- }
- free(data.entries);
-
- conn->num_bytes_sent += mg_printf(conn, "%s", "</table></body></html>");
- conn->status_code = 200;
+ const char *dir) {
+ int i, sort_direction;
+ struct dir_scan_data data = { NULL, 0, 128 };
+
+ if (!scan_directory(conn, dir, &data, dir_scan_callback)) {
+ send_http_error(conn, 500, "Cannot open directory",
+ "Error: opendir(%s): %s", dir, strerror(ERRNO));
+ return;
+ }
+
+ sort_direction = conn->request_info.query_string != NULL &&
+ conn->request_info.query_string[1] == 'd' ? 'a' : 'd';
+
+ conn->must_close = 1;
+ mg_printf(conn, "%s",
+ "HTTP/1.1 200 OK\r\n"
+ "Connection: close\r\n"
+ "Content-Type: text/html; charset=utf-8\r\n\r\n");
+
+ conn->num_bytes_sent += mg_printf(conn,
+ "<html><head><title>Index of %s</title>"
+ "<style>th {text-align: left;}</style></head>"
+ "<body><h1>Index of %s</h1><pre><table cellpadding=\"0\">"
+ "<tr><th><a href=\"?n%c\">Name</a></th>"
+ "<th><a href=\"?d%c\">Modified</a></th>"
+ "<th><a href=\"?s%c\">Size</a></th></tr>"
+ "<tr><td colspan=\"3\"><hr></td></tr>",
+ conn->request_info.uri, conn->request_info.uri,
+ sort_direction, sort_direction, sort_direction);
+
+ // Print first entry - link to a parent directory
+ conn->num_bytes_sent += mg_printf(conn,
+ "<tr><td><a href=\"%s%s\">%s</a></td>"
+ "<td>&nbsp;%s</td><td>&nbsp;&nbsp;%s</td></tr>\n",
+ conn->request_info.uri, "..", "Parent directory", "-", "-");
+
+ // Sort and print directory entries
+ qsort(data.entries, (size_t) data.num_entries, sizeof(data.entries[0]),
+ compare_dir_entries);
+ for (i = 0; i < data.num_entries; i++) {
+ print_dir_entry(&data.entries[i]);
+ free(data.entries[i].file_name);
+ }
+ free(data.entries);
+
+ conn->num_bytes_sent += mg_printf(conn, "%s", "</table></body></html>");
+ conn->status_code = 200;
}
// Send len bytes from the opened file to the client.
static void send_file_data(struct mg_connection *conn, struct file *filep,
- int64_t offset, int64_t len) {
- char buf[MG_BUF_LEN];
- int to_read, num_read, num_written;
-
- // Sanity check the offset
- offset = offset < 0 ? 0 : offset > filep->size ? filep->size : offset;
-
- if (len > 0 && filep->membuf != NULL && filep->size > 0) {
- if (len > filep->size - offset) {
- len = filep->size - offset;
- }
- mg_write(conn, filep->membuf + offset, (size_t) len);
- } else if (len > 0 && filep->fp != NULL) {
- fseeko(filep->fp, offset, SEEK_SET);
- while (len > 0) {
- // Calculate how much to read from the file in the buffer
- to_read = sizeof(buf);
- if ((int64_t) to_read > len) {
- to_read = (int) len;
- }
-
- // Read from file, exit the loop on error
- if ((num_read = fread(buf, 1, (size_t) to_read, filep->fp)) <= 0) {
- break;
- }
-
- // Send read bytes to the client, exit the loop on error
- if ((num_written = mg_write(conn, buf, (size_t) num_read)) != num_read) {
- break;
- }
-
- // Both read and were successful, adjust counters
- conn->num_bytes_sent += num_written;
- len -= num_written;
- }
- }
+ int64_t offset, int64_t len) {
+ char buf[MG_BUF_LEN];
+ int to_read, num_read, num_written;
+
+ // Sanity check the offset
+ offset = offset < 0 ? 0 : offset > filep->size ? filep->size : offset;
+
+ if (len > 0 && filep->membuf != NULL && filep->size > 0) {
+ if (len > filep->size - offset) {
+ len = filep->size - offset;
+ }
+ mg_write(conn, filep->membuf + offset, (size_t) len);
+ } else if (len > 0 && filep->fp != NULL) {
+ fseeko(filep->fp, offset, SEEK_SET);
+ while (len > 0) {
+ // Calculate how much to read from the file in the buffer
+ to_read = sizeof(buf);
+ if ((int64_t) to_read > len) {
+ to_read = (int) len;
+ }
+
+ // Read from file, exit the loop on error
+ if ((num_read = fread(buf, 1, (size_t) to_read, filep->fp)) <= 0) {
+ break;
+ }
+
+ // Send read bytes to the client, exit the loop on error
+ if ((num_written = mg_write(conn, buf, (size_t) num_read)) != num_read) {
+ break;
+ }
+
+ // Both read and were successful, adjust counters
+ conn->num_bytes_sent += num_written;
+ len -= num_written;
+ }
+ }
}
static int parse_range_header(const char *header, int64_t *a, int64_t *b) {
- return sscanf(header, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b);
+ return sscanf(header, "bytes=%" INT64_FMT "-%" INT64_FMT, a, b);
}
static void gmt_time_string(char *buf, size_t buf_len, time_t *t) {
- strftime(buf, buf_len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(t));
+ strftime(buf, buf_len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(t));
}
static void construct_etag(char *buf, size_t buf_len,
- const struct file *filep) {
- snprintf(buf, buf_len, "\"%lx.%" INT64_FMT "\"",
- (unsigned long) filep->modification_time, filep->size);
+ const struct file *filep) {
+ snprintf(buf, buf_len, "\"%lx.%" INT64_FMT "\"",
+ (unsigned long) filep->modification_time, filep->size);
}
static void fclose_on_exec(struct file *filep) {
- if (filep != NULL && filep->fp != NULL) {
+ if (filep != NULL && filep->fp != NULL) {
#ifndef _WIN32
- fcntl(fileno(filep->fp), F_SETFD, FD_CLOEXEC);
+ fcntl(fileno(filep->fp), F_SETFD, FD_CLOEXEC);
#endif
- }
+ }
}
static void handle_file_request(struct mg_connection *conn, const char *path,
- struct file *filep) {
- char date[64], lm[64], etag[64], range[64];
- const char *msg = "OK", *hdr;
- time_t curtime = time(NULL);
- int64_t cl, r1, r2;
- struct vec mime_vec;
- int n;
- char gz_path[PATH_MAX];
- char const* encoding = "";
-
- get_mime_type(conn->ctx, path, &mime_vec);
- cl = filep->size;
- conn->status_code = 200;
- range[0] = '\0';
-
- // if this file is in fact a pre-gzipped file, rewrite its filename
- // it's important to rewrite the filename after resolving
- // the mime type from it, to preserve the actual file's type
- if (filep->gzipped) {
- snprintf(gz_path, sizeof(gz_path), "%s.gz", path);
- path = gz_path;
- encoding = "Content-Encoding: gzip\r\n";
- }
-
- if (!mg_fopen(conn, path, "rb", filep)) {
- send_http_error(conn, 500, http_500_error,
- "fopen(%s): %s", path, strerror(ERRNO));
- return;
- }
-
- fclose_on_exec(filep);
-
- // If Range: header specified, act accordingly
- r1 = r2 = 0;
- hdr = mg_get_header(conn, "Range");
- if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0 &&
- r1 >= 0 && r2 >= 0) {
- // actually, range requests don't play well with a pre-gzipped
- // file (since the range is specified in the uncmpressed space)
- if (filep->gzipped) {
- send_http_error(conn, 501, "Not Implemented", "range requests in gzipped files are not supported");
- return;
- }
- conn->status_code = 206;
- cl = n == 2 ? (r2 > cl ? cl : r2) - r1 + 1: cl - r1;
- mg_snprintf(conn, range, sizeof(range),
- "Content-Range: bytes "
- "%" INT64_FMT "-%"
- INT64_FMT "/%" INT64_FMT "\r\n",
- r1, r1 + cl - 1, filep->size);
- msg = "Partial Content";
- }
-
- // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to
- // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
- gmt_time_string(date, sizeof(date), &curtime);
- gmt_time_string(lm, sizeof(lm), &filep->modification_time);
- construct_etag(etag, sizeof(etag), filep);
-
- (void) mg_printf(conn,
- "HTTP/1.1 %d %s\r\n"
- "Date: %s\r\n"
- "Last-Modified: %s\r\n"
- "Etag: %s\r\n"
- "Content-Type: %.*s\r\n"
- "Content-Length: %" INT64_FMT "\r\n"
- "Connection: %s\r\n"
- "Accept-Ranges: bytes\r\n"
- "%s%s\r\n",
- conn->status_code, msg, date, lm, etag, (int) mime_vec.len,
- mime_vec.ptr, cl, suggest_connection_header(conn), range, encoding);
-
- if (strcmp(conn->request_info.request_method, "HEAD") != 0) {
- send_file_data(conn, filep, r1, cl);
- }
- mg_fclose(filep);
+ struct file *filep) {
+ char date[64], lm[64], etag[64], range[64];
+ const char *msg = "OK", *hdr;
+ time_t curtime = time(NULL);
+ int64_t cl, r1, r2;
+ struct vec mime_vec;
+ int n;
+ char gz_path[PATH_MAX];
+ char const* encoding = "";
+
+ get_mime_type(conn->ctx, path, &mime_vec);
+ cl = filep->size;
+ conn->status_code = 200;
+ range[0] = '\0';
+
+ // if this file is in fact a pre-gzipped file, rewrite its filename
+ // it's important to rewrite the filename after resolving
+ // the mime type from it, to preserve the actual file's type
+ if (filep->gzipped) {
+ snprintf(gz_path, sizeof(gz_path), "%s.gz", path);
+ path = gz_path;
+ encoding = "Content-Encoding: gzip\r\n";
+ }
+
+ if (!mg_fopen(conn, path, "rb", filep)) {
+ send_http_error(conn, 500, http_500_error,
+ "fopen(%s): %s", path, strerror(ERRNO));
+ return;
+ }
+
+ fclose_on_exec(filep);
+
+ // If Range: header specified, act accordingly
+ r1 = r2 = 0;
+ hdr = mg_get_header(conn, "Range");
+ if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0 &&
+ r1 >= 0 && r2 >= 0) {
+ // actually, range requests don't play well with a pre-gzipped
+ // file (since the range is specified in the uncmpressed space)
+ if (filep->gzipped) {
+ send_http_error(conn, 501, "Not Implemented", "range requests in gzipped files are not supported");
+ return;
+ }
+ conn->status_code = 206;
+ cl = n == 2 ? (r2 > cl ? cl : r2) - r1 + 1: cl - r1;
+ mg_snprintf(conn, range, sizeof(range),
+ "Content-Range: bytes "
+ "%" INT64_FMT "-%"
+ INT64_FMT "/%" INT64_FMT "\r\n",
+ r1, r1 + cl - 1, filep->size);
+ msg = "Partial Content";
+ }
+
+ // Prepare Etag, Date, Last-Modified headers. Must be in UTC, according to
+ // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3
+ gmt_time_string(date, sizeof(date), &curtime);
+ gmt_time_string(lm, sizeof(lm), &filep->modification_time);
+ construct_etag(etag, sizeof(etag), filep);
+
+ (void) mg_printf(conn,
+ "HTTP/1.1 %d %s\r\n"
+ "Date: %s\r\n"
+ "Last-Modified: %s\r\n"
+ "Etag: %s\r\n"
+ "Content-Type: %.*s\r\n"
+ "Content-Length: %" INT64_FMT "\r\n"
+ "Connection: %s\r\n"
+ "Accept-Ranges: bytes\r\n"
+ "%s%s\r\n",
+ conn->status_code, msg, date, lm, etag, (int) mime_vec.len,
+ mime_vec.ptr, cl, suggest_connection_header(conn), range, encoding);
+
+ if (strcmp(conn->request_info.request_method, "HEAD") != 0) {
+ send_file_data(conn, filep, r1, cl);
+ }
+ mg_fclose(filep);
}
void mg_send_file(struct mg_connection *conn, const char *path) {
- struct file file = STRUCT_FILE_INITIALIZER;
- if (mg_stat(conn, path, &file)) {
- handle_file_request(conn, path, &file);
- } else {
- send_http_error(conn, 404, "Not Found", "%s", "File not found");
- }
+ struct file file = STRUCT_FILE_INITIALIZER;
+ if (mg_stat(conn, path, &file)) {
+ handle_file_request(conn, path, &file);
+ } else {
+ send_http_error(conn, 404, "Not Found", "%s", "File not found");
+ }
}
// Parse HTTP headers from the given buffer, advance buffer to the point
// where parsing stopped.
static void parse_http_headers(char **buf, struct mg_request_info *ri) {
- int i;
+ int i;
- for (i = 0; i < (int) ARRAY_SIZE(ri->http_headers); i++) {
- ri->http_headers[i].name = skip_quoted(buf, ":", " ", 0);
- ri->http_headers[i].value = skip(buf, "\r\n");
- if (ri->http_headers[i].name[0] == '\0')
- break;
- ri->num_headers = i + 1;
- }
+ for (i = 0; i < (int) ARRAY_SIZE(ri->http_headers); i++) {
+ ri->http_headers[i].name = skip_quoted(buf, ":", " ", 0);
+ ri->http_headers[i].value = skip(buf, "\r\n");
+ if (ri->http_headers[i].name[0] == '\0')
+ break;
+ ri->num_headers = i + 1;
+ }
}
static int is_valid_http_method(const char *method) {
- return !strcmp(method, "GET") || !strcmp(method, "POST") ||
- !strcmp(method, "HEAD") || !strcmp(method, "CONNECT") ||
- !strcmp(method, "PUT") || !strcmp(method, "DELETE") ||
- !strcmp(method, "OPTIONS") || !strcmp(method, "PROPFIND")
- || !strcmp(method, "MKCOL")
- ;
+ return !strcmp(method, "GET") || !strcmp(method, "POST") ||
+ !strcmp(method, "HEAD") || !strcmp(method, "CONNECT") ||
+ !strcmp(method, "PUT") || !strcmp(method, "DELETE") ||
+ !strcmp(method, "OPTIONS") || !strcmp(method, "PROPFIND")
+ || !strcmp(method, "MKCOL")
+ ;
}
// Parse HTTP request, fill in mg_request_info structure.
// This function modifies the buffer by NUL-terminating
// HTTP request components, header names and header values.
static int parse_http_message(char *buf, int len, struct mg_request_info *ri) {
- int is_request, request_length = get_request_len(buf, len);
- if (request_length > 0) {
- // Reset attributes. DO NOT TOUCH is_ssl, remote_ip, remote_port
- ri->remote_user = ri->request_method = ri->uri = ri->http_version = NULL;
- ri->num_headers = 0;
-
- buf[request_length - 1] = '\0';
-
- // RFC says that all initial whitespaces should be ingored
- while (*buf != '\0' && isspace(* (unsigned char *) buf)) {
- buf++;
- }
- ri->request_method = skip(&buf, " ");
- ri->uri = skip(&buf, " ");
- ri->http_version = skip(&buf, "\r\n");
- if (((is_request = is_valid_http_method(ri->request_method)) &&
- memcmp(ri->http_version, "HTTP/", 5) != 0) ||
- (!is_request && memcmp(ri->request_method, "HTTP/", 5)) != 0) {
- request_length = -1;
- } else {
- if (is_request) {
- ri->http_version += 5;
- }
- parse_http_headers(&buf, ri);
- }
- }
- return request_length;
+ int is_request, request_length = get_request_len(buf, len);
+ if (request_length > 0) {
+ // Reset attributes. DO NOT TOUCH is_ssl, remote_ip, remote_port
+ ri->remote_user = ri->request_method = ri->uri = ri->http_version = NULL;
+ ri->num_headers = 0;
+
+ buf[request_length - 1] = '\0';
+
+ // RFC says that all initial whitespaces should be ingored
+ while (*buf != '\0' && isspace(* (unsigned char *) buf)) {
+ buf++;
+ }
+ ri->request_method = skip(&buf, " ");
+ ri->uri = skip(&buf, " ");
+ ri->http_version = skip(&buf, "\r\n");
+ if (((is_request = is_valid_http_method(ri->request_method)) &&
+ memcmp(ri->http_version, "HTTP/", 5) != 0) ||
+ (!is_request && memcmp(ri->request_method, "HTTP/", 5)) != 0) {
+ request_length = -1;
+ } else {
+ if (is_request) {
+ ri->http_version += 5;
+ }
+ parse_http_headers(&buf, ri);
+ }
+ }
+ return request_length;
}
// Keep reading the input (either opened file descriptor fd, or socket sock,
@@ -3062,133 +3060,132 @@ static int parse_http_message(char *buf, int len, struct mg_request_info *ri) {
// have some data. The length of the data is stored in nread.
// Upon every read operation, increase nread by the number of bytes read.
static int read_request(FILE *fp, struct mg_connection *conn,
- char *buf, int bufsiz, int *nread) {
- int request_len, n = 0;
+ char *buf, int bufsiz, int *nread) {
+ int request_len, n = 0;
- request_len = get_request_len(buf, *nread);
- while (*nread < bufsiz && request_len == 0 &&
- (n = pull(fp, conn, buf + *nread, bufsiz - *nread)) > 0) {
- *nread += n;
- assert(*nread <= bufsiz);
- request_len = get_request_len(buf, *nread);
- }
+ request_len = get_request_len(buf, *nread);
+ while (*nread < bufsiz && request_len == 0 &&
+ (n = pull(fp, conn, buf + *nread, bufsiz - *nread)) > 0) {
+ *nread += n;
+ assert(*nread <= bufsiz);
+ request_len = get_request_len(buf, *nread);
+ }
- return request_len <= 0 && n <= 0 ? -1 : request_len;
+ return request_len <= 0 && n <= 0 ? -1 : request_len;
}
// For given directory path, substitute it to valid index file.
// Return 0 if index file has been found, -1 if not found.
// If the file is found, it's stats is returned in stp.
static int substitute_index_file(struct mg_connection *conn, char *path,
- size_t path_len, struct file *filep) {
- const char *list = conn->ctx->config[INDEX_FILES];
- struct file file = STRUCT_FILE_INITIALIZER;
- struct vec filename_vec;
- size_t n = strlen(path);
- int found = 0;
-
- // The 'path' given to us points to the directory. Remove all trailing
- // directory separator characters from the end of the path, and
- // then append single directory separator character.
- while (n > 0 && path[n - 1] == '/') {
- n--;
- }
- path[n] = '/';
-
- // Traverse index files list. For each entry, append it to the given
- // path and see if the file exists. If it exists, break the loop
- while ((list = next_option(list, &filename_vec, NULL)) != NULL) {
-
- // Ignore too long entries that may overflow path buffer
- if (filename_vec.len > path_len - (n + 2))
- continue;
-
- // Prepare full path to the index file
- mg_strlcpy(path + n + 1, filename_vec.ptr, filename_vec.len + 1);
-
- // Does it exist?
- if (mg_stat(conn, path, &file)) {
- // Yes it does, break the loop
- *filep = file;
- found = 1;
- break;
- }
- }
-
- // If no index file exists, restore directory path
- if (!found) {
- path[n] = '\0';
- }
-
- return found;
+ size_t path_len, struct file *filep) {
+ const char *list = conn->ctx->config[INDEX_FILES];
+ struct file file = STRUCT_FILE_INITIALIZER;
+ struct vec filename_vec;
+ size_t n = strlen(path);
+ int found = 0;
+
+ // The 'path' given to us points to the directory. Remove all trailing
+ // directory separator characters from the end of the path, and
+ // then append single directory separator character.
+ while (n > 0 && path[n - 1] == '/') {
+ n--;
+ }
+ path[n] = '/';
+
+ // Traverse index files list. For each entry, append it to the given
+ // path and see if the file exists. If it exists, break the loop
+ while ((list = next_option(list, &filename_vec, NULL)) != NULL) {
+ // Ignore too long entries that may overflow path buffer
+ if (filename_vec.len > path_len - (n + 2))
+ continue;
+
+ // Prepare full path to the index file
+ mg_strlcpy(path + n + 1, filename_vec.ptr, filename_vec.len + 1);
+
+ // Does it exist?
+ if (mg_stat(conn, path, &file)) {
+ // Yes it does, break the loop
+ *filep = file;
+ found = 1;
+ break;
+ }
+ }
+
+ // If no index file exists, restore directory path
+ if (!found) {
+ path[n] = '\0';
+ }
+
+ return found;
}
// Return True if we should reply 304 Not Modified.
static int is_not_modified(const struct mg_connection *conn,
- const struct file *filep) {
- char etag[64];
- const char *ims = mg_get_header(conn, "If-Modified-Since");
- const char *inm = mg_get_header(conn, "If-None-Match");
- construct_etag(etag, sizeof(etag), filep);
- return (inm != NULL && !mg_strcasecmp(etag, inm)) ||
- (ims != NULL && filep->modification_time <= parse_date_string(ims));
+ const struct file *filep) {
+ char etag[64];
+ const char *ims = mg_get_header(conn, "If-Modified-Since");
+ const char *inm = mg_get_header(conn, "If-None-Match");
+ construct_etag(etag, sizeof(etag), filep);
+ return (inm != NULL && !mg_strcasecmp(etag, inm)) ||
+ (ims != NULL && filep->modification_time <= parse_date_string(ims));
}
static int forward_body_data(struct mg_connection *conn, FILE *fp,
- SOCKET sock, SSL *ssl) {
- const char *expect, *body;
- char buf[MG_BUF_LEN];
- int to_read, nread, buffered_len, success = 0;
-
- expect = mg_get_header(conn, "Expect");
- assert(fp != NULL);
-
- if (conn->content_len == -1) {
- send_http_error(conn, 411, "Length Required", "%s", "");
- } else if (expect != NULL && mg_strcasecmp(expect, "100-continue")) {
- send_http_error(conn, 417, "Expectation Failed", "%s", "");
- } else {
- if (expect != NULL) {
- (void) mg_printf(conn, "%s", "HTTP/1.1 100 Continue\r\n\r\n");
- }
-
- body = conn->buf + conn->request_len + conn->consumed_content;
- buffered_len = &conn->buf[conn->data_len] - body;
- assert(buffered_len >= 0);
- assert(conn->consumed_content == 0);
-
- if (buffered_len > 0) {
- if ((int64_t) buffered_len > conn->content_len) {
- buffered_len = (int) conn->content_len;
- }
- push(fp, sock, ssl, body, (int64_t) buffered_len);
- conn->consumed_content += buffered_len;
- }
-
- nread = 0;
- while (conn->consumed_content < conn->content_len) {
- to_read = sizeof(buf);
- if ((int64_t) to_read > conn->content_len - conn->consumed_content) {
- to_read = (int) (conn->content_len - conn->consumed_content);
- }
- nread = pull(NULL, conn, buf, to_read);
- if (nread <= 0 || push(fp, sock, ssl, buf, nread) != nread) {
- break;
- }
- conn->consumed_content += nread;
- }
-
- if (conn->consumed_content == conn->content_len) {
- success = nread >= 0;
- }
-
- // Each error code path in this function must send an error
- if (!success) {
- send_http_error(conn, 577, http_500_error, "%s", "");
- }
- }
-
- return success;
+ SOCKET sock, SSL *ssl) {
+ const char *expect, *body;