MIKAI
Library to modify content of a Mykey
srix-flag.c
Go to the documentation of this file.
1 /*
2  * @author Lilz <https://telegram.me/Lilz73>
3  * @copyright 2020-2021 Lilz <https://telegram.me/Lilz73>
4  * @license MIKAI LICENSE
5  *
6  * This file is part of MIKAI.
7  *
8  * MIKAI is free software: you can redistribute it and/or modify
9  * it under the terms of the MIKAI License, as published by
10  * Lilz along with this program and available on "MIKAI Download" Telegram channel
11  * <https://telegram.me/mikaidownload>.
12  *
13  * MIKAI is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY.
15  *
16  * You should have received a copy of the MIKAI License along
17  * with MIKAI.
18  * If not, see <https://telegram.me/mikaidownload>.
19  */
20 
21 #include "srix-flag.h"
22 
23 void srixFlagAdd(SrixFlag flag[static 1], uint8_t block) {
24  /*
25  * Array:
26  * 0 -> 0-31
27  * 1-> 32-63
28  * 2-> 64-95
29  * 3-> 96-127
30  *
31  * Flag position bit between 0 and 31 in a single uint32_t
32  * (array of 4 uint32_t).
33  */
34  if (block < 128) {
35  flag->memory[block / 32] |= 1U << block % 32;
36  }
37 }
38 
39 bool srixFlagGet(SrixFlag flag[static 1], uint8_t block) {
40  if (block < 128) {
41  return flag->memory[block / 32] >> block % 32 & 1U;
42  } else {
43  return false;
44  }
45 }
SrixFlag
Struct that represents the modified blocks in a SRIX tag.
Definition: srix-flag.h:30
srixFlagAdd
void srixFlagAdd(SrixFlag flag[static 1], uint8_t block)
Definition: srix-flag.c:23
SrixFlag::memory
uint32_t memory[4]
Definition: srix-flag.h:31
srixFlagGet
bool srixFlagGet(SrixFlag flag[static 1], uint8_t block)
Definition: srix-flag.c:39
srix-flag.h