This repository has been archived by the owner on May 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcommon.h
68 lines (44 loc) · 1.74 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Copyright (C) 2014, 2015 Sen "Senorsen" Zhang <[email protected]>
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#ifndef _COMMON_H_
#define _COMMON_H_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#define TRUE 1
#define FALSE 0
typedef struct nodeWgDate {
int year, month, day;
int hour, minute, second;
} wgDate;
void print_function(const char * function_name);
uint16_t calc_checksum(uint8_t * data, uint16_t length);
uint16_t write_checksum(uint8_t * data, uint16_t length);
uint16_t read_checksum(uint8_t * data, uint16_t length);
int socket_init(int prog);
void socket_end();
int process_data(int prog, uint8_t control[2], uint8_t data[], uint16_t length, uint8_t * rets, uint16_t * ret_length);
int dec_fake_hex(uint16_t n);
void store_int16(uint16_t n, uint8_t * buf);
void store_int32(uint32_t n, uint8_t * buf);
uint16_t convert_int16(uint8_t * buf);
uint32_t convert_int32(uint8_t * buf);
int mask_check(uint8_t num, uint8_t pos);
void store_wiegand(uint32_t wiegand, uint8_t * buf);
uint32_t read_card_wiegand(uint8_t * buf);
uint32_t read_card_org_part(uint8_t * buf);
void store_wiegand_date(int type, int year, int month, int day, int hour, int minute, int second, uint8_t * buf);
wgDate read_wiegand_date(uint8_t * buf);
#endif