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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* -*-c-*- -------------- mix_device_t.c :
* Implementation of the functions declared in mix_device_t.h
* ------------------------------------------------------------------
* Copyright (C) 2000 Free Software Foundation, Inc.
*
* This program is free software; 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <stdlib.h>
#include <mix_device.h>
/* Define VERBOSE_TEST if you want to get prints of the test */
/* #define VERBOSE_TEST */
#include "test.h"
static int S_ = MIX_CHAR_MAX +1;
int
main (int argc, char **argv)
{
mix_device_t *console;
size_t s;
mix_word_t **block;
mix_char_t mchars[S_];
gchar chars[S_];
int i, j;
int bno;
INIT_TEST;
console = mix_device_new (mix_dev_CONSOLE);
s = mix_device_block_size (console);
bno = S_/(s*5);
if (bno == 0) bno = 1;
block = g_new (mix_word_t *, bno);
for (i = 0; i < bno; ++i)
block[i] = g_new (mix_word_t, s);
for (i = 0; i < S_; ++i) {
chars[i] = mix_char_to_ascii (i);
mchars[i] = mix_ascii_to_char (chars[i]);
g_assert (mchars[i] == i);
}
for (i = 0; i < bno; ++i) {
for (j = 0; j < s; ++j) {
int n = i*s + 5*j;
if (n < S_)
block[i][j] = mix_bytes_to_word (mchars + n, 5);
else
block[i][j] = 0;
}
}
for (i = 0; i < bno; ++i) {
mix_device_write (console, block[i]);
}
return EXIT_SUCCESS;
}
|