/[dtapublic]/projs/dtats/trunk/shared_source/c_datd/charfunc.c
ViewVC logotype

Annotation of /projs/dtats/trunk/shared_source/c_datd/charfunc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (hide annotations) (download)
Sat Oct 29 01:53:01 2016 UTC (8 years ago) by dashley
Original Path: projs/trunk/shared_source/c_datd/charfunc.c
File MIME type: text/plain
File size: 4022 byte(s)
License and property (keyword) changes.
1 dashley 56 //$Header$
2 dashley 25 //-------------------------------------------------------------------------------------------------
3 dashley 56 //This file is part of "David T. Ashley's Shared Source Code", a set of shared components
4     //integrated into many of David T. Ashley's projects.
5 dashley 25 //-------------------------------------------------------------------------------------------------
6 dashley 56 //This source code and any program in which it is compiled/used is provided under the MIT License,
7     //reproduced below.
8     //-------------------------------------------------------------------------------------------------
9     //Permission is hereby granted, free of charge, to any person obtaining a copy of
10     //this software and associated documentation files(the "Software"), to deal in the
11     //Software without restriction, including without limitation the rights to use,
12     //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
13     //Software, and to permit persons to whom the Software is furnished to do so,
14     //subject to the following conditions :
15 dashley 25 //
16 dashley 56 //The above copyright notice and this permission notice shall be included in all
17     //copies or substantial portions of the Software.
18 dashley 25 //
19 dashley 56 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20     //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21     //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22     //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23     //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24     //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25     //SOFTWARE.
26 dashley 25 //-------------------------------------------------------------------------------------------------
27     #define MODULE_CHARFUNC
28    
29     #include <assert.h>
30     #include <stddef.h>
31    
32     #include "charfunc.h"
33    
34    
35     int CHARFUNC_digit_to_val(char digit)
36     {
37     switch (digit)
38     {
39     case '0': return(0);
40     break;
41     case '1': return(1);
42     break;
43     case '2': return(2);
44     break;
45     case '3': return(3);
46     break;
47     case '4': return(4);
48     break;
49     case '5': return(5);
50     break;
51     case '6': return(6);
52     break;
53     case '7': return(7);
54     break;
55     case '8': return(8);
56     break;
57     case '9': return(9);
58     break;
59     default: return(-1);
60     break;
61     }
62     }
63    
64    
65     char CHARFUNC_nibble_to_lc_hex_digit(int nibble)
66     {
67     switch (nibble & 0x0F)
68     {
69     case 0:
70     return('0');
71     break;
72     case 1:
73     return('1');
74     break;
75     case 2:
76     return('2');
77     break;
78     case 3:
79     return('3');
80     break;
81     case 4:
82     return('4');
83     break;
84     case 5:
85     return('5');
86     break;
87     case 6:
88     return('6');
89     break;
90     case 7:
91     return('7');
92     break;
93     case 8:
94     return('8');
95     break;
96     case 9:
97     return('9');
98     break;
99     case 10:
100     return('a');
101     break;
102     case 11:
103     return('b');
104     break;
105     case 12:
106     return('c');
107     break;
108     case 13:
109     return('d');
110     break;
111     case 14:
112     return('e');
113     break;
114     case 15:
115     return('f');
116     break;
117     default:
118     assert(0);
119     return('?');
120     break;
121     }
122     }
123    
124    
125     void CHARFUNC_int_to_lc_hex_rev(int arg, char *s)
126     {
127     int i;
128    
129     assert(s != NULL);
130    
131     for (i=0; i<8; i++)
132     {
133     s[i] = CHARFUNC_nibble_to_lc_hex_digit(arg);
134     arg >>= 4;
135     }
136     }
137    
138     const char *CHARFUNC_cvcinfo(void)
139     {
140 dashley 56 return("$Header$");
141 dashley 25 }
142    
143    
144     const char *CHARFUNC_hvcinfo(void)
145     {
146     return(CHARFUNC_H_VERSION);
147     }
148    
149 dashley 56 //End of charfunc.c.

Properties

Name Value
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25