added nix build stuff

This commit is contained in:
Lexi Quinn 2023-07-18 23:53:22 +10:00
parent 9c7ccfe0b0
commit b208382e60
8 changed files with 50 additions and 56 deletions

View File

@ -1,5 +1,5 @@
TARGET = quest TARGET = quest
LIBS = -lm -luiohook -lcjson LIBS = -lm -luiohook -lcjson -lxcb -lXinerama -lX11
CC = gcc CC = gcc
CFLAGS = -g -Wall CFLAGS = -g -Wall
INSTALL_PATH = /usr/local INSTALL_PATH = /usr/local

2
default.nix Normal file
View File

@ -0,0 +1,2 @@
{pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./derivation.nix {}

23
derivation.nix Normal file
View File

@ -0,0 +1,23 @@
{ stdenv }:
stdenv.mkDerivation rec {
name = "quest-${version}";
version = "0.7";
src = ./src2/.;
nativeBuildInputs = [ ];
buildInputs = [ ];
buildPhase = ''
gcc server.c -o quest-daemon
gcc client.c -o quest-log
gcc tui.c -o quest
'';
installPhase = ''
mkdir -p $out/bin
cp quest-daemon $out/bin
cp quest-log $out/bin
cp quest $out/bin
'';
}

View File

@ -102,9 +102,9 @@ Runs by themselves are simply a list of events that occured
to this data, these more complicated directives are used to define segments to this data, these more complicated directives are used to define segments
that are played between splits and routes made up of these segments. that are played between splits and routes made up of these segments.
Define all your possible segments first, followed by all routes. Define all your possible segments first, followed by all routes.
If no segments are defined, a single unnamed segment is assumed. If no segments are defined, a single unnamed segment is to be assumed.
If no routes are defined, a single unnamed route that passes through all If no routes are defined, a single unnamed route that passes through all
segments in the order of their definition is assumed. segments in the order of their definition is to be assumed.
Segment Segment
Shortname Shortname
@ -141,7 +141,7 @@ Run Directives
These directives are much more complicated and are not intended to be written These directives are much more complicated and are not intended to be written
by a human but rather by the timer software, they will make up the majority by a human but rather by the timer software, they will make up the majority
of a file as they are the run history which may be quite long. of a file as they are the run history which may be quite long.
These data passed by these directives exists agnostic of segments, route, games, The data passed by these directives exists agnostic of segments, route, games,
or categories, rather they are either explicitly matched with metadata that is or categories, rather they are either explicitly matched with metadata that is
applicable, or by default is matched with the last set of metadata declared by applicable, or by default is matched with the last set of metadata declared by
the time of the run directive the time of the run directive

View File

@ -22,6 +22,7 @@ struct pastseg *pastRuns;
int segCount; int segCount;
int currSeg = -1; int currSeg = -1;
char currentTime[10]; char currentTime[10];
int *route;
void sub_timespec(struct timespec t1, struct timespec t2, struct timespec* td) void sub_timespec(struct timespec t1, struct timespec t2, struct timespec* td)
{ {

View File

@ -24,6 +24,7 @@
struct segment struct segment
{ {
int id;
char *name; char *name;
int ms; int ms;
bool isSkipped; bool isSkipped;
@ -49,6 +50,7 @@ extern struct segment *bestsegs;
extern struct segment *wrrun; extern struct segment *wrrun;
extern struct segment *segments; extern struct segment *segments;
extern struct timespec notif; extern struct timespec notif;
extern int *route;
void sub_timespec(struct timespec t1, struct timespec t2, struct timespec* td); void sub_timespec(struct timespec t1, struct timespec t2, struct timespec* td);
void add_timespec(struct timespec t1, struct timespec t2, struct timespec* td); void add_timespec(struct timespec t1, struct timespec t2, struct timespec* td);

View File

@ -220,10 +220,12 @@ void loadFiles()
fgets(buff2, 255, fp); fgets(buff2, 255, fp);
if (buff2[0] == '\t') { if (buff2[0] == '\t') {
valuecount++; valuecount++;
names = realloc(names, sizeof(char*) * valuecount); names = realloc(names, sizeof(char*) * valuecount);
names[valuecount - 1] = malloc(strlen(buff) - 1); names[valuecount - 1] = malloc(strlen(buff) - 1);
strncpy(names[valuecount - 1], buff, strlen(buff) - 1); strncpy(names[valuecount - 1], buff, strlen(buff) - 1);
names[valuecount - 1][strlen(buff)] = '\0'; names[valuecount - 1][strlen(buff)] = '\0';
values = realloc(values, sizeof(char*) * valuecount); values = realloc(values, sizeof(char*) * valuecount);
values[valuecount - 1] = malloc(strlen(buff2) - 2); values[valuecount - 1] = malloc(strlen(buff2) - 2);
strncpy(values[valuecount - 1], buff2 + 1, strlen(buff2) - 1); strncpy(values[valuecount - 1], buff2 + 1, strlen(buff2) - 1);
@ -373,43 +375,18 @@ int main(int argc, char *argv[])
exit(1); exit(1);
} }
/* Now start listening for the clients, here
* process will go in sleep mode and will wait
* for the incoming connection
*/
listen(sockfd,5); listen(sockfd,5);
clilen = sizeof(cli_addr); clilen = sizeof(cli_addr);
while (alive) { while (alive) {
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0) { if (newsockfd < 0) {
perror("ERROR on accept"); perror("ERROR on accept");
exit(1); exit(1);
} }
doprocessing(newsockfd);
/* Create child process */ close(newsockfd);
//pid = fork(); }
pid = 1;
if (pid < 0) {
perror("ERROR on fork");
exit(1);
}
if (pid == 0) {
/* This is the child process */
//close(sockfd);
//doprocessing(newsockfd);
//exit(0);
}
else {
doprocessing(newsockfd);
close(newsockfd);
}
} /* end of while */
free(run); free(run);
close(sockfd); close(sockfd);
} }

View File

@ -67,30 +67,19 @@ void printbig(int x, int y, int ms)
printf("\033[%d;%dH", y + sy, x); //go to position printf("\033[%d;%dH", y + sy, x); //go to position
for (int cc = 0; cc < 12; cc++) { //then, for every character for (int cc = 0; cc < 12; cc++) { //then, for every character
int c = small[cc]; //check what character we're on int c = small[cc]; //check what character we're on
if (c >= 48 && c <= 57) { //if its a number, print 4 pixels int mapcharacterwidth = (c >= 48 && c <= 57) ? 4 : 2;//if its a number, print 4 pixels, if its punctuation, print 2 pixels
for (int xx = 0; xx < 4; xx++) { int mapoffset;
int xxx = c - 48; if (c >= 48 && c <= 57)
if (numbermap[sy][(xxx * 4) + xx] == 'x') mapoffset = (c - 48) * 4;
printf("\033[48;2;%d;%d;%dm ", f.r, f.g, f.b); else if (c == 46)
if (numbermap[sy][(xxx * 4) + xx] == '.') mapoffset = 42;
printf("\033[48;2;%d;%d;%dm ", b.r, b.g, b.b); else
} mapoffset = 40;
} for (int xx = 0; xx < mapcharacterwidth; xx++) {
if (c == 46 || c == 58) { //if its punctuation, print 2 pixels if (numbermap[sy][mapoffset + xx] == 'x')
for (int xx = 0; xx < 2; xx++) { printf("\033[48;2;%d;%d;%dm ", f.r, f.g, f.b);
if (c == 46) { if (numbermap[sy][mapoffset + xx] == '.')
if (numbermap[sy][42 + xx] == 'x') printf("\033[48;2;%d;%d;%dm ", b.r, b.g, b.b);
printf("\033[48;2;%d;%d;%dm ", f.r, f.g, f.b);
if (numbermap[sy][42 + xx] == '.')
printf("\033[48;2;%d;%d;%dm ", b.r, b.g, b.b);
}
if (c == 58) {
if (numbermap[sy][40 + xx] == 'x')
printf("\033[48;2;%d;%d;%dm ", f.r, f.g, f.b);
if (numbermap[sy][40 + xx] == '.')
printf("\033[48;2;%d;%d;%dm ", b.r, b.g, b.b);
}
}
} }
} }
} }