Skip to content

Commit 844569e

Browse files
committed
removing printf, replacing with simple itox
1 parent 4ea47f6 commit 844569e

File tree

6 files changed

+23
-1105
lines changed

6 files changed

+23
-1105
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ The goal of this project is to see how much crypto functionality can be brought
1010
## How to install on Flipper Zero
1111
- If you do not have one, download a Flipper Zero firmware to get the `fbt` build tool
1212
- Plug your Flipper Zero in via USB
13-
- Copy the contents of this folder into the applications_user folder of your firmware
13+
- Copy the contents of this folder into the `applications_user` folder of your firmware
1414
- Modify the `site_scons/cc.scons` file in the Flipper Zero firmware to remove the `"-Wdouble-promotion"` warning and add the `"-Os"` flag
1515

1616
Then run the command:
1717
```
18-
.\fbt COMPACT=1 DEBUG=0 launch_app APPSRC=applications_user/FlipBIP
18+
./fbt COMPACT=1 DEBUG=0 launch_app APPSRC=applications_user/FlipBIP
1919
```
2020
The application will be compiled and copied onto your device
2121

helpers/flipbip_string.c

+15-65
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* SUCH DAMAGE.
2828
*/
2929
#include "flipbip_string.h"
30-
// #include <string.h>
3130
#include <ctype.h>
3231
char *
3332
flipbip_strtok(char *s, const char *delim)
@@ -77,67 +76,18 @@ flipbip_strtok_r(char *s, const char *delim, char **last)
7776
}
7877
/* NOTREACHED */
7978
}
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+
}

helpers/flipbip_string.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#include <stdint.h>
2+
13
char * flipbip_strtok(char *s, const char *delim);
24
char * flipbip_strtok_r(char *s, const char *delim, char **last);
3-
// void flipbip_strrev(unsigned char *str);
4-
// int flipbip_itoa(int num, unsigned char* str, int len, int base);
5+
6+
void flipbip_itox(uint8_t i, char *str);

0 commit comments

Comments
 (0)