Skip to content

Commit d2d908e

Browse files
committed
fix nfcmaker
1 parent 7fc2efb commit d2d908e

File tree

7 files changed

+34
-33
lines changed

7 files changed

+34
-33
lines changed

apps_broken_by_last_refactors/nfc_maker/strnlen.c renamed to apps_broken_by_last_refactors/nfc_maker/newstrnlen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "strnlen.h"
1+
#include "newstrnlen.h"
22

3-
size_t strnlen(const char* s, size_t maxlen) {
3+
size_t newstrnlen(const char* s, size_t maxlen) {
44
size_t len;
55

66
for(len = 0; len < maxlen; len++, s++) {

apps_broken_by_last_refactors/nfc_maker/strnlen.h renamed to apps_broken_by_last_refactors/nfc_maker/newstrnlen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
#include <stddef.h>
55

6-
size_t strnlen(const char* s, size_t maxlen);
6+
size_t newstrnlen(const char* s, size_t maxlen);

apps_broken_by_last_refactors/nfc_maker/nfc_maker.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#pragma once
2-
3-
#include <furi.h>
41
#include <gui/gui.h>
52
#include <gui/view.h>
63
#include <gui/modules/validators.h>
@@ -14,9 +11,11 @@
1411
#include "scenes/nfc_maker_scene.h"
1512
#include <lib/flipper_format/flipper_format.h>
1613
#include <toolbox/name_generator.h>
17-
#include <applications/main/nfc/nfc_app_i.h>
1814
#include <furi_hal_bt.h>
19-
#include "strnlen.h"
15+
#include "newstrnlen.h"
16+
17+
#define NFC_MK_APP_FOLDER EXT_PATH("nfc")
18+
#define NFC_MK_APP_EXTENSION ".nfc"
2019

2120
#define MAC_INPUT_LEN GAP_MAC_ADDR_SIZE
2221
#define MAIL_INPUT_LEN 128

apps_broken_by_last_refactors/nfc_maker/nfc_maker_validators.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
#include "nfc_maker_validators.h"
33
#include <storage/storage.h>
44

5-
struct ValidatorIsFile {
5+
struct NFCMakerValidatorIsFile {
66
char* app_path_folder;
77
const char* app_extension;
88
char* current_name;
99
};
1010

11-
bool validator_is_file_callback(const char* text, FuriString* error, void* context) {
11+
bool nfc_maker_validator_is_file_callback(const char* text, FuriString* error, void* context) {
1212
furi_assert(context);
13-
ValidatorIsFile* instance = context;
13+
NFCMakerValidatorIsFile* instance = context;
1414

1515
if(instance->current_name != NULL) {
1616
if(strcmp(instance->current_name, text) == 0) {
@@ -34,11 +34,11 @@ bool validator_is_file_callback(const char* text, FuriString* error, void* conte
3434
return ret;
3535
}
3636

37-
ValidatorIsFile* validator_is_file_alloc_init(
37+
NFCMakerValidatorIsFile* nfc_maker_validator_is_file_alloc_init(
3838
const char* app_path_folder,
3939
const char* app_extension,
4040
const char* current_name) {
41-
ValidatorIsFile* instance = malloc(sizeof(ValidatorIsFile));
41+
NFCMakerValidatorIsFile* instance = malloc(sizeof(NFCMakerValidatorIsFile));
4242

4343
instance->app_path_folder = strdup(app_path_folder);
4444
instance->app_extension = app_extension;
@@ -49,7 +49,7 @@ ValidatorIsFile* validator_is_file_alloc_init(
4949
return instance;
5050
}
5151

52-
void validator_is_file_free(ValidatorIsFile* instance) {
52+
void nfc_maker_validator_is_file_free(NFCMakerValidatorIsFile* instance) {
5353
furi_assert(instance);
5454
free(instance->app_path_folder);
5555
free(instance->current_name);

apps_broken_by_last_refactors/nfc_maker/nfc_maker_validators.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
#ifdef __cplusplus
66
extern "C" {
77
#endif
8-
typedef struct ValidatorIsFile ValidatorIsFile;
8+
typedef struct NFCMakerValidatorIsFile NFCMakerValidatorIsFile;
99

10-
ValidatorIsFile* validator_is_file_alloc_init(
10+
NFCMakerValidatorIsFile* nfc_maker_validator_is_file_alloc_init(
1111
const char* app_path_folder,
1212
const char* app_extension,
1313
const char* current_name);
1414

15-
void validator_is_file_free(ValidatorIsFile* instance);
15+
void nfc_maker_validator_is_file_free(NFCMakerValidatorIsFile* instance);
1616

17-
bool validator_is_file_callback(const char* text, FuriString* error, void* context);
17+
bool nfc_maker_validator_is_file_callback(const char* text, FuriString* error, void* context);
1818

1919
#ifdef __cplusplus
2020
}

apps_broken_by_last_refactors/nfc_maker/scenes/nfc_maker_scene_result.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../nfc_maker.h"
2+
#include <furi_hal_random.h>
23

34
enum PopupEvent {
45
PopupEventExit,
@@ -17,7 +18,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
1718

1819
FlipperFormat* file = flipper_format_file_alloc(furi_record_open(RECORD_STORAGE));
1920
FuriString* path = furi_string_alloc();
20-
furi_string_printf(path, NFC_APP_FOLDER "/%s" NFC_APP_EXTENSION, app->save_buf);
21+
furi_string_printf(path, NFC_MK_APP_FOLDER "/%s" NFC_MK_APP_EXTENSION, app->save_buf);
2122

2223
uint32_t pages = 135;
2324
size_t size = pages * 4;
@@ -104,15 +105,15 @@ void nfc_maker_scene_result_on_enter(void* context) {
104105
vcard,
105106
"FN:%s%s%s\r\n",
106107
app->small_buf1,
107-
strnlen(app->small_buf2, SMALL_INPUT_LEN) ? " " : "",
108+
newstrnlen(app->small_buf2, SMALL_INPUT_LEN) ? " " : "",
108109
app->small_buf2);
109-
if(strnlen(app->mail_buf, MAIL_INPUT_LEN)) {
110+
if(newstrnlen(app->mail_buf, MAIL_INPUT_LEN)) {
110111
furi_string_cat_printf(vcard, "EMAIL:%s\r\n", app->mail_buf);
111112
}
112-
if(strnlen(app->phone_buf, PHONE_INPUT_LEN)) {
113+
if(newstrnlen(app->phone_buf, PHONE_INPUT_LEN)) {
113114
furi_string_cat_printf(vcard, "TEL:%s\r\n", app->phone_buf);
114115
}
115-
if(strnlen(app->big_buf, BIG_INPUT_LEN)) {
116+
if(newstrnlen(app->big_buf, BIG_INPUT_LEN)) {
116117
furi_string_cat_printf(vcard, "URL:%s\r\n", app->big_buf);
117118
}
118119
furi_string_cat_printf(vcard, "END:VCARD\r\n");
@@ -127,7 +128,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
127128
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
128129
type = "\x55";
129130

130-
data_len = strnlen(app->big_buf, BIG_INPUT_LEN);
131+
data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
131132
payload_len = data_len + 1;
132133
payload = malloc(payload_len);
133134

@@ -140,7 +141,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
140141
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
141142
type = "\x55";
142143

143-
data_len = strnlen(app->mail_buf, MAIL_INPUT_LEN);
144+
data_len = newstrnlen(app->mail_buf, MAIL_INPUT_LEN);
144145
payload_len = data_len + 1;
145146
payload = malloc(payload_len);
146147

@@ -153,7 +154,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
153154
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
154155
type = "\x55";
155156

156-
data_len = strnlen(app->phone_buf, PHONE_INPUT_LEN);
157+
data_len = newstrnlen(app->phone_buf, PHONE_INPUT_LEN);
157158
payload_len = data_len + 1;
158159
payload = malloc(payload_len);
159160

@@ -166,7 +167,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
166167
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
167168
type = "\x54";
168169

169-
data_len = strnlen(app->big_buf, BIG_INPUT_LEN);
170+
data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
170171
payload_len = data_len + 3;
171172
payload = malloc(payload_len);
172173

@@ -181,7 +182,7 @@ void nfc_maker_scene_result_on_enter(void* context) {
181182
tnf = 0x01; // NFC Forum well-known type [NFC RTD]
182183
type = "\x55";
183184

184-
data_len = strnlen(app->big_buf, BIG_INPUT_LEN);
185+
data_len = newstrnlen(app->big_buf, BIG_INPUT_LEN);
185186
payload_len = data_len + 1;
186187
payload = malloc(payload_len);
187188

@@ -194,8 +195,8 @@ void nfc_maker_scene_result_on_enter(void* context) {
194195
tnf = 0x02; // Media-type [RFC 2046]
195196
type = "application/vnd.wfa.wsc";
196197

197-
uint8_t ssid_len = strnlen(app->small_buf1, SMALL_INPUT_LEN);
198-
uint8_t pass_len = strnlen(app->small_buf2, SMALL_INPUT_LEN);
198+
uint8_t ssid_len = newstrnlen(app->small_buf1, SMALL_INPUT_LEN);
199+
uint8_t pass_len = newstrnlen(app->small_buf2, SMALL_INPUT_LEN);
199200
uint8_t data_len = ssid_len + pass_len;
200201
payload_len = data_len + 39;
201202
payload = malloc(payload_len);

apps_broken_by_last_refactors/nfc_maker/scenes/nfc_maker_scene_save.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ void nfc_maker_scene_save_on_enter(void* context) {
2626
BIG_INPUT_LEN,
2727
true);
2828

29-
ValidatorIsFile* validator_is_file =
30-
validator_is_file_alloc_init(NFC_APP_FOLDER, NFC_APP_EXTENSION, NULL);
31-
nfc_maker_text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
29+
NFCMakerValidatorIsFile* validator_is_file =
30+
nfc_maker_validator_is_file_alloc_init(NFC_MK_APP_FOLDER, NFC_MK_APP_EXTENSION, NULL);
31+
nfc_maker_text_input_set_validator(
32+
text_input, nfc_maker_validator_is_file_callback, validator_is_file);
3233

3334
view_dispatcher_switch_to_view(app->view_dispatcher, NfcMakerViewTextInput);
3435
}

0 commit comments

Comments
 (0)