aboutsummaryrefslogtreecommitdiff
path: root/xop.c
blob: f2b6748309b84ccc91d08fa683b239b564589288 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/// __  _____  _ __
/// \ \/ / _ \| '_ \
///  >  < (_) | |_) |
/// /_/\_\___/| .__/
///           |_|
///
/// Copyright (c) 1997 - Ognjen 'xolatile' Milan Robovic
///
/// xolatile@chud.cyou - xop - The evil within...
///
/// This program is free software, free as in freedom and as in free beer, you can redistribute it and/or modify it under the terms of the GNU
/// General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version if you wish...
///
/// This program is distributed in the hope that it will be useful, but it is probably not, and without any warranty, without even the implied
/// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License
/// for more details, if you dare, it is a lot of text that nobody wants to read...

#include "xtandard.h"

static procedure echo_byte (natural_8 byte) {
	output ("0123456789ABCDEF" + byte / 16, 1);
	output ("0123456789ABCDEF" + byte % 16, 1);

	output (" ", 1);
}

integer main (integer argc, character * * argv) {
	integer      file   = 0;
	natural_64   size   = 0;
	natural_8  * buffer = null;

	if (argc != 2) {
		return (log_failure);
	}

	file = file_open (argv [1], file_flag_read);
	size = file_size (argv [1]);

	buffer = allocate (size * sizeof (* buffer));

	file_read (file, buffer, size);

	file = file_close (file);

	for (natural_64 offset = 0; offset < size; ++offset) {
		conditional_print (buffer [offset] == 0x90, "\n/B/1");

		echo_byte (buffer [offset]);

		conditional_print (buffer [offset] == 0x90, "/-");
	}

	print ("\n");

	buffer = deallocate (buffer);

	return (log_success);
}