LCOV - code coverage report
Current view: top level - src/core - tl_registry.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 8 8
Test Date: 2026-04-20 19:54:22 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /* SPDX-License-Identifier: GPL-3.0-or-later */
       2              : /* Copyright 2026 Peter Csaszar */
       3              : 
       4              : /**
       5              :  * @file tl_registry.c
       6              :  * @brief TL constructor registry — lookup table.
       7              :  */
       8              : 
       9              : #include "tl_registry.h"
      10              : 
      11              : #include <stddef.h>
      12              : 
      13              : static const TlRegistryEntry g_registry[] = {
      14              :     /* MTProto internal */
      15              :     { TL_rpc_result,            "rpc_result" },
      16              :     { TL_rpc_error,             "rpc_error" },
      17              :     { TL_gzip_packed,           "gzip_packed" },
      18              :     { TL_msg_container,         "msg_container" },
      19              :     { TL_msgs_ack,              "msgs_ack" },
      20              :     { TL_bad_msg_notification,  "bad_msg_notification" },
      21              :     { TL_bad_server_salt,       "bad_server_salt" },
      22              :     { TL_new_session_created,   "new_session_created" },
      23              :     { TL_pong,                  "pong" },
      24              :     { TL_future_salts,          "future_salts" },
      25              :     { TL_destroy_session_ok,    "destroy_session_ok" },
      26              :     { TL_destroy_session_none,  "destroy_session_none" },
      27              : 
      28              :     /* Auth (DH exchange) */
      29              :     { TL_resPQ,                 "resPQ" },
      30              :     { TL_server_DH_params_ok,   "server_DH_params_ok" },
      31              :     { TL_server_DH_params_fail, "server_DH_params_fail" },
      32              :     { TL_dh_gen_ok,             "dh_gen_ok" },
      33              :     { TL_dh_gen_retry,          "dh_gen_retry" },
      34              :     { TL_dh_gen_fail,           "dh_gen_fail" },
      35              : 
      36              :     /* auth.* */
      37              :     { TL_auth_sentCode,         "auth.sentCode" },
      38              :     { TL_auth_authorization,    "auth.authorization" },
      39              : 
      40              :     /* account.* (2FA / SRP) */
      41              :     { TL_account_password,      "account.password" },
      42              :     { TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow,
      43              :                                 "passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow" },
      44              :     { TL_passwordKdfAlgoUnknown, "passwordKdfAlgoUnknown" },
      45              :     { TL_inputCheckPasswordSRP, "inputCheckPasswordSRP" },
      46              :     { TL_inputCheckPasswordEmpty, "inputCheckPasswordEmpty" },
      47              : 
      48              :     /* User */
      49              :     { TL_user,                  "user" },
      50              :     { TL_userEmpty,             "userEmpty" },
      51              :     { TL_userFull,              "userFull" },
      52              : 
      53              :     /* Chat/Channel */
      54              :     { TL_chat,                  "chat" },
      55              :     { TL_chatEmpty,             "chatEmpty" },
      56              :     { TL_chatForbidden,         "chatForbidden" },
      57              :     { TL_channel,               "channel" },
      58              :     { TL_channelForbidden,      "channelForbidden" },
      59              : 
      60              :     /* Messages */
      61              :     { TL_message,               "message" },
      62              :     { TL_messageEmpty,          "messageEmpty" },
      63              :     { TL_messageService,        "messageService" },
      64              :     { TL_messages_dialogs,      "messages.dialogs" },
      65              :     { TL_messages_dialogsSlice,       "messages.dialogsSlice" },
      66              :     { TL_messages_dialogsNotModified, "messages.dialogsNotModified" },
      67              :     { TL_messages_messages,     "messages.messages" },
      68              :     { TL_messages_messagesSlice,"messages.messagesSlice" },
      69              :     { TL_messages_channelMessages, "messages.channelMessages" },
      70              :     { TL_messages_affectedHistory, "messages.affectedHistory" },
      71              :     { TL_messages_affectedMessages, "messages.affectedMessages" },
      72              : 
      73              :     /* Media */
      74              :     { TL_messageMediaEmpty,     "messageMediaEmpty" },
      75              :     { TL_messageMediaPhoto,     "messageMediaPhoto" },
      76              :     { TL_messageMediaDocument,  "messageMediaDocument" },
      77              :     { TL_messageMediaGeo,       "messageMediaGeo" },
      78              :     { TL_messageMediaContact,   "messageMediaContact" },
      79              :     { TL_messageMediaWebPage,   "messageMediaWebPage" },
      80              : 
      81              :     /* Document/Photo */
      82              :     { TL_document,              "document" },
      83              :     { TL_documentEmpty,         "documentEmpty" },
      84              :     { TL_photo,                 "photo" },
      85              :     { TL_photoEmpty,            "photoEmpty" },
      86              :     { TL_photoSize,             "photoSize" },
      87              : 
      88              :     /* Contacts */
      89              :     { TL_contacts_contacts,     "contacts.contacts" },
      90              :     { TL_contacts_contactsNotModified, "contacts.contactsNotModified" },
      91              :     { TL_contacts_resolvedPeer, "contacts.resolvedPeer" },
      92              : 
      93              :     /* Updates */
      94              :     { TL_updates_state,         "updates.state" },
      95              :     { TL_updates_difference,    "updates.difference" },
      96              :     { TL_updates_differenceEmpty, "updates.differenceEmpty" },
      97              :     { TL_updates_differenceSlice, "updates.differenceSlice" },
      98              :     { TL_updateShort,           "updateShort" },
      99              :     { TL_updates,               "updates" },
     100              :     { TL_updatesCombined,       "updatesCombined" },
     101              :     { TL_updateNewMessage,      "updateNewMessage" },
     102              :     { TL_updateReadHistoryInbox, "updateReadHistoryInbox" },
     103              :     { TL_updateReadHistoryOutbox, "updateReadHistoryOutbox" },
     104              : 
     105              :     /* Peer */
     106              :     { TL_peerUser,              "peerUser" },
     107              :     { TL_peerChat,              "peerChat" },
     108              :     { TL_peerChannel,           "peerChannel" },
     109              :     { TL_inputPeerUser,         "inputPeerUser" },
     110              :     { TL_inputPeerChat,         "inputPeerChat" },
     111              :     { TL_inputPeerChannel,      "inputPeerChannel" },
     112              :     { TL_inputPeerSelf,         "inputPeerSelf" },
     113              :     { TL_inputPeerEmpty,        "inputPeerEmpty" },
     114              : 
     115              :     /* Config */
     116              :     { TL_config,                "config" },
     117              :     { TL_dcOption,              "dcOption" },
     118              :     { TL_nearestDc,             "nearestDc" },
     119              : 
     120              :     /* Bool */
     121              :     { TL_boolTrue,              "boolTrue" },
     122              :     { TL_boolFalse,             "boolFalse" },
     123              : 
     124              :     /* Vector */
     125              :     { TL_vector,                "vector" },
     126              : };
     127              : 
     128              : #define REGISTRY_SIZE (sizeof(g_registry) / sizeof(g_registry[0]))
     129              : 
     130            6 : const char *tl_constructor_name(uint32_t id) {
     131          218 :     for (size_t i = 0; i < REGISTRY_SIZE; i++) {
     132          217 :         if (g_registry[i].id == id) return g_registry[i].name;
     133              :     }
     134            1 :     return "unknown";
     135              : }
     136              : 
     137           28 : int tl_constructor_known(uint32_t id) {
     138         1201 :     for (size_t i = 0; i < REGISTRY_SIZE; i++) {
     139         1198 :         if (g_registry[i].id == id) return 1;
     140              :     }
     141            3 :     return 0;
     142              : }
        

Generated by: LCOV version 2.0-1