Skip to content

Commit

Permalink
Allow to download complete disk images (incl. custom config file) bes…
Browse files Browse the repository at this point in the history
…ide the pure custom config file. Is this kind of a hack as there are no disk image utilities used. Instead the offsets to the config file content in the current example-webserver disk image files is hardcoded into the PHP source code. As soon as the disk images change the offsets need to be adjusted.
  • Loading branch information
oliverschmidt committed Jun 7, 2008
1 parent a4d1c62 commit c7b6364
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
20 changes: 18 additions & 2 deletions tools/6502/contiki.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</head>
<body>
<form action="download.php">
<h4 align="center">Download your custom generated Contiki configuration</h4>
<h4 align="center">Download your custom generated Contiki</h4>
<table align="center" cellpadding="0" cellspacing="0">
<tr class="p">
<td>
Expand Down Expand Up @@ -103,6 +103,22 @@ <h4 align="center">Download your custom generated Contiki configuration</h4>
</td>
</tr><tr class="bg">
<td colspan="3" />
</tr><tr class="p">
<td colspan="3">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="radio" name="disk" id="disk" value="1" checked="checked" />
<label for="disk">Complete Disk Image</label>
</td><td align="right">
<input type="radio" name="disk" id="conf" value="0" />
<label for="conf">Configuration File Only</label>
</td>
</tr>
</table>
</td>
</tr><tr class="bg">
<td colspan="3" />
</tr><tr class="p">
<td colspan="3" align="center">
<input type="submit" value="Download" />
Expand All @@ -111,4 +127,4 @@ <h4 align="center">Download your custom generated Contiki configuration</h4>
</table>
</form>
</body>
</html>
</html>
19 changes: 16 additions & 3 deletions tools/6502/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,36 @@
case "apple2":
$hex = $_GET['apple2-addr'];
$drv = $_GET['apple2-drv'];
$ext = 'dsk';
$ofs = 0x0B500;
break;
case "c64":
$hex = strtok($_GET['c64-addr-drv'], '-');
$drv = strtok('-');
$ext = 'd64';
$ofs = 0x17802;
break;
case "c128":
$hex = strtok($_GET['c128-addr-drv'], '-');
$drv = strtok('-');
$ext = 'd71';
$ofs = 0x17802;
break;
}

$addr = hexdec($hex);
$cfg .= chr($addr % 0x100).chr($addr / 0x100);
$cfg .= $drv;

if ($_GET['disk']) {
$out = substr_replace(file_get_contents('contiki.' . $ext), $cfg, $ofs, strlen($cfg));
} else {
$ext = 'cfg';
$out = $cfg;
}

header('Content-Type: application/octetstream');
header('Content-Disposition: attachment; filename=contiki.cfg');
print($cfg);
header('Content-Disposition: attachment; filename=contiki.' . $ext);
print($out);

?>
?>

0 comments on commit c7b6364

Please sign in to comment.