-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdata_generator.c
More file actions
executable file
·112 lines (106 loc) · 4.26 KB
/
data_generator.c
File metadata and controls
executable file
·112 lines (106 loc) · 4.26 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*******************************************************************************
*
* File Name: data_generator.c
* Revision: 1.0
* Date: August, 2006
* Email: nandsupport@micron.com
* Company: Micron Technology, Inc.
*
* Description: HEX data generator
* Generate regular bytes 1111 2222 3333 4444 ....
* for easy checking of decoding result
* or random data can be generated by random mode
**
* Disclaimer This software code and all associated documentation, comments or other
* of Warranty: information (collectively "Software") is provided "AS IS" without
* warranty of any kind. MICRON TECHNOLOGY, INC. ("MTI") EXPRESSLY
* DISCLAIMS ALL WARRANTIES EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO, NONINFRINGEMENT OF THIRD PARTY RIGHTS, AND ANY IMPLIED WARRANTIES
* OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. MTI DOES NOT
* WARRANT THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS, OR THAT THE
* OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE.
* FURTHERMORE, MTI DOES NOT MAKE ANY REPRESENTATIONS REGARDING THE USE OR
* THE RESULTS OF THE USE OF THE SOFTWARE IN TERMS OF ITS CORRECTNESS,
* ACCURACY, RELIABILITY, OR OTHERWISE. THE ENTIRE RISK ARISING OUT OF USE
* OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU. IN NO EVENT SHALL MTI,
* ITS AFFILIATED COMPANIES OR THEIR SUPPLIERS BE LIABLE FOR ANY DIRECT,
* INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES (INCLUDING,
* WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION,
* OR LOSS OF INFORMATION) ARISING OUT OF YOUR USE OF OR INABILITY TO USE
* THE SOFTWARE, EVEN IF MTI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGES. Because some jurisdictions prohibit the exclusion or
* limitation of liability for consequential or incidental damages, the
* above limitation may not apply to you.
*
* Copyright 2006 Micron Technology, Inc. All rights reserved.
*
*
* Rev Author Date Changes
* --- --------------- ---------- -------------------------------
* 1.0 ZS 08/07/2006 Initial release
*
*
/*******************************************************************************
*/
#include "bch_global.c"
int main(int argc, char** argv)
{ int n ; // Length of generated data in bytes
int i, Temp ;
int Help;
int Random ; // Random mode
if (argc == 1)
{
fprintf(stderr, "# Data generator. Use -h for details.\n\n");
return(-1);
}
Random = 0;
Help = 0;
n = 64 ;
for (i=1; i < argc;i++)
{ if (argv[i][0] == '-')
{ switch (argv[i][1])
{ case 'n': n = atoi(argv[++i]);
break;
case 'r': Random = 1;
break;
default: Help = 1;
}
}
else
Help = 1;
}
if (Help == 1)
{ fprintf(stdout,"# Usage %s: BCH data generator\n",argv[0]);
fprintf(stdout," -h: This help message\n");
fprintf(stdout," -n <bytes>: Number of bytes that will be generated. Default = %d \n", n);
fprintf(stdout," Output is 2*n HEX regular characters.\n");
fprintf(stdout," -r Random mode generator. Will output random HEX characters.\n");
fprintf(stdout," <stdout>: resulting generated character string in hex format.\n");
fprintf(stdout," <stderr>: information about the generation process as well as error messages\n");
fprintf(stdout," Example: ./data -n 2048 > data_in.txt\n");
}
else
{ if (Random == 0)
{ fprintf(stdout, "{ Regular mode generator.}\n");
fprintf(stdout, "{ %d bytes generated.}\n\n", n);
for (i = 1; i <= n/2 ; i++)
{ Temp = inttohex(i % 16);
fprintf(stdout, "%c%c%c%c", Temp, Temp, Temp, Temp );
if (i%16 ==0 )
fprintf(stdout, "\n");
}
}
else
{ fprintf(stdout, "{ Random mode generator.}\n");
fprintf(stdout, "{ %d bytes generated.}\n\n", n);
for (i = 1; i <= n * 2 ; i++)
{ Temp = rand() % 16 ;
Temp = inttohex(Temp);
fprintf(stdout, "%c", Temp );
if (i%64 ==0 )
fprintf(stdout, "\n");
}
}
}
return(0);
}