-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
hddscviewer3.h
executable file
·577 lines (477 loc) · 15.8 KB
/
hddscviewer3.h
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
// Copyright (C) 2015-2022 Scott Dwyer.
// You may use/distribute/modify this freely, under the terms of
// the GNU General Public License version 2 or later version.
// This software is distributed WITHOUT ANY WARRANTY.
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <math.h>
#include <malloc.h>
#include <gtk/gtk.h>
#include <cairo.h>
#include "conditional.h"
#ifdef DEBUG
#include <curl/curl.h>
#endif
#include <sys/stat.h>
#define LANGFILE 0
#define LANGQUIT 1
#define LANGOPEN 2
#define LANGERROR 3
#define LANGWARN 4
#define LANGLANGUAGE 5
#define LANGEXPORTLANG 6
#define LANGIMPORTLANG 7
#define LANGLANGEXPORTERR 8
#define LANGLANGIMPORTERR 9
#define LANGLANGIMPORTERR2 10
#define LANGLANGCHANGESUCCESS 11
#define LANGSUCCESS 12
#define LANGOPTIONS 13
#define LANGLEFTRES 14
#define LANGMAINRES 15
#define LANGMAINSIZE 16
#define LANGAUTOUPDATE 17
#define LANGSHOWBADHEAD 18
#define LANGNONTRIMMED 19
#define LANGNONDIVIDED 20
#define LANGNONSCRAPED 21
#define LANGBAD 22
#define LANGNONTRIED 23
#define LANGFINISHED 24
#define LANGCURRENT 25
#define LANGBADHEAD 26
#define LANG1PT 27
#define LANG2PT 28
#define LANG3PT 29
#define LANG4PT 30
#define LANG6PT 31
#define LANG8PT 32
#define LANG10PT 33
#define LANG12PT 34
#define LANG14PT 35
#define LANG16PT 36
#define LANG4K 37
#define LANG8K 38
#define LANG16K 39
#define LANG32K 40
#define LANG64K 41
#define LANG128K 42
#define LANG256K 43
#define LANG512K 44
#define LANG1M 45
#define LANGOFF 46
#define LANG5SEC 47
#define LANG10SEC 48
#define LANG30SEC 49
#define LANG1MIN 50
#define LANG2MIN 51
#define LANG5MIN 52
#define LANGSHOWGOODDATA 53
#define LANGGOODDATA 54
#define LANG2M 55
#define LANG4M 56
#define LANG8M 57
#define LANG16M 58
// TODO MAKE SURE TO UPDATE COUNT EVERY TIME! it should be one more than last defined
#define LANGCOUNT 428
#define MAXLANGLENGTH 2048
char enlang[LANGCOUNT][MAXLANGLENGTH];
char curlang[LANGCOUNT][MAXLANGLENGTH];
char newlang[LANGCOUNT][MAXLANGLENGTH];
char program_title[256];
GtkWidget *filelangex;
GtkWidget *filelangim;
int setup_enlanguage(void);
int copy_enlanguage(void);
int copy_newlanguage(void);
#define TRANSLATETIMERALL 1000000000 // nanosecond delay for every translate call
#define TRANSLATETIMERFAST 10000000000 // nanosecond delay for each normal translate call
#define TRANSLATETIMERSLOW 2000000000 // nanosecond delay for each slow translate call
#define BLACK 0x000000 // (0,0,0)
#define WHITE 0xFFFFFF // (255,255,255)
#define RED 0xFF0000 // (255,0,0)
#define LIME 0x00FF00 // (0,255,0)
#define BLUE 0x0000FF // (0,0,255)
#define YELLOW 0xFFFF00 // (255,255,0)
#define CYAN 0x00FFFF // (0,255,255)
#define MAGENTA 0xFF00FF // (255,0,255)
#define SILVER 0xC0C0C0 // (192,192,192)
#define GRAY 0x808080 // (128,128,128)
#define MAROON 0x800000 // (128,0,0)
#define OLIVE 0x808000 // (128,128,0)
#define GREEN 0x008000 // (0,128,0)
#define PURPLE 0x800080 // (128,0,128)
#define TEAL 0x008080 // (0,128,128)
#define NAVY 0x000080 // (0,0,128)
#define ORANGE 0xFFA500 // (255,165,0)
#define MYBLUE 0x0080FF // (0,128,255)
#define MYORANGE 0xFF8000 // (255,128,0)
#define NONTRIED 0
#define NONTRIMMED 0x10
#define NONDIVIDED 0x20
#define NONSCRAPED 0x30
#define BAD 0x40
#define BAD_HEAD 0x80
#define FINISHED 0x7f
#define NONTRIED_BIT 0x0001
#define NONTRIMMED_BIT 0x0002
#define NONDIVIDED_BIT 0x0004
#define NONSCRAPED_BIT 0x0008
#define BAD_BIT 0x0010
#define BAD_HEAD_BIT 0x0020
#define FINISHED_BIT 0x0040
#define UNKNOWN_BIT 0x0080
#define MAINWINDOWWIDTH 800
#define MAINWINDOWHEIGTH 600
#define LEFTSQUARESIZE 2
#define MAINSQUARESIZE 8
#define MAINGRIDSIZE 65536
#define DISPLAY_MESSAGE_SIZE 4096
#define EXIT_MESSAGE_SIZE 2048
#define TEMP_MESSAGE_SIZE 32768
#define DEBUG_MESSAGE_SIZE 4096
#define ERROR_MESSAGE_SIZE 1024
#define MAX_LINE_LENGTH 256
gint main_window_width = MAINWINDOWWIDTH;
gint main_window_height = MAINWINDOWHEIGTH;
gint main_vbox_width;
gint main_vbox_height;
gint main_hbox_width;
gint main_hbox_height;
gint left_vbox_width;
gint left_vbox_height;
gint right_vbox_width;
gint right_vbox_height;
gint top_hbox_width;
gint top_hbox_height;
gint top_info_box_width;
gint top_info_box_height;
gint top_drawing_area_width;
gint top_drawing_area_height;
gint main_drawing_area_width;
gint main_drawing_area_height;
gint left_drawing_area_width;
gint left_drawing_area_height;
gint main_scrolled_window_width;
gint main_scrolled_window_height;
gint main_drawing_vbox_width;
gint main_drawing_vbox_height;
gdouble scroll_position;
gint last_main_window_width = 0;
gint last_main_window_height = 0;
gint last_main_vbox_width = 0;
gint last_main_vbox_height = 0;
gint last_main_hbox_width = 0;
gint last_main_hbox_height = 0;
gint last_left_vbox_width = 0;
gint last_left_vbox_height = 0;
gint last_right_vbox_width = 0;
gint last_right_vbox_height = 0;
gint last_top_hbox_width = 0;
gint last_top_hbox_height = 0;
gint last_top_info_box_width = 0;
gint last_top_info_box_height = 0;
gint last_top_drawing_area_width = 0;
gint last_top_drawing_area_height = 0;
gint last_main_drawing_area_width = 0;
gint last_main_drawing_area_height = 0;
gint last_left_drawing_area_width = 0;
gint last_left_drawing_area_height = 0;
gint last_main_scrolled_window_width = 0;
gint last_main_scrolled_window_height = 0;
gint last_main_drawing_vbox_width = 0;
gint last_main_drawing_vbox_height = 0;
gdouble last_scroll_position = 0;
GtkWidget *language_window;
GtkWidget *main_window;
GtkWidget *main_vbox;
GtkWidget *main_hbox;
GtkWidget *left_vbox;
GtkWidget *right_vbox;
GtkWidget *top_hbox;
GtkWidget *top_info_box;
GtkWidget *top_drawing_area;
GtkWidget *main_drawing_area;
GtkWidget *left_drawing_area;
GtkWidget *main_scrolled_window;
GtkWidget *main_drawing_vbox;
GtkWidget *frame;
// menu items
GtkWidget *menubar;
GtkWidget *menuvbox;
GtkWidget *menuseparater;
// file menu
GtkWidget *filemenu;
GtkWidget *filemi;
GtkWidget *quitmi;
GtkWidget *openmi;
GtkWidget *filew;
//options menu
GtkWidget *optionsmenu;
GtkWidget *optionsmi;
GtkWidget *leftresmenu;
GtkWidget *leftresolutionmi;
GtkWidget *leftresbutton1;
GtkWidget *leftresbutton2;
GtkWidget *leftresbutton3;
GtkWidget *leftresbutton4;
GtkWidget *mainresmenu;
GtkWidget *mainresolutionmi;
GtkWidget *mainresbutton4;
GtkWidget *mainresbutton6;
GtkWidget *mainresbutton8;
GtkWidget *mainresbutton10;
GtkWidget *mainresbutton12;
GtkWidget *mainresbutton14;
GtkWidget *mainresbutton16;
GtkWidget *maingridsizemi;
GtkWidget *mainsizemenu;
GtkWidget *mainsizebutton4k;
GtkWidget *mainsizebutton8k;
GtkWidget *mainsizebutton16k;
GtkWidget *mainsizebutton32k;
GtkWidget *mainsizebutton64k;
GtkWidget *mainsizebutton128k;
GtkWidget *mainsizebutton256k;
GtkWidget *mainsizebutton512k;
GtkWidget *mainsizebutton1m;
GtkWidget *mainsizebutton2m;
GtkWidget *mainsizebutton4m;
GtkWidget *mainsizebutton8m;
GtkWidget *mainsizebutton16m;
GtkWidget *autoupdatemi;
GtkWidget *autoupdatemenu;
GtkWidget *autoupdatebuttonoff;
GtkWidget *autoupdatebutton5s;
GtkWidget *autoupdatebutton10s;
GtkWidget *autoupdatebutton30s;
GtkWidget *autoupdatebutton1m;
GtkWidget *autoupdatebutton2m;
GtkWidget *autoupdatebutton5m;
GtkWidget *showbadcheck;
GtkWidget *optionsw;
GSList *leftresgroup = NULL;
GSList *mainresgroup = NULL;
GSList *mainsizegroup = NULL;
GSList *autoupgroup = NULL;
GtkWidget *showgoodcheck;
int debug = 0;
int translate = 0;
char exit_message[EXIT_MESSAGE_SIZE];
char display_message[DISPLAY_MESSAGE_SIZE];
char tempmessage[TEMP_MESSAGE_SIZE];
char debug_message[DEBUG_MESSAGE_SIZE];
char error_message[ERROR_MESSAGE_SIZE];
char log_file[1024];
int log_rows = 1000;
int total_lines = 0;
long long *lposition;
long long *lsize;
long long *lstatus;
long long *temp_lposition;
long long *temp_lsize;
long long *temp_lstatus;
long long current_position = 0;
long long current_status = 0;
long long total_size = 0;
double rcolor = 0;
double gcolor = 0;
double bcolor = 0;
int left_square_size = LEFTSQUARESIZE;
int main_square_size = MAINSQUARESIZE;
int square_adjust = 0;
int nontried_color = BLACK;
int nontrimmed_color = SILVER;
int nondivided_color = GRAY;
int nonscraped_color = MYBLUE;
int bad_color = RED;
int good_color = LIME;
int unknown_color = BLACK;
int current_color_outer = YELLOW;
int current_color_inner = YELLOW;
int bad_head_color = PURPLE;
int selected_color = WHITE;
int main_grid_size = MAINGRIDSIZE;
gint timeout_tag = 0;
int autotimer_on = 0;
int show_bad_head = 0;
int show_good_data = 0;
int mouse_x = 0;
int mouse_y = 0;
int mouse_x_old = 0;
int mouse_y_old = 0;
int redraw_count = 0;
void help(void);
void version(void);
gint update_action (gconstpointer data);
void update_size_variables(void);
void compare_size_variables(void);
static gboolean on_button_press(const GtkWidget* widget, GdkEventButton *event, GdkWindowEdge edge);
static gboolean main_drawing_expose_event(const GtkWidget *widget, const GdkEventExpose *event, gpointer data);
static gboolean left_vbox_expose_event(const GtkWidget *widget, const GdkEventExpose *event, gpointer data);
static gboolean top_drawing_expose_event(const GtkWidget *widget, const GdkEventExpose *event, gpointer data);
void getsize_main_window(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_main_vbox(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_main_hbox(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_left_vbox(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_right_vbox(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_top_hbox(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_top_info_box(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_top_drawing_area(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_main_drawing_area(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_left_drawing_area(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_main_drawing_vbox(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void getsize_main_scrolled_window(const GtkWidget *widget, const GtkAllocation *allocation, const void *data);
void change_main_resolution(const GtkWidget *w, gpointer data);
void change_main_grid_size(const GtkWidget *w, gpointer data);
void redraw_main_drawing_area(void);
void redraw_top_drawing_area(void);
void change_left_resolution(const GtkWidget *w, gpointer data);
void redraw_left_vbox(void);
int initialize_memory(void);
int increase_log_memory(int new_lines);
int message_exit(char *message);
int message_display(char *message);
int message_now(char *message);
int message_debug(char *message, int level);
int message_error(char *message);
int clear_error_message(void);
int read_log_file(char *log_file);
gint reload_file(gpointer user_data);
void set_autoupdate_timer(const GtkWidget *w, gpointer data);
void toggle_showbad(const GtkWidget *w, gpointer data);
void toggle_showgood(const GtkWidget *w, gpointer data);
int check_log(void);
void select_file(void);
void get_rgb_color(int color);
int get_color_from_status(int status_bits);
int get_block_status(long long position, long long size);
int find_block(long long position);
int process_status(int line);
int do_nanosleep(unsigned long long time);
int set_language(void);
int print_gui_error_message(char *message, char *title, int type);
void import_language_file(void);
static void file_import_sel( char *import_file );
int translate_all(void);
int translate_language(char *fromlang, char *translang, const char *language, const char *native);
int translate_language_slow(char *fromlang, char *translang, const char *language, const char *native);
char* get_translated_data(char *url_data);
struct MemoryStruct {
char *memory;
size_t size;
};
char * languages[] = {
// "Afrikaans","af","Afrikaans",
// "Albanian","sq","shqiptar",
// "Amharic","am","አማርኛ",
"Arabic","ar","عربى",
// "Armenian","hy","հայերեն",
// "Azeerbaijani","az","Azeerbaijani",
// "Basque","eu","Euskal",
// "Belarusian","be","беларускі",
// "Bengali","bn","বাঙালি",
// "Bosnian","bs","bosanski",
// "Bulgarian","bg","български",
// "Catalan","ca","català",
// "Cebuano","ceb","Cebuano",
// "Chichewa","ny","Chichewa",
"Chinese (Simplified)","zh-CN","简体中文)",
// "Chinese (Traditional)","zh-TW","中國傳統的)",
// "Corsican","co","Corsu",
// "Croatian","hr","hrvatski",
// "Czech","cs","čeština",
// "Danish","da","dansk",
// "Dutch","nl","Nederlands",
// "Esperanto","eo","Esperanto",
// "Estonian","et","eesti",
// "Filipino","tl","Pilipino",
// "Finnish","fi","Suomalainen",
"French","fr","français",
// "Frisian","fy","Frysk",
// "Galician","gl","galego",
// "Georgian","ka","ქართული",
"German","de","Deutsch",
// "Greek","el","Ελληνικά",
// "Gujarati","gu","ગુજરાતી",
// "Haitian Creole","ht","kreyòl ayisyen",
// "Hausa","ha","Hausa",
// "Hawaiian","haw","ʻŌlelo Hawaiʻi",
// "Hebrew","iw","עִברִית",
"Hindi","hi","हिंदी",
// "Hmong","hmn","Hmong",
// "Hungarian","hu","Magyar",
// "Icelandic","is","icelandic",
// "Igbo","ig","Igbo",
"Indonesian","id","bahasa Indonesia",
// "Irish","ga","Gaeilge",
"Italian","it","italiano",
"Japanese","ja","日本語",
// "Javanese","jw","Jawa",
// "Kannada","kn","ಕನ್ನಡ",
// "Kazakh","kk","Қазақ",
// "Khmer","km","ភាសាខ្មែរ",
// "Korean","ko","한국어",
// "Kurdish","ku","Kurdî",
// "Kyrgyz","ky","Кыргызча",
// "Lao","lo","ລາວ",
// "Latin","la","Latine",
// "Latvian","lv","Latvijas",
// "Lithuanian","lt","Lietuvos",
// "Luxembourgish","lb","lëtzebuergesch",
// "Macedonian","mk","Македонски",
// "Malagasy","mg","Malagasy",
// "Malay","ms","Malay",
// "Malayalam","ml","മലയാളം",
// "Maltese","mt","Malti",
// "Maori","mi","Maori",
// "Marathi","mr","मराठी",
// "Mongolian","mn","Монгол",
// "Burmese","my","မြန်မာ",
// "Nepali","ne","नेपाली",
// "Norwegian","no","norsk",
// "Pashto","ps","پښتو",
// "Persian","fa","فارسی",
// "Polish","pl","Polskie",
"Portuguese","pt","Português",
// "Punjabi","pa","ਪੰਜਾਬੀ",
// "Romanian","ro","Română",
"Russian","ru","русский",
// "Samoan","sm","Samoa",
// "Scots Gaelic","gd","Gàidhlig",
// "Serbian","sr","Српски",
// "Sesotho","st","Sesotho",
// "Shona","sn","Shona",
// "Sindhi","sd","سنڌي",
// "Sinhala","si","සිංහල",
// "Slovak","sk","slovenský",
// "Slovenian","sl","slovenski",
// "Somali","so","Soomaali",
"Spanish","es","Español",
// "Sundanese","su","Sunda",
// "Swahili","sw","Kiswahili",
// "Swedish","sv","svenska",
// "Tajik","tg","Тоҷикистон",
// "Tamil","ta","தமிழ்",
// "Telugu","te","తెలుగు",
// "Thai","th","ไทย",
// "Turkish","tr","Türk",
// "Ukrainian","uk","український",
// "Urdu","ur","اردو",
// "Uzbek","uz","O'zbekiston",
// "Vietnamese","vi","Tiếng Việt",
// "Welsh","cy","Cymraeg",
// "Xhosa","xh","isiXhosa",
// "Yiddish","yi","ייִדיש",
// "Yoruba","yo","yorùbá",
// "Zulu","zu","Zulu"
};
#define n_languages (sizeof (languages) / sizeof (const char *))