diff --git a/applications/plugins/totp/application.fam b/applications/plugins/totp/application.fam index e6bacc603..84aa43f09 100644 --- a/applications/plugins/totp/application.fam +++ b/applications/plugins/totp/application.fam @@ -8,18 +8,21 @@ App( "gui", "cli", "dialogs", - "storage" + "storage", + "input", + "notification" ], provides=["totp_start"], stack_size=2 * 1024, order=20, fap_category="Misc", - fap_icon="totp_10px.png", + fap_icon="totp_10px.png" ) + # App( -# appid="totp_start", -# apptype=FlipperAppType.STARTUP, -# entry_point="totp_on_system_start", -# requires=["totp"], -# order=30, -# ) \ No newline at end of file +# appid="totp_start", +# apptype=FlipperAppType.STARTUP, +# entry_point="totp_on_system_start", +# requires=["totp"], +# order=30, +# ) diff --git a/applications/plugins/totp/lib/totp/sha1.c b/applications/plugins/totp/lib/totp/sha1.c deleted file mode 100644 index cdcd87bdf..000000000 --- a/applications/plugins/totp/lib/totp/sha1.c +++ /dev/null @@ -1,169 +0,0 @@ -#include -#include "sha1.h" - -union _buffer { - uint8_t b[BLOCK_LENGTH]; - uint32_t w[BLOCK_LENGTH/4]; -} buffer; -union _state { - uint8_t b[HASH_LENGTH]; - uint32_t w[HASH_LENGTH/4]; -} state; - -uint8_t bufferOffset; -uint32_t byteCount; -uint8_t keyBuffer[BLOCK_LENGTH]; -uint8_t innerHash[HASH_LENGTH]; - -#define SHA1_K0 0x5a827999 -#define SHA1_K20 0x6ed9eba1 -#define SHA1_K40 0x8f1bbcdc -#define SHA1_K60 0xca62c1d6 - -uint8_t sha1InitState[] = { - 0x01,0x23,0x45,0x67, // H0 - 0x89,0xab,0xcd,0xef, // H1 - 0xfe,0xdc,0xba,0x98, // H2 - 0x76,0x54,0x32,0x10, // H3 - 0xf0,0xe1,0xd2,0xc3 // H4 -}; - -void sha1_init(void) { - memcpy(state.b,sha1InitState,HASH_LENGTH); - byteCount = 0; - bufferOffset = 0; -} - -uint32_t rol32(uint32_t number, uint8_t bits) { - return ((number << bits) | (uint32_t)(number >> (32-bits))); -} - -void hashBlock() { - uint8_t i; - uint32_t a,b,c,d,e,t; - - a=state.w[0]; - b=state.w[1]; - c=state.w[2]; - d=state.w[3]; - e=state.w[4]; - for (i=0; i<80; i++) { - if (i>=16) { - t = buffer.w[(i+13)&15] ^ buffer.w[(i+8)&15] ^ buffer.w[(i+2)&15] ^ buffer.w[i&15]; - buffer.w[i&15] = rol32(t,1); - } - if (i<20) { - t = (d ^ (b & (c ^ d))) + SHA1_K0; - } else if (i<40) { - t = (b ^ c ^ d) + SHA1_K20; - } else if (i<60) { - t = ((b & c) | (d & (b | c))) + SHA1_K40; - } else { - t = (b ^ c ^ d) + SHA1_K60; - } - t+=rol32(a,5) + e + buffer.w[i&15]; - e=d; - d=c; - c=rol32(b,30); - b=a; - a=t; - } - state.w[0] += a; - state.w[1] += b; - state.w[2] += c; - state.w[3] += d; - state.w[4] += e; -} - -void addUncounted(uint8_t data) { - buffer.b[bufferOffset ^ 3] = data; - bufferOffset++; - if (bufferOffset == BLOCK_LENGTH) { - hashBlock(); - bufferOffset = 0; - } -} - -void sha1_write(uint8_t data) { - ++byteCount; - addUncounted(data); - - return; -} - -void sha1_write_array(uint8_t *buffer, uint8_t size){ - while (size--) { - sha1_write(*buffer++); - } -} - -void pad() { - // Implement SHA-1 padding (fips180-2 ��5.1.1) - - // Pad with 0x80 followed by 0x00 until the end of the block - addUncounted(0x80); - while (bufferOffset != 56) addUncounted(0x00); - - // Append length in the last 8 bytes - addUncounted(0); // We're only using 32 bit lengths - addUncounted(0); // But SHA-1 supports 64 bit lengths - addUncounted(0); // So zero pad the top bits - addUncounted(byteCount >> 29); // Shifting to multiply by 8 - addUncounted(byteCount >> 21); // as SHA-1 supports bitstreams as well as - addUncounted(byteCount >> 13); // byte. - addUncounted(byteCount >> 5); - addUncounted(byteCount << 3); -} - -uint8_t* sha1_result(void) { - // Pad to complete the last block - pad(); - - // Swap byte order back - uint8_t i; - for (i=0; i<5; i++) { - uint32_t a,b; - a=state.w[i]; - b=a<<24; - b|=(a<<8) & 0x00ff0000; - b|=(a>>8) & 0x0000ff00; - b|=a>>24; - state.w[i]=b; - } - - // Return pointer to hash (20 characters) - return state.b; -} - -#define HMAC_IPAD 0x36 -#define HMAC_OPAD 0x5c - -void sha1_init_hmac(const uint8_t* key, uint8_t keyLength) { - uint8_t i; - memset(keyBuffer,0,BLOCK_LENGTH); - if (keyLength > BLOCK_LENGTH) { - // Hash long keys - sha1_init(); - for (;keyLength--;) sha1_write(*key++); - memcpy(keyBuffer,sha1_result(),HASH_LENGTH); - } else { - // Block length keys are used as is - memcpy(keyBuffer,key,keyLength); - } - // Start inner hash - sha1_init(); - for (i=0; i - -#define HASH_LENGTH 20 -#define BLOCK_LENGTH 64 - -void sha1_init(void); -void sha1_init_hmac(const uint8_t* secret, uint8_t secretLength); -uint8_t* sha1_result(void); -uint8_t* sha1_result_hmac(void); -void sha1_write(uint8_t); -void sha1_write_array(uint8_t *buffer, uint8_t size); -#endif diff --git a/applications/plugins/totp/lib/ui/canvas_extensions.c b/applications/plugins/totp/lib/ui/canvas_extensions.c deleted file mode 100644 index 9245c02ac..000000000 --- a/applications/plugins/totp/lib/ui/canvas_extensions.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "canvas_extensions.h" - -void canvas_draw_dots(Canvas* const canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height, const uint8_t *dots) { - for (uint8_t i = 0; i < width; i++) { - for (uint8_t j = 0; j < height; j++) { - if (dots[i + j * width]) { - canvas_draw_dot(canvas, x + i, y + j); - } - } - } -} diff --git a/applications/plugins/totp/lib/ui/canvas_extensions.h b/applications/plugins/totp/lib/ui/canvas_extensions.h deleted file mode 100644 index ab1714d4a..000000000 --- a/applications/plugins/totp/lib/ui/canvas_extensions.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _TOTPCANVAS_EXTENSIONS_H_ -#define _TOTPCANVAS_EXTENSIONS_H_ - -#include -#include -#include -#include - -void canvas_draw_dots(Canvas* const canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height, const uint8_t *dots); - -#endif diff --git a/applications/plugins/totp/scenes/add_new_token/totp_input_text.h b/applications/plugins/totp/scenes/add_new_token/totp_input_text.h index 945835fce..a73a227b5 100644 --- a/applications/plugins/totp/scenes/add_new_token/totp_input_text.h +++ b/applications/plugins/totp/scenes/add_new_token/totp_input_text.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_INPUT_TEXT_H_ -#define _TOTP_INPUT_TEXT_H_ +#pragma once #include #include @@ -37,5 +36,3 @@ InputTextSceneState* totp_input_text_activate(InputTextSceneContext* context); void totp_input_text_render(Canvas* const canvas, InputTextSceneState* text_input_state); bool totp_input_text_handle_event(PluginEvent* const event, InputTextSceneState* text_input_state); void totp_input_text_free(InputTextSceneState* state); - -#endif diff --git a/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.c b/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.c index 9645c6c19..fd49c586f 100644 --- a/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.c +++ b/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.c @@ -1,13 +1,13 @@ #include "totp_scene_add_new_token.h" #include "../../types/common.h" -#include "../../lib/ui/constants.h" +#include "../../services/ui/constants.h" #include "../scene_director.h" #include "totp_input_text.h" #include "../../types/token_info.h" -#include "../../lib/list/list.h" -#include "../../lib/base32/base32.h" -#include "../../lib/config/config.h" -#include "../../lib/ui/ui_controls.h" +#include "../../services/list/list.h" +#include "../../services/base32/base32.h" +#include "../../services/config/config.h" +#include "../../services/ui/ui_controls.h" #include "../generate_token/totp_scene_generate_token.h" #define TOKEN_ALGO_LIST_LENGTH 3 diff --git a/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.h b/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.h index 653e17319..c68e94a8b 100644 --- a/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.h +++ b/applications/plugins/totp/scenes/add_new_token/totp_scene_add_new_token.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_SCENE_ADD_NEW_TOKEN_H_ -#define _TOTP_SCENE_ADD_NEW_TOKEN_H_ +#pragma once #include #include @@ -17,5 +16,3 @@ void totp_scene_add_new_token_render(Canvas* const canvas, PluginState* plugin_s bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState* plugin_state); void totp_scene_add_new_token_deactivate(PluginState* plugin_state); void totp_scene_add_new_token_free(PluginState* plugin_state); - -#endif diff --git a/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.c b/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.c index 068d118af..336d4c175 100644 --- a/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.c +++ b/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.c @@ -1,9 +1,9 @@ #include "totp_scene_authenticate.h" #include #include "../../types/common.h" -#include "../../lib/ui/icons.h" -#include "../../lib/ui/constants.h" -#include "../../lib/config/config.h" +#include "../../services/ui/icons.h" +#include "../../services/ui/constants.h" +#include "../../services/config/config.h" #include "../scene_director.h" #include "../totp_scenes_enum.h" diff --git a/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.h b/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.h index d301c0c34..f1199a425 100644 --- a/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.h +++ b/applications/plugins/totp/scenes/authenticate/totp_scene_authenticate.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_SCENE_AUTHENTICATE_H_ -#define _TOTP_SCENE_AUTHENTICATE_H_ +#pragma once #include #include @@ -13,5 +12,3 @@ void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_st bool totp_scene_authenticate_handle_event(PluginEvent* const event, PluginState* plugin_state); void totp_scene_authenticate_deactivate(PluginState* plugin_state); void totp_scene_authenticate_free(PluginState* plugin_state); - -#endif diff --git a/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.c b/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.c index acd3a1379..700d141d0 100644 --- a/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.c +++ b/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.c @@ -4,10 +4,10 @@ #include "totp_scene_generate_token.h" #include "../../types/token_info.h" #include "../../types/common.h" -#include "../../lib/ui/icons.h" -#include "../../lib/ui/constants.h" -#include "../../lib/totp/totp.h" -#include "../../lib/config/config.h" +#include "../../services/ui/icons.h" +#include "../../services/ui/constants.h" +#include "../../services/totp/totp.h" +#include "../../services/config/config.h" #include "../scene_director.h" #include "../token_menu/totp_scene_token_menu.h" diff --git a/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.h b/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.h index 40dc47a69..c13bc7073 100644 --- a/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.h +++ b/applications/plugins/totp/scenes/generate_token/totp_scene_generate_token.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_SCENE_GENERATE_TOKEN_H_ -#define _TOTP_SCENE_GENERATE_TOKEN_H_ +#pragma once #include #include @@ -17,5 +16,3 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_ bool totp_scene_generate_token_handle_event(PluginEvent* const event, PluginState* plugin_state); void totp_scene_generate_token_deactivate(PluginState* plugin_state); void totp_scene_generate_token_free(PluginState* plugin_state); - -#endif diff --git a/applications/plugins/totp/scenes/scene_director.h b/applications/plugins/totp/scenes/scene_director.h index 962b7e9a7..0cd9ecfec 100644 --- a/applications/plugins/totp/scenes/scene_director.h +++ b/applications/plugins/totp/scenes/scene_director.h @@ -1,5 +1,4 @@ -#ifndef _SCENE_DIRECTOR_H_ -#define _SCENE_DIRECTOR_H_ +#pragma once #include #include "../types/plugin_state.h" @@ -12,5 +11,3 @@ void totp_scene_director_init_scenes(PluginState* const plugin_state); void totp_scene_director_render(Canvas* const canvas, PluginState* const plugin_state); void totp_scene_director_dispose(PluginState* const plugin_state); bool totp_scene_director_handle_event(PluginEvent* const event, PluginState* const plugin_state); - -#endif diff --git a/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.c b/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.c index 122f8cc17..26c5985aa 100644 --- a/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.c +++ b/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.c @@ -1,11 +1,11 @@ #include "totp_scene_token_menu.h" #include #include -#include "../../lib/ui/ui_controls.h" -#include "../../lib/ui/constants.h" +#include "../../services/ui/ui_controls.h" +#include "../../services/ui/constants.h" #include "../scene_director.h" -#include "../../lib/config/config.h" -#include "../../lib/list/list.h" +#include "../../services/config/config.h" +#include "../../services/list/list.h" #include "../../types/token_info.h" #include "../generate_token/totp_scene_generate_token.h" #include "../add_new_token/totp_scene_add_new_token.h" diff --git a/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.h b/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.h index a73b5e8a3..e544e73eb 100644 --- a/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.h +++ b/applications/plugins/totp/scenes/token_menu/totp_scene_token_menu.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_SCENE_TOKEN_MENU_H_ -#define _TOTP_SCENE_TOKEN_MENU_H_ +#pragma once #include #include @@ -17,5 +16,3 @@ void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_stat bool totp_scene_token_menu_handle_event(PluginEvent* const event, PluginState* plugin_state); void totp_scene_token_menu_deactivate(PluginState* plugin_state); void totp_scene_token_menu_free(PluginState* plugin_state); - -#endif diff --git a/applications/plugins/totp/scenes/totp_scenes_enum.h b/applications/plugins/totp/scenes/totp_scenes_enum.h index 3e45992e5..32cfcb238 100644 --- a/applications/plugins/totp/scenes/totp_scenes_enum.h +++ b/applications/plugins/totp/scenes/totp_scenes_enum.h @@ -1,9 +1,8 @@ -#ifndef _TOTP_SCENES_ENUM_H_ -#define _TOTP_SCENES_ENUM_H_ +#pragma once + typedef enum { TotpSceneAuthentication, TotpSceneGenerateToken, TotpSceneAddNewToken, TotpSceneTokenMenu } Scene; -#endif diff --git a/applications/plugins/totp/lib/base32/base32.c b/applications/plugins/totp/services/base32/base32.c similarity index 100% rename from applications/plugins/totp/lib/base32/base32.c rename to applications/plugins/totp/services/base32/base32.c diff --git a/applications/plugins/totp/lib/base32/base32.h b/applications/plugins/totp/services/base32/base32.h similarity index 95% rename from applications/plugins/totp/lib/base32/base32.h rename to applications/plugins/totp/services/base32/base32.h index fb4da0bee..c3e5b3756 100644 --- a/applications/plugins/totp/lib/base32/base32.h +++ b/applications/plugins/totp/services/base32/base32.h @@ -25,8 +25,7 @@ // All functions return the number of output bytes or -1 on error. If the // output buffer is too small, the result will silently be truncated. -#ifndef _BASE32_H_ -#define _BASE32_H_ +#pragma once #include @@ -35,5 +34,3 @@ int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize) int base32_encode(const uint8_t *data, int length, uint8_t *result, int bufSize) __attribute__((visibility("hidden"))); - -#endif /* _BASE32_H_ */ diff --git a/applications/plugins/totp/lib/config/config.c b/applications/plugins/totp/services/config/config.c similarity index 92% rename from applications/plugins/totp/lib/config/config.c rename to applications/plugins/totp/services/config/config.c index d4b758652..60264268c 100644 --- a/applications/plugins/totp/lib/config/config.c +++ b/applications/plugins/totp/services/config/config.c @@ -1,6 +1,7 @@ #include "config.h" #include #include +#include "../list/list.h" #include "../../types/common.h" #include "../../types/token_info.h" #include "migrations/config_migration_v1_to_v2.h" @@ -40,11 +41,11 @@ char* token_info_get_algo_as_cstr(TokenInfo* token_info) { } void token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) { - if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) { + if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) { token_info->algo = SHA1; - } else if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME)) { + } else if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME)) { token_info->algo = SHA256; - } else if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME)) { + } else if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME)) { token_info->algo = SHA512; } } @@ -88,30 +89,29 @@ FlipperFormat* totp_open_config_file(Storage* storage) { flipper_format_write_comment_cstr(fff_data_file, " "); flipper_format_write_comment_cstr(fff_data_file, "Timezone offset in hours. Important note: do not put '+' sign for positive values"); flipper_format_write_float(fff_data_file, TOTP_CONFIG_KEY_TIMEZONE, &tmp_tz, 1); - FuriString* temp_str; - temp_str = furi_string_alloc(); + FuriString* temp_str = furi_string_alloc(); flipper_format_write_comment_cstr(fff_data_file, " "); flipper_format_write_comment_cstr(fff_data_file, "=== TOKEN SAMPLE BEGIN ==="); flipper_format_write_comment_cstr(fff_data_file, " "); flipper_format_write_comment_cstr(fff_data_file, "# Token name which will be visible in the UI."); - string_printf(temp_str, "%s: Sample token name", TOTP_CONFIG_KEY_TOKEN_NAME); + furi_string_printf(temp_str, "%s: Sample token name", TOTP_CONFIG_KEY_TOKEN_NAME); flipper_format_write_comment(fff_data_file, temp_str); flipper_format_write_comment_cstr(fff_data_file, " "); flipper_format_write_comment_cstr(fff_data_file, "# Plain token secret without spaces, dashes and etc, just pure alpha-numeric characters. Important note: plain token will be encrypted and replaced by TOTP app"); - string_printf(temp_str, "%s: plaintokensecret", TOTP_CONFIG_KEY_TOKEN_SECRET); + furi_string_printf(temp_str, "%s: plaintokensecret", TOTP_CONFIG_KEY_TOKEN_SECRET); flipper_format_write_comment(fff_data_file, temp_str); flipper_format_write_comment_cstr(fff_data_file, " "); - string_printf(temp_str, " # Token hashing algorithm to use during code generation. Supported options are %s, %s and %s. If you are not use which one to use - use %s", TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME); + furi_string_printf(temp_str, " # Token hashing algorithm to use during code generation. Supported options are %s, %s and %s. If you are not use which one to use - use %s", TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME); flipper_format_write_comment(fff_data_file, temp_str); - string_printf(temp_str, "%s: %s", TOTP_CONFIG_KEY_TOKEN_ALGO, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME); + furi_string_printf(temp_str, "%s: %s", TOTP_CONFIG_KEY_TOKEN_ALGO, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME); flipper_format_write_comment(fff_data_file, temp_str); flipper_format_write_comment_cstr(fff_data_file, " "); flipper_format_write_comment_cstr(fff_data_file, "# How many digits there should be in generated code. Available options are 6 and 8. Majority websites requires 6 digits code, however some rare websites wants to get 8 digits code. If you are not sure which one to use - use 6"); - string_printf(temp_str, "%s: 6", TOTP_CONFIG_KEY_TOKEN_DIGITS); + furi_string_printf(temp_str, "%s: 6", TOTP_CONFIG_KEY_TOKEN_DIGITS); flipper_format_write_comment(fff_data_file, temp_str); flipper_format_write_comment_cstr(fff_data_file, " "); @@ -163,8 +163,7 @@ void totp_config_file_load_base(PluginState* const plugin_state) { plugin_state->timezone_offset = 0; - FuriString* temp_str; - temp_str = furi_string_alloc(); + FuriString* temp_str = furi_string_alloc(); uint32_t file_version; if(!flipper_format_read_header(fff_data_file, temp_str, &file_version)) { @@ -236,9 +235,8 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) { Storage* storage = totp_open_storage(); FlipperFormat* fff_data_file = totp_open_config_file(storage); - FuriString* temp_str; + FuriString* temp_str = furi_string_alloc(); uint32_t temp_data32; - temp_str = furi_string_alloc(); if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) { FURI_LOG_E(LOGGING_TAG, "Missing or incorrect header"); diff --git a/applications/plugins/totp/lib/config/config.h b/applications/plugins/totp/services/config/config.h similarity index 90% rename from applications/plugins/totp/lib/config/config.h rename to applications/plugins/totp/services/config/config.h index 43b6e01bd..62ad0b44d 100644 --- a/applications/plugins/totp/lib/config/config.h +++ b/applications/plugins/totp/services/config/config.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_CONFIG_FILE_H_ -#define _TOTP_CONFIG_FILE_H_ +#pragma once #include #include @@ -15,5 +14,3 @@ void totp_full_save_config_file(PluginState* const plugin_state); void totp_config_file_load_base(PluginState* const plugin_state); void totp_config_file_load_tokens(PluginState* const plugin_state); void totp_config_file_save_new_token(FlipperFormat* file, TokenInfo* token_info); - -#endif diff --git a/applications/plugins/totp/lib/config/constants.h b/applications/plugins/totp/services/config/constants.h similarity index 87% rename from applications/plugins/totp/lib/config/constants.h rename to applications/plugins/totp/services/config/constants.h index 5ca92a710..931db4e02 100644 --- a/applications/plugins/totp/lib/config/constants.h +++ b/applications/plugins/totp/services/config/constants.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_CONFIG_CONSTANTS_FILE_H_ -#define _TOTP_CONFIG_CONSTANTS_FILE_H_ +#pragma once #define CONFIG_FILE_HEADER "Flipper TOTP plugin config file" #define CONFIG_FILE_ACTUAL_VERSION 2 @@ -15,5 +14,3 @@ #define TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME "sha1" #define TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME "sha256" #define TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME "sha512" - -#endif diff --git a/applications/plugins/totp/lib/config/migrations/config_migration_v1_to_v2.c b/applications/plugins/totp/services/config/migrations/config_migration_v1_to_v2.c similarity index 96% rename from applications/plugins/totp/lib/config/migrations/config_migration_v1_to_v2.c rename to applications/plugins/totp/services/config/migrations/config_migration_v1_to_v2.c index d27b0c1dd..ad1b8d795 100644 --- a/applications/plugins/totp/lib/config/migrations/config_migration_v1_to_v2.c +++ b/applications/plugins/totp/services/config/migrations/config_migration_v1_to_v2.c @@ -7,8 +7,7 @@ bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* fff_backup_data_file) { flipper_format_write_header_cstr(fff_data_file, CONFIG_FILE_HEADER, NEW_VERSION); - FuriString* temp_str; - temp_str = furi_string_alloc(); + FuriString* temp_str = furi_string_alloc(); if (flipper_format_read_string(fff_backup_data_file, TOTP_CONFIG_KEY_BASE_IV, temp_str)) { flipper_format_write_string(fff_data_file, TOTP_CONFIG_KEY_BASE_IV, temp_str); diff --git a/applications/plugins/totp/lib/config/migrations/config_migration_v1_to_v2.h b/applications/plugins/totp/services/config/migrations/config_migration_v1_to_v2.h similarity index 59% rename from applications/plugins/totp/lib/config/migrations/config_migration_v1_to_v2.h rename to applications/plugins/totp/services/config/migrations/config_migration_v1_to_v2.h index 2dc1106f4..58b7f08d7 100644 --- a/applications/plugins/totp/lib/config/migrations/config_migration_v1_to_v2.h +++ b/applications/plugins/totp/services/config/migrations/config_migration_v1_to_v2.h @@ -1,8 +1,5 @@ -#ifndef _TOTP_CONFIG_FILE_MIGRATE_V1_TO_V2_H_ -#define _TOTP_CONFIG_FILE_MIGRATE_V1_TO_V2_H_ +#pragma once #include bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* fff_backup_data_file); - -#endif diff --git a/applications/plugins/totp/lib/hmac/byteswap.c b/applications/plugins/totp/services/hmac/byteswap.c similarity index 100% rename from applications/plugins/totp/lib/hmac/byteswap.c rename to applications/plugins/totp/services/hmac/byteswap.c diff --git a/applications/plugins/totp/lib/hmac/byteswap.h b/applications/plugins/totp/services/hmac/byteswap.h similarity index 68% rename from applications/plugins/totp/lib/hmac/byteswap.h rename to applications/plugins/totp/services/hmac/byteswap.h index c412e4cd6..42a4abf22 100644 --- a/applications/plugins/totp/lib/hmac/byteswap.h +++ b/applications/plugins/totp/services/hmac/byteswap.h @@ -1,9 +1,6 @@ -#ifndef BYTESWAP_H -#define BYTESWAP_H +#pragma once #include uint32_t swap_uint32( uint32_t val ); uint64_t swap_uint64( uint64_t val ); - -#endif diff --git a/applications/plugins/totp/lib/hmac/hmac-common.h b/applications/plugins/totp/services/hmac/hmac-common.h similarity index 100% rename from applications/plugins/totp/lib/hmac/hmac-common.h rename to applications/plugins/totp/services/hmac/hmac-common.h diff --git a/applications/plugins/totp/lib/hmac/hmac-sha1.c b/applications/plugins/totp/services/hmac/hmac-sha1.c similarity index 100% rename from applications/plugins/totp/lib/hmac/hmac-sha1.c rename to applications/plugins/totp/services/hmac/hmac-sha1.c diff --git a/applications/plugins/totp/lib/hmac/hmac-sha1.h b/applications/plugins/totp/services/hmac/hmac-sha1.h similarity index 85% rename from applications/plugins/totp/lib/hmac/hmac-sha1.h rename to applications/plugins/totp/services/hmac/hmac-sha1.h index 5bf0b8157..f01957a38 100644 --- a/applications/plugins/totp/lib/hmac/hmac-sha1.h +++ b/applications/plugins/totp/services/hmac/hmac-sha1.h @@ -1,5 +1,4 @@ -#ifndef HMAC_SHA1_H -#define HMAC_SHA1_H +#pragma once #include @@ -10,5 +9,3 @@ output to pre-allocated 20 byte minimum RESBUF buffer. Return 0 on success. */ int hmac_sha1 (const void *key, size_t keylen, const void *in, size_t inlen, void *restrict resbuf); - -#endif /* HMAC_SHA1_H */ diff --git a/applications/plugins/totp/lib/hmac/hmac-sha256.c b/applications/plugins/totp/services/hmac/hmac-sha256.c similarity index 100% rename from applications/plugins/totp/lib/hmac/hmac-sha256.c rename to applications/plugins/totp/services/hmac/hmac-sha256.c diff --git a/applications/plugins/totp/lib/hmac/hmac-sha256.h b/applications/plugins/totp/services/hmac/hmac-sha256.h similarity index 84% rename from applications/plugins/totp/lib/hmac/hmac-sha256.h rename to applications/plugins/totp/services/hmac/hmac-sha256.h index a46fb89b7..c4bf703ec 100644 --- a/applications/plugins/totp/lib/hmac/hmac-sha256.h +++ b/applications/plugins/totp/services/hmac/hmac-sha256.h @@ -1,5 +1,4 @@ -#ifndef HMAC_SHA256_H -#define HMAC_SHA256_H +#pragma once #include @@ -10,5 +9,3 @@ output to pre-allocated 32 byte minimum RESBUF buffer. Return 0 on success. */ int hmac_sha256 (const void *key, size_t keylen, const void *in, size_t inlen, void *restrict resbuf); - -#endif /* HMAC_SHA256_H */ diff --git a/applications/plugins/totp/lib/hmac/hmac-sha512.c b/applications/plugins/totp/services/hmac/hmac-sha512.c similarity index 100% rename from applications/plugins/totp/lib/hmac/hmac-sha512.c rename to applications/plugins/totp/services/hmac/hmac-sha512.c diff --git a/applications/plugins/totp/lib/hmac/hmac-sha512.h b/applications/plugins/totp/services/hmac/hmac-sha512.h similarity index 84% rename from applications/plugins/totp/lib/hmac/hmac-sha512.h rename to applications/plugins/totp/services/hmac/hmac-sha512.h index 8ad7d6ff0..6407a7e19 100644 --- a/applications/plugins/totp/lib/hmac/hmac-sha512.h +++ b/applications/plugins/totp/services/hmac/hmac-sha512.h @@ -1,5 +1,4 @@ -#ifndef HMAC_SHA512_H -#define HMAC_SHA512_H +#pragma once #include @@ -10,5 +9,3 @@ output to pre-allocated 64 byte minimum RESBUF buffer. Return 0 on success. */ int hmac_sha512 (const void *key, size_t keylen, const void *in, size_t inlen, void *restrict resbuf); - -#endif /* HMAC_SHA512_H */ diff --git a/applications/plugins/totp/lib/hmac/memxor.c b/applications/plugins/totp/services/hmac/memxor.c similarity index 100% rename from applications/plugins/totp/lib/hmac/memxor.c rename to applications/plugins/totp/services/hmac/memxor.c diff --git a/applications/plugins/totp/lib/hmac/memxor.h b/applications/plugins/totp/services/hmac/memxor.h similarity index 95% rename from applications/plugins/totp/lib/hmac/memxor.h rename to applications/plugins/totp/services/hmac/memxor.h index e67534e31..20f3e9817 100644 --- a/applications/plugins/totp/lib/hmac/memxor.h +++ b/applications/plugins/totp/services/hmac/memxor.h @@ -18,8 +18,7 @@ /* Written by Simon Josefsson. The interface was inspired by memxor in Niels Möller's Nettle. */ -#ifndef MEMXOR_H -# define MEMXOR_H +#pragma once #include @@ -27,5 +26,3 @@ the result in DEST, of length N bytes. Returns a pointer to DEST. */ void *memxor (void */*restrict*/ dest, const void */*restrict*/ src, size_t n); - -#endif /* MEMXOR_H */ diff --git a/applications/plugins/totp/lib/hmac/sha1.c b/applications/plugins/totp/services/hmac/sha1.c similarity index 100% rename from applications/plugins/totp/lib/hmac/sha1.c rename to applications/plugins/totp/services/hmac/sha1.c diff --git a/applications/plugins/totp/lib/hmac/sha1.h b/applications/plugins/totp/services/hmac/sha1.h similarity index 98% rename from applications/plugins/totp/lib/hmac/sha1.h rename to applications/plugins/totp/services/hmac/sha1.h index bc3470a50..e85163385 100644 --- a/applications/plugins/totp/lib/hmac/sha1.h +++ b/applications/plugins/totp/services/hmac/sha1.h @@ -16,8 +16,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -#ifndef SHA1_H -# define SHA1_H 1 +#pragma once # include # include @@ -105,8 +104,6 @@ extern int sha1_stream (FILE *stream, void *resblock); } # endif -#endif - /* * Hey Emacs! * Local Variables: diff --git a/applications/plugins/totp/lib/hmac/sha256.c b/applications/plugins/totp/services/hmac/sha256.c similarity index 100% rename from applications/plugins/totp/lib/hmac/sha256.c rename to applications/plugins/totp/services/hmac/sha256.c diff --git a/applications/plugins/totp/lib/hmac/sha256.h b/applications/plugins/totp/services/hmac/sha256.h similarity index 98% rename from applications/plugins/totp/lib/hmac/sha256.h rename to applications/plugins/totp/services/hmac/sha256.h index 533173a59..5612bd75b 100644 --- a/applications/plugins/totp/lib/hmac/sha256.h +++ b/applications/plugins/totp/services/hmac/sha256.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -#ifndef SHA256_H -# define SHA256_H 1 +#pragma once # include # include @@ -111,8 +110,6 @@ extern int sha224_stream (FILE *stream, void *resblock); } # endif -#endif - /* * Hey Emacs! * Local Variables: diff --git a/applications/plugins/totp/lib/hmac/sha512.c b/applications/plugins/totp/services/hmac/sha512.c similarity index 100% rename from applications/plugins/totp/lib/hmac/sha512.c rename to applications/plugins/totp/services/hmac/sha512.c diff --git a/applications/plugins/totp/lib/hmac/sha512.h b/applications/plugins/totp/services/hmac/sha512.h similarity index 99% rename from applications/plugins/totp/lib/hmac/sha512.h rename to applications/plugins/totp/services/hmac/sha512.h index 1eb187022..59949471f 100644 --- a/applications/plugins/totp/lib/hmac/sha512.h +++ b/applications/plugins/totp/services/hmac/sha512.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -#ifndef SHA512_H -# define SHA512_H 1 +#pragma once # include # include "u64.h" @@ -114,8 +113,6 @@ extern int sha384_stream (FILE *stream, void *resblock); } # endif -#endif - /* * Hey Emacs! * Local Variables: diff --git a/applications/plugins/totp/lib/hmac/u64.c b/applications/plugins/totp/services/hmac/u64.c similarity index 100% rename from applications/plugins/totp/lib/hmac/u64.c rename to applications/plugins/totp/services/hmac/u64.c diff --git a/applications/plugins/totp/lib/hmac/u64.h b/applications/plugins/totp/services/hmac/u64.h similarity index 99% rename from applications/plugins/totp/lib/hmac/u64.h rename to applications/plugins/totp/services/hmac/u64.h index f57ea6550..df94d08ac 100644 --- a/applications/plugins/totp/lib/hmac/u64.h +++ b/applications/plugins/totp/services/hmac/u64.h @@ -17,6 +17,8 @@ /* Written by Paul Eggert. */ +#pragma once + #include #ifndef _GL_U64_INLINE diff --git a/applications/plugins/totp/lib/list/list.c b/applications/plugins/totp/services/list/list.c similarity index 100% rename from applications/plugins/totp/lib/list/list.c rename to applications/plugins/totp/services/list/list.c diff --git a/applications/plugins/totp/lib/list/list.h b/applications/plugins/totp/services/list/list.h similarity index 93% rename from applications/plugins/totp/lib/list/list.h rename to applications/plugins/totp/services/list/list.h index 4d0bbd6f8..ee7473704 100644 --- a/applications/plugins/totp/lib/list/list.h +++ b/applications/plugins/totp/services/list/list.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_LIST_H_ -#define _TOTP_LIST_H_ +#pragma once #include #include @@ -15,5 +14,3 @@ ListNode *list_find(ListNode *head, void* data); /* returns pointer of element w ListNode *list_element_at(ListNode *head, uint16_t index); /* returns pointer of element with specified index in list. */ ListNode *list_remove(ListNode *head, ListNode *ep); /* removes element from the list and returns new head node. */ void list_free(ListNode *head); /* deletes all elements of the list. */ - -#endif diff --git a/applications/plugins/totp/lib/timezone_utils/timezone_utils.c b/applications/plugins/totp/services/timezone_utils/timezone_utils.c similarity index 100% rename from applications/plugins/totp/lib/timezone_utils/timezone_utils.c rename to applications/plugins/totp/services/timezone_utils/timezone_utils.c diff --git a/applications/plugins/totp/lib/timezone_utils/timezone_utils.h b/applications/plugins/totp/services/timezone_utils/timezone_utils.h similarity index 68% rename from applications/plugins/totp/lib/timezone_utils/timezone_utils.h rename to applications/plugins/totp/services/timezone_utils/timezone_utils.h index 9d15d7a08..0ae829d74 100644 --- a/applications/plugins/totp/lib/timezone_utils/timezone_utils.h +++ b/applications/plugins/totp/services/timezone_utils/timezone_utils.h @@ -1,9 +1,6 @@ -#ifndef _TIMEZONE_UTILS_H_ -#define _TIMEZONE_UTILS_H_ +#pragma once #include int32_t timezone_offset_from_hours(float hours); uint64_t timezone_offset_apply(uint64_t time, int32_t offset); - -#endif diff --git a/applications/plugins/totp/lib/totp/totp.c b/applications/plugins/totp/services/totp/totp.c similarity index 100% rename from applications/plugins/totp/lib/totp/totp.c rename to applications/plugins/totp/services/totp/totp.c diff --git a/applications/plugins/totp/lib/totp/totp.h b/applications/plugins/totp/services/totp/totp.h similarity index 95% rename from applications/plugins/totp/lib/totp/totp.h rename to applications/plugins/totp/services/totp/totp.h index d03abfb50..d2eb71c7e 100644 --- a/applications/plugins/totp/lib/totp/totp.h +++ b/applications/plugins/totp/services/totp/totp.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_H_ -#define _TOTP_H_ +#pragma once #include #include @@ -40,5 +39,3 @@ extern const TOTP_ALGO TOTP_ALGO_SHA512; 0 otherwise */ uint32_t totp_at(TOTP_ALGO algo, uint8_t digits, const uint8_t* plain_secret, uint8_t plain_secret_length, uint64_t for_time, float timezone, uint8_t interval); - -#endif diff --git a/applications/plugins/totp/lib/ui/constants.h b/applications/plugins/totp/services/ui/constants.h similarity index 68% rename from applications/plugins/totp/lib/ui/constants.h rename to applications/plugins/totp/services/ui/constants.h index 0946a763d..9caf90c4e 100644 --- a/applications/plugins/totp/lib/ui/constants.h +++ b/applications/plugins/totp/services/ui/constants.h @@ -1,9 +1,6 @@ -#ifndef _TOTP_UI_CONSTANTS_H_ -#define _TOTP_UI_CONSTANTS_H_ +#pragma once #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define SCREEN_WIDTH_CENTER (SCREEN_WIDTH >> 1) #define SCREEN_HEIGHT_CENTER (SCREEN_HEIGHT >> 1) - -#endif diff --git a/applications/plugins/totp/lib/ui/icons.h b/applications/plugins/totp/services/ui/icons.h similarity index 87% rename from applications/plugins/totp/lib/ui/icons.h rename to applications/plugins/totp/services/ui/icons.h index ea4b6812e..3bbbc52f6 100644 --- a/applications/plugins/totp/lib/ui/icons.h +++ b/applications/plugins/totp/services/ui/icons.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_ICONS_H_ -#define _TOTP_ICONS_H_ +#pragma once #include @@ -10,5 +9,3 @@ static const uint8_t ICON_ARROW_LEFT_8x9[] = { 0x80,0xe0,0xf8,0xfe,0xff,0xfe,0xf #define ICON_ARROW_RIGHT_8x9_WIDTH 8 #define ICON_ARROW_RIGHT_8x9_HEIGHT 9 static const uint8_t ICON_ARROW_RIGHT_8x9[] = { 0x01,0x07,0x1f,0x7f,0xff,0x7f,0x1f,0x07,0x01 }; - -#endif diff --git a/applications/plugins/totp/lib/ui/ui_controls.c b/applications/plugins/totp/services/ui/ui_controls.c similarity index 100% rename from applications/plugins/totp/lib/ui/ui_controls.c rename to applications/plugins/totp/services/ui/ui_controls.c diff --git a/applications/plugins/totp/lib/ui/ui_controls.h b/applications/plugins/totp/services/ui/ui_controls.h similarity index 84% rename from applications/plugins/totp/lib/ui/ui_controls.h rename to applications/plugins/totp/services/ui/ui_controls.h index df1fb27bf..3f9e7b6eb 100644 --- a/applications/plugins/totp/lib/ui/ui_controls.h +++ b/applications/plugins/totp/services/ui/ui_controls.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_UI_CONTROLS_H_ -#define _TOTP_UI_CONTROLS_H_ +#pragma once #include #include @@ -7,5 +6,3 @@ void ui_control_text_box_render(Canvas* const canvas, int8_t y, char* text, bool is_selected); void ui_control_button_render(Canvas* const canvas, uint8_t x, int8_t y, uint8_t width, uint8_t height, char* text, bool is_selected); void ui_control_select_render(Canvas* const canvas, int8_t y, char* text, bool is_selected); - -#endif diff --git a/applications/plugins/totp/totp_app.c b/applications/plugins/totp/totp_app.c index a420e1ed5..3b8539b52 100644 --- a/applications/plugins/totp/totp_app.c +++ b/applications/plugins/totp/totp_app.c @@ -7,9 +7,9 @@ #include #include #include -#include "lib/base32/base32.h" -#include "lib/list/list.h" -#include "lib/config/config.h" +#include "services/base32/base32.h" +#include "services/list/list.h" +#include "services/config/config.h" #include "types/plugin_state.h" #include "types/token_info.h" #include "types/plugin_event.h" diff --git a/applications/plugins/totp/types/common.h b/applications/plugins/totp/types/common.h index 1fb6b5735..df8f6cc2d 100644 --- a/applications/plugins/totp/types/common.h +++ b/applications/plugins/totp/types/common.h @@ -1,7 +1,4 @@ -#ifndef _TOTP_COMMON_TYPES_H_ -#define _TOTP_COMMON_TYPES_H_ +#pragma once #define LOGGING_TAG "TOTP APP" #define CRYPTO_KEY_SLOT 2 - -#endif diff --git a/applications/plugins/totp/types/event_type.h b/applications/plugins/totp/types/event_type.h index f828e29bd..ed890caf1 100644 --- a/applications/plugins/totp/types/event_type.h +++ b/applications/plugins/totp/types/event_type.h @@ -1,11 +1,7 @@ -#ifndef _TOTP_EVENT_TYPE_H_ -#define _TOTP_EVENT_TYPE_H_ - +#pragma once #include typedef enum { EventTypeTick, EventTypeKey, } EventType; - -#endif diff --git a/applications/plugins/totp/types/plugin_event.h b/applications/plugins/totp/types/plugin_event.h index 68c5bef7e..76c22af59 100644 --- a/applications/plugins/totp/types/plugin_event.h +++ b/applications/plugins/totp/types/plugin_event.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_PLUGIN_EVENT_H_ -#define _TOTP_PLUGIN_EVENT_H_ +#pragma once #include #include @@ -9,5 +8,3 @@ typedef struct { EventType type; InputEvent input; } PluginEvent; - -#endif diff --git a/applications/plugins/totp/types/plugin_state.h b/applications/plugins/totp/types/plugin_state.h index e026d4d78..3f2b30ed6 100644 --- a/applications/plugins/totp/types/plugin_state.h +++ b/applications/plugins/totp/types/plugin_state.h @@ -1,10 +1,9 @@ -#ifndef _TOTP_PLUGIN_STATE_H_ -#define _TOTP_PLUGIN_STATE_H_ +#pragma once #include #include #include -#include "../lib/list/list.h" +#include "../services/list/list.h" #include "../scenes/totp_scenes_enum.h" #define TOTP_IV_SIZE 16 @@ -27,5 +26,3 @@ typedef struct { uint8_t iv[TOTP_IV_SIZE]; uint8_t base_iv[TOTP_IV_SIZE]; } PluginState; - -#endif diff --git a/applications/plugins/totp/types/token_info.c b/applications/plugins/totp/types/token_info.c index 7d47dd43a..3284c522e 100644 --- a/applications/plugins/totp/types/token_info.c +++ b/applications/plugins/totp/types/token_info.c @@ -3,7 +3,7 @@ #include "token_info.h" #include "stdlib.h" #include "common.h" -#include "../lib/base32/base32.h" +#include "../services/base32/base32.h" TokenInfo* token_info_alloc() { TokenInfo* tokenInfo = malloc(sizeof(TokenInfo)); diff --git a/applications/plugins/totp/types/token_info.h b/applications/plugins/totp/types/token_info.h index b87026214..c0c865ead 100644 --- a/applications/plugins/totp/types/token_info.h +++ b/applications/plugins/totp/types/token_info.h @@ -1,5 +1,4 @@ -#ifndef _TOTP_TOKEN_INFO_H_ -#define _TOTP_TOKEN_INFO_H_ +#pragma once #include @@ -26,5 +25,3 @@ TokenInfo* token_info_alloc(); void token_info_free(TokenInfo* token_info); void token_info_set_secret(TokenInfo* token_info, const char* base32_token_secret, uint8_t token_secret_length, uint8_t* iv); uint8_t token_info_get_digits_count(TokenInfo* token_info); - -#endif