block.h (1066B)
1 // 2 // block.h 3 // damus 4 // 5 // Created by William Casarin on 2023-04-09. 6 // 7 8 #ifndef block_h 9 #define block_h 10 11 #include "nostr_bech32.h" 12 #include "str_block.h" 13 14 #define MAX_BLOCKS 1024 15 16 enum block_type { 17 BLOCK_HASHTAG = 1, 18 BLOCK_TEXT = 2, 19 BLOCK_MENTION_INDEX = 3, 20 BLOCK_MENTION_BECH32 = 4, 21 BLOCK_URL = 5, 22 BLOCK_INVOICE = 6, 23 }; 24 25 26 typedef struct invoice_block { 27 struct str_block invstr; 28 union { 29 struct bolt11 *bolt11; 30 }; 31 } invoice_block_t; 32 33 typedef struct mention_bech32_block { 34 struct str_block str; 35 struct nostr_bech32 bech32; 36 } mention_bech32_block_t; 37 38 typedef struct note_block { 39 enum block_type type; 40 union { 41 struct str_block str; 42 struct invoice_block invoice; 43 struct mention_bech32_block mention_bech32; 44 int mention_index; 45 } block; 46 } block_t; 47 48 typedef struct note_blocks { 49 int words; 50 int num_blocks; 51 struct note_block *blocks; 52 } blocks_t; 53 54 void blocks_init(struct note_blocks *blocks); 55 void blocks_free(struct note_blocks *blocks); 56 57 #endif /* block_h */