27
27
* SUCH DAMAGE.
28
28
*/
29
29
#include "flipbip_string.h"
30
- // #include <string.h>
31
30
#include <ctype.h>
32
31
char *
33
32
flipbip_strtok (char * s , const char * delim )
@@ -77,67 +76,18 @@ flipbip_strtok_r(char *s, const char *delim, char **last)
77
76
}
78
77
/* NOTREACHED */
79
78
}
80
- /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
81
- *
82
- * Redistribution and use in source and binary forms, with or without
83
- * modification, are permitted provided that the following conditions are
84
- * met:
85
- * * Redistributions of source code must retain the above copyright
86
- * notice, this list of conditions and the following disclaimer.
87
- * * Redistributions in binary form must reproduce the above
88
- * copyright notice, this list of conditions and the following
89
- * disclaimer in the documentation and/or other materials provided
90
- * with the distribution.
91
- * * Neither the name of The Linux Foundation nor the names of its
92
- * contributors may be used to endorse or promote products derived
93
- * from this software without specific prior written permission.
94
- *
95
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
96
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
97
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
98
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
99
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
100
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
101
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
102
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
103
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
104
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
105
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
106
- */
107
- // void
108
- // flipbip_strrev(unsigned char *str)
109
- // {
110
- // int i;
111
- // int j;
112
- // unsigned char a;
113
- // unsigned len = strlen((const char *)str);
114
- // for (i = 0, j = len - 1; i < j; i++, j--)
115
- // {
116
- // a = str[i];
117
- // str[i] = str[j];
118
- // str[j] = a;
119
- // }
120
- // }
121
- // int
122
- // flipbip_itoa(int num, unsigned char* str, int len, int base)
123
- // {
124
- // int sum = num;
125
- // int i = 0;
126
- // int digit;
127
- // if (len == 0)
128
- // return -1;
129
- // do
130
- // {
131
- // digit = sum % base;
132
- // if (digit < 0xA)
133
- // str[i++] = '0' + digit;
134
- // else
135
- // str[i++] = 'A' + digit - 0xA;
136
- // sum /= base;
137
- // }while (sum && (i < (len - 1)));
138
- // if (i == (len - 1) && sum)
139
- // return -1;
140
- // str[i] = '\0';
141
- // flipbip_strrev(str);
142
- // return 0;
143
- // }
79
+
80
+
81
+ void
82
+ flipbip_itox (uint8_t i , char * str )
83
+ {
84
+ unsigned char n ;
85
+
86
+ str += 2 ;
87
+ * str = '\0' ;
88
+
89
+ for (n = 2 ; n != 0 ; -- n ) {
90
+ * -- str = "0123456789abcdef" [i & 0x0F ];
91
+ i >>= 4 ;
92
+ }
93
+ }
0 commit comments