Compare commits
No commits in common. "018003ebd45981594513f33887c426fec0c8149c" and "c8518218e526b892b0912de6e49635821140ec01" have entirely different histories.
018003ebd4
...
c8518218e5
10 changed files with 5635 additions and 68 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -78,6 +78,3 @@ Makefile
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,autotools
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,autotools
|
||||||
|
|
||||||
fckgw
|
|
||||||
*.o
|
|
||||||
*~
|
|
||||||
|
|
|
@ -1,7 +1 @@
|
||||||
SUBDIRS = src
|
SUBDIRS = src
|
||||||
AM_CFLAGS = -std=c17
|
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
|
|
||||||
run:
|
|
||||||
./src/fckgw
|
|
||||||
|
|
|
@ -2,5 +2,6 @@ AC_INIT([fckgw],[1.0])
|
||||||
AC_CONFIG_SRCDIR([src/main.c])
|
AC_CONFIG_SRCDIR([src/main.c])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
CFLAGS="$CFLAGS -std=c17"
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
6
configure.ac~
Normal file
6
configure.ac~
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
AC_INIT([fckgw], [1.0])
|
||||||
|
AC_CONFIG_SRCDIR([src/main.c])
|
||||||
|
AM_INIT_AUTOMAKE([-Wall -Wextra -Werror foreign])
|
||||||
|
AC_PROG_CC_STDC
|
||||||
|
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||||
|
AC_OUTPUT
|
5626
configure~
Executable file
5626
configure~
Executable file
File diff suppressed because it is too large
Load diff
|
@ -1,2 +1,2 @@
|
||||||
bin_PROGRAMS = fckgw
|
bin_PROGRAMS = fckgw
|
||||||
fckgw_SOURCES = main.c code.c
|
fckgw_SOURCES = main.c
|
||||||
|
|
24
src/code.c
24
src/code.c
|
@ -1,24 +0,0 @@
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/random.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include "code.h"
|
|
||||||
#include "errors.h"
|
|
||||||
|
|
||||||
int code_init(struct code *key) {
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
|
|
||||||
perror("Unable to read clock 'CLOCK_REALTIME'");
|
|
||||||
return ERR_CLOCK_READ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
key->unix_ts_sec = ts.tv_sec;
|
|
||||||
key->unix_ts_msec = ts.tv_nsec / 1000000;
|
|
||||||
key->purpose = ACCESS;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
23
src/code.h
23
src/code.h
|
@ -1,23 +0,0 @@
|
||||||
#include <stdint.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#ifdef __SIZEOF_INT128__
|
|
||||||
typedef unsigned __int128 uint128_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum code_purpose {
|
|
||||||
ACCESS,
|
|
||||||
DISCOUNT,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct code {
|
|
||||||
time_t unix_ts_sec;
|
|
||||||
long unix_ts_msec;
|
|
||||||
enum code_purpose purpose;
|
|
||||||
uint16_t rand_a;
|
|
||||||
uint64_t rand_b;
|
|
||||||
};
|
|
||||||
|
|
||||||
int code_init(struct code *key);
|
|
||||||
|
|
||||||
uint128_t code_convert_to_num(struct code *key);
|
|
|
@ -1 +0,0 @@
|
||||||
#define ERR_CLOCK_READ 1
|
|
11
src/main.c
11
src/main.c
|
@ -1,14 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "code.h"
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
struct code key;
|
return 0;
|
||||||
|
|
||||||
int key_init_err = code_init(&key);
|
|
||||||
if (key_init_err != 0) {
|
|
||||||
return key_init_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("unix_ts_sec: %ld, unix_ts_nsec: %ld, purpose: %d\n", key.unix_ts_sec, key.unix_ts_msec, key.purpose);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue