'
This commit is contained in:
parent
62ece126f9
commit
eac570d6f5
4 changed files with 56 additions and 3 deletions
47
micromake/src/micromake.c
Normal file
47
micromake/src/micromake.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#define BUFFER_SIZE 1024
|
||||
#define STRING_BUFFER_SIZE 32
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Helps to match a string (excludes blanks and special characters)
|
||||
int is_char(char c)
|
||||
{
|
||||
return c != '\0' && !isblank(c) && c != ':' && c != '=' && c != '#';
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Open file
|
||||
FILE *stream = fopen(argv[1], "r");
|
||||
if (stream == 0)
|
||||
errx(1, "Could not open file");
|
||||
|
||||
// Allocate buffer
|
||||
size_t buf_size = BUFFER_SIZE;
|
||||
char *buf = malloc(sizeof(char) * buf_size);
|
||||
if (buf == NULL)
|
||||
errx(1, "Could not allocate more memory");
|
||||
|
||||
// Read
|
||||
ssize_t nread;
|
||||
while ((nread = getline(&buf, &buf_size, stream)) != -1)
|
||||
{
|
||||
int i = 0;
|
||||
// Skip blanks
|
||||
while (i < nread && isblank(buf[i]))
|
||||
i++;
|
||||
|
||||
// Read target name
|
||||
size_t str_buf_size = STRING_BUFFER_SIZE;
|
||||
char *str_buf = malloc(sizeof(char) * str_buf_size);
|
||||
while (is_char(buf[i]))
|
||||
{
|
||||
}
|
||||
|
||||
// Read deps
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue