This commit is contained in:
Liam Waldron 2024-12-03 09:27:41 -05:00
commit 150f938a8e
9 changed files with 185 additions and 0 deletions

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# Highly Extreme Level Language Standard Library (stdhell)
stdhell is the standard library for my terrible programming language called HELL.
# Rationale
99% of hell just rips off the system's standard c library but for things that aren't there, I made this.
Some of these libraries are provided for abstraction, however. For example, the `rng` library provides a simple PRNG.
Same for the keygen library.
# Copyright
LGPL v3.0 or later

6
src/hellmath/Makefile Normal file
View File

@ -0,0 +1,6 @@
lib: main.c
$(CC) main.c -c -o hellmath.o
$(AR) -rc hellmath.a hellmath.o
install: hellmath.a
install hellmath.a $(PREFIX)/lib/stdhell

35
src/hellmath/main.c Normal file
View File

@ -0,0 +1,35 @@
/*
* main.c - Main library for hellmath
*
* This file is part of stdhell.
*
* Stdhell is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* Stdhell is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Stdhell. If
* not, see <https://www.gnu.org/licenses/>.
*/
int
check_prime(int n)
{
int divisors;
for (int i = 2; i <= n - 1; i++) {
if (n % i == 0) {
divisors++;
}
}
if (divisors > 0) {
return 1;
}
else {
return 0;
}
}

9
src/keygen/Makefile Normal file
View File

@ -0,0 +1,9 @@
include config.mk
all:
$(CC) -c main.c
$(AR) -rc keygen.a main.o
clean:
rm main.o
rm keygen.a

6
src/keygen/config.mk Normal file
View File

@ -0,0 +1,6 @@
#
# config.mk
#
CC = /bin/gcc
AR = /bin/ar

71
src/keygen/main.c Normal file
View File

@ -0,0 +1,71 @@
/*
main.c - keygen library
This file is part of stdhell.
stdhell is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
stdhell is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with stdhell. If not, see <https://www.gnu.org/licenses/>.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void
keygen_gen(int N)
{
int c = 0;
int randomizer = 0;
srand((unsigned int)(time(NULL)));
/* Characters to use for string generation */
char numbers[] = "1234567890";
char letter[] = "qwertyuiopasdfghjklzxcvbnm";
char LETTER[] = "QWERTYUIOPASDFGHJKLZXCVBNM";
char symbols[] = "!@#$%^&*?";
/* Variable for each individual password character */
char password[N];
/* Completed password string */
char complete_key[N];
randomizer = rand() % 4;
for (c = 0; c < N; c++) {
switch (randomizer) {
case 1:
password[c] = numbers[rand() % 10];
randomizer = rand() % 4;
complete_key[c] = password[c];
break;
case 2:
password[c] = symbols[rand() % 8];
randomizer = rand() % 4;
complete_key[c] = password[c];
break;
case 3:
password[c] = LETTER[rand() % 26];
randomizer = rand() % 4;
complete_key[c] = password[c];
break;
default:
password[c] = letter[rand() % 26];
randomizer = rand() % 4;
complete_key[c] = password[c];
}
}
return 0;
}

8
src/keygen/test.c Normal file
View File

@ -0,0 +1,8 @@
#include "test.h"
int
main()
{
keygen_gen(30);
printf("%s\n", complete_key[]);
}

6
src/keygen/test.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef TEST_H_
#define TEST_H_
void keygen_gen(int N);
#endif

29
src/rng/main.c Normal file
View File

@ -0,0 +1,29 @@
/*
main.c - keygen library
This file is part of stdhell.
stdhell is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
stdhell is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with stdhell. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int
rng_randint()
{
srand(time(0));
int n = rand();
}