aboutsummaryrefslogtreecommitdiff
path: root/project/src/lib-analyze.h
blob: 236bad3922be2e9bc9695588c2e002453c0f1ede (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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

/***************************************************************************
 *                         _______ _______ _______                         *
 *                        |  ___  |____   |  ___  |                        *
 *                        | |   |_|    / /| |   |_|                        *
 *                        | |_____    / / | |_____                         *
 *                        |_____  |  / /  |_____  |                        *
 *                         _    | | / /    _    | |                        *
 *                        | |___| |/ /____| |___| |                        *
 *                        |_______|_______|_______|                        *
 *                                                                         *
 *                            Wiimms SZS Tools                             *
 *                          https://szs.wiimm.de/                          *
 *                                                                         *
 ***************************************************************************
 *                                                                         *
 *   This file is part of the SZS project.                                 *
 *   Visit https://szs.wiimm.de/ for project details and sources.          *
 *                                                                         *
 *   Copyright (c) 2011-2024 by Dirk Clemens <wiimm@wiimm.de>              *
 *                                                                         *
 ***************************************************************************
 *                                                                         *
 *   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.                          *
 *                                                                         *
 *   See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt       *
 *                                                                         *
 ***************************************************************************/

#ifndef SZS_LIB_ANALYZE_H
#define SZS_LIB_ANALYZE_H 1

#define _GNU_SOURCE 1

#include "lib-std.h"
#include "lib-checksum.h"
#include "lib-lex.h"
#include "lib-szs.h"

//
///////////////////////////////////////////////////////////////////////////////
///////////////			analyze_param_t			///////////////
///////////////////////////////////////////////////////////////////////////////
// [[analyze_param_t]]

typedef struct analyze_param_t
{
    ccp			fname;		// NULL or source filename
    szs_file_t		szs;		// source file
    File_t		fo;		// output file
    PrintScript_t	ps;		// script options
}
analyze_param_t;

//-----------------------------------------------------------------------------

void PrintHeaderAP
(
    analyze_param_t	*ap,		// valid structure
    ccp			analyze		// analyzed object
);

void PrintFooterAP
(
    analyze_param_t	*ap,		// valid structure
    bool		valid,		// true if source is valid
    u_usec_t		duration_usec,	// 0 or duration of analysis
    ccp			warn_format,	// NULL or format for warn message
    ...					// arguments for 'warn_format'
) __attribute__ ((__format__(__printf__,4,5)));

//
///////////////////////////////////////////////////////////////////////////////
///////////////			analyze_szs_t			///////////////
///////////////////////////////////////////////////////////////////////////////
// [[analyze_szs_t]]

typedef struct analyze_szs_t
{
    //--- db+sha1 check sums

    char	db64[CHECKSUM_DB_SIZE+1];
					// DB64 checksum
    sha1_hex_t	sha1_szs;		// SHA1 of SZS file
    sha1_hex_t	sha1_szs_norm;		// SHA1 of normed SZS file
    sha1_hex_t	sha1_kmp;		// SHA1 of KMP file
    sha1_hex_t	sha1_kmp_norm;		// SHA1 of normed KMP file
    sha1_hex_t	sha1_kcl;		// SHA1 of KCL file
    sha1_hex_t	sha1_course;		// SHA1 of course-model
    sha1_hex_t	sha1_vrcorn;		// SHA1 of vrcorn
    sha1_hex_t	sha1_minimap;		// SHA1 of minimap


    //--- slots of original tracks: 0:none, 11..84:versus 111..125:arena

    u8		sha1_kmp_slot;
    u8		sha1_kmp_norm_slot;
    u8		sha1_kcl_slot;
    u8		sha1_minimap_slot;


    //--- sub files

    lex_info_t		lexinfo;	// LEX info
    slot_ana_t		slotana;	// slot data
    slot_info_t		slotinfo;	// slot data
    kmp_finish_t	kmp_finish;	// finish line
    kmp_usedpos_t	used_pos;	// used positions
    szs_have_t		have;		// complete have status, copy of szs_file_t::have


    //--- ct id

    uint		ctid_list;	// id by --id-list
    uint		ctid_attrib;	// id by attribute


    //--- more stats

    int		ckpt0_count;		// number of LC in CKPT, -1 unknown
    int		lap_count;		// STGI lap counter
    float	speed_factor;		// STGI speed factor
    u16		speed_mod;		// STGI speed mod
    u8		have_common;		// 1: found at least one common file
    u8		valid_track;		// 1: valid track or arena file

    char	gobj_info[20];		// gobj counters
    char	ct_attrib[300];		// collected ct attributes

    u_usec_t	duration_usec;		// duration of AnalyzeSZS() in usec
}
analyze_szs_t;

//-----------------------------------------------------------------------------

void InitializeAnalyzeSZS ( analyze_szs_t * as );
void ResetAnalyzeSZS ( analyze_szs_t * as );

void AnalyzeSZS
(
    analyze_szs_t	*as,		// result
    bool		init_sa,	// true: init 'as', false: reset 'as'
    szs_file_t		*szs,		// SZS file to analysze
    ccp			fname		// NULL or fname for slot analysis
);

uint GetCtIdByList ( sha1_hex_t sha1 );

//
///////////////////////////////////////////////////////////////////////////////
///////////////			exec analyze			///////////////
///////////////////////////////////////////////////////////////////////////////

enumError ExecAnalyzeSZS	( analyze_param_t *ap );
enumError ExecAnalyzeLECODE	( analyze_param_t *ap );

//
///////////////////////////////////////////////////////////////////////////////
///////////////			    END				///////////////
///////////////////////////////////////////////////////////////////////////////

#endif // SZS_LIB_ANALYZE_H