Initial commit
parent
68793641c3
commit
91ac0ef53e
|
@ -0,0 +1,14 @@
|
|||
CC=gcc-11
|
||||
CFLAGS=-g -Wall -Wextra -O0
|
||||
LDFLAGS=
|
||||
SOURCES=main.c config.h structs.h
|
||||
OBJECTS=$(SOURCES:.cpp=.o)
|
||||
EXECUTABLE=work1
|
||||
|
||||
all: $(SOURCES) $(EXECUTABLE)
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
.cpp.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
Binary file not shown.
|
@ -0,0 +1,79 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
//#define DEBUG
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
// #include <malloc.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <locale.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// input console checking
|
||||
#define HELP_CONSOLE_OPTION_1 "-h"
|
||||
#define HELP_CONSOLE_OPTION_2 "--help"
|
||||
#define GENKEY_CONSOLE_OPTION "genkey"
|
||||
#define SIGNATURE_CONSOLE_OPTION "sign"
|
||||
#define CHECK_CONSOLE_OPTION "check"
|
||||
#define ENCRYPT_CONSOLE_OPTION "encrypt"
|
||||
#define DECRYPT_CONSOLE_OPTION "decrypt"
|
||||
#define SIZE_CONSOLE_OPTION "--size"
|
||||
#define PUBKEY_CONSOLE_OPTION "--pubkey"
|
||||
#define SECRET_CONSOLE_OPTION "--secret"
|
||||
#define SIGFILE_CONSOLE_OPTION "--sigfile"
|
||||
#define INFILE_CONSOLE_OPTION "--infile"
|
||||
#define OUTFILE_CONSOLE_OPTION "--outfile"
|
||||
|
||||
// boolean
|
||||
#define BOOL int
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
// RSA
|
||||
#define KEYSIZE_MODULE 256
|
||||
typedef enum {
|
||||
KEY_256 = 256,
|
||||
KEY_512 = 512,
|
||||
KEY_1024 = 1024,
|
||||
KEY_2048 = 2048
|
||||
} KEY_BIT_SIZE;
|
||||
|
||||
// file
|
||||
#define FILE_OPENING_ERROR "Cannot open the %s file.\n"
|
||||
|
||||
#define primes_128_bit_filename "primes_128_bit.blackleague"
|
||||
#define primes_256_bit_filename "primes_256_bit.blackleague"
|
||||
#define primes_512_bit_filename "primes_512_bit.blackleague"
|
||||
#define primes_1024_bit_filename "primes_1024_bit.blackleague"
|
||||
|
||||
/// <summary>
|
||||
/// Exit codes for exit()
|
||||
/// </summary>
|
||||
enum EXIT_CODE {
|
||||
SUCCESS,
|
||||
FAILURE,
|
||||
NO_ARGUMENTS_FAILURE,
|
||||
WRONG_ARGUMENT_FAILURE,
|
||||
NOT_ENOUGH_ARGUMENTS_FAILURE,
|
||||
FILE_OPEN_FAILURE,
|
||||
FILE_FORMAT_FAILURE,
|
||||
LOG_FAILURE,
|
||||
MEMORY_ALLOCATION_FAILURE,
|
||||
GET_PRIME_FAILURE,
|
||||
GET_NUMBER_FAILURE,
|
||||
DEBUG_EXIT_CODE = 100
|
||||
};
|
||||
|
||||
// fast funcs
|
||||
#define swap(a,b); b = a+b; a = b-a; b = b-a;
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
#define max(a,b) (a>b)? a : b
|
||||
#endif
|
||||
|
||||
#endif // !CONFIG_H
|
|
@ -0,0 +1,8 @@
|
|||
#include "structs.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
File new_file = createFile();
|
||||
printf("%s\n", new_file.creation_time);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#include "config.h"
|
||||
|
||||
#define extinsion_lenth 5
|
||||
#define filename_lenth 10
|
||||
#define creation_time_length 17
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char creation_time[creation_time_length+1];
|
||||
char filename[filename_lenth+1];
|
||||
char extension[extinsion_lenth+1];
|
||||
}File;
|
||||
|
||||
File createFile()
|
||||
{
|
||||
time_t time_now;
|
||||
struct tm* time_info;
|
||||
File result = {"\0","\0","\0"};
|
||||
|
||||
time(&time_now);
|
||||
time_info = localtime(&time_now);
|
||||
|
||||
strftime (result.creation_time,creation_time_length,"%T %D",time_info);
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue