-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstr.c51
More file actions
114 lines (98 loc) · 4.48 KB
/
str.c51
File metadata and controls
114 lines (98 loc) · 4.48 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
113
114
/////////////////////////////////////////////////////////////////////////////
// +---------------------------------------------------------------------+ //
// | String utils | //
// | -------------------------------- | //
// | Version 1.02 | //
// | | //
// | Copyright Tomas Hujer | //
// | (c) 2005-2007 | //
// | thomas.hoodger(at)gmail.com | //
// +---------------------------------------------------------------------+ //
// //
// Version history //
// //
// ---------------------------------------------- //
// 1.02 Pridana funkce pro porovnani retezcu //
// ---------------------------------------------- //
// //
// ----------------------------------------------------------------------- //
/////////////////////////////////////////////////////////////////////////////
#pragma LIST
#pragma PAGELENGTH(30000);
#pragma LINES
#define uchar unsigned char
#define uint unsigned int
// ---------------------------------------------------------------------------
// +------------------------------------------------------------------------+
// | Konverze znaku na velky |
// +------------------------------------------------------------------------+
// | Vrati velke pismeno znaku ch |
// +------------------------------------------------------------------------+
uchar str_up_char(uchar ch)
{
if((ch>='a') &&
(ch<='z'))
return(ch & (255-32));
else
return(ch);
}
// +------------------------------------------------------------------------+
// | Vymazani bufferu |
// +------------------------------------------------------------------------+
// | Vynuluje pocet byte Bytes na ukazateli *buf |
// +------------------------------------------------------------------------+
void str_reset_buffer(uchar *buf, uint bytes)
{
uchar i;
for(i=0; i < bytes; i++)
buf[i]=0;
}
// +------------------------------------------------------------------------+
// | Detekce znaku - cislice |
// +------------------------------------------------------------------------+
// | Je-li znak cislice vrati 1 |
// +------------------------------------------------------------------------+
uchar str_is_num(uchar ch)
{
if((ch >= '0') &&
(ch <= '9'))
return(1);
else
return(0);
}
// +------------------------------------------------------------------------+
// | Porovnani retezce |
// +------------------------------------------------------------------------+
// | Pokud si Bytes znaku v retezcich Ptr1 a Ptr2 odpovida vrati 1 |
// +------------------------------------------------------------------------+
bit str_cmp(uchar *ptr1, uchar *ptr2)
{
uchar i=0;
bit out=0;
//while(ptr1[i] && ptr2[i])
while(ptr2[i])
{
out=1;
if(str_up_char(ptr1[i]) != str_up_char(ptr2[i]))
{
out=0;
break;
}
i++;
}
return(out);
}
// +------------------------------------------------------------------------+
// | Detekce hex cisla |
// +------------------------------------------------------------------------+
// | Je-li byte hex cislo, vraci 1 |
// +------------------------------------------------------------------------+
/*
bit is_hex(char byte)
{
if(((up_char(byte) >= 'A') && (up_char(byte) <='F')) || ((byte >= '0') && (byte <= '9')))
return(1);
else
return(0);
}
*/