-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
80 lines (61 loc) · 2.08 KB
/
util.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
/***************************************************************************
* util.h
*
* Tue November 22 21:23:11 2011
* Copyright 2011 Armin Diehl
****************************************************************************/
/*
* util.h
*
* Copyright (C) 2011 - Armin Diehl
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTIL_H
#define UTIL_H
#include <stdint.h>
#define KEY_ESC 27
#define KEY_ENTER 13
#define KEY_BS 8
#define KEY_DEL 0x7f
/* convert hex str to unsigned int, max 32 bit
returns 1 on succsess */
int xtoui(const char* xs, unsigned int* result);
void kb_normal(void);
void kb_raw(void);
/* returns 1 if console key is available */
int kbhit(void);
/* return one character from console without echo */
int getch(void);
/* Input string from console, input terminated by
* any char in exitChars */
char inputString (char * s, int maxLen, const char * exitChars);
/* returns hex digit for lower 4 bits */
char hexNibble (unsigned int i);
/* 1 if file or directory exists */
int file_exists(char * filename);
/* 1 if it is a directory */
int is_directory(char * filename);
/* -1 on error */
int file_getSize(char * filename);
/* convert string to upper case */
void strupper(char *str);
/* return pointer to end of string (the null char) */
char * strend(char *str);
void bufAddHex1 (char * dest, int data);
void bufAddHex2 (char * dest, int data);
int hex2int(char *hex, int numBytes);
void getStringFromHex(char *src, char *dst, int numChars);
#endif