mirror of
1
0
Fork 0

Moved tutils

This commit is contained in:
Tristan B. Kildaire 2020-05-06 10:37:20 +02:00
parent ad30290598
commit 0582f9189e
3 changed files with 32 additions and 13 deletions

View File

@ -6,7 +6,8 @@ EXE=bin/ped
all: install
$(CC) src/tty.c -o tty.o -c
$(CC) $(FLAGS) -o $(EXE) src/ped.c tty.o
$(CC) src/utils.c -o utils.o -c
$(CC) $(FLAGS) -o $(EXE) src/ped.c tty.o utils.o
test: clean all
./bin/ped test

View File

@ -40,18 +40,6 @@ int main(int argc, char** args)
return EXIT_SUCCESS;
}
void output(char* string, unsigned int length)
{
write(0, string, length);
}
char getChar()
{
char character;
int b = read(0, &character, 1);
return character;
}
void redraw(struct Session* session)
{
/* Move cursor back home */

30
src/utils.c Normal file
View File

@ -0,0 +1,30 @@
#include<string.h>
#include<unistd.h>
/**
* Writes a null-terminated string to the tty
*/
void writeStr(char* ntString)
{
write(0, ntString, strlen(ntString));
}
/**
* Writes bytes from buffer `string` of length
* `length` to the tty
*/
void output(char* string, unsigned int length)
{
write(0, string, length);
}
/**
* Reads and returns the single byte
* read from the tty.
*/
char getChar()
{
char character;
int b = read(0, &character, 1);
return character;
}