#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
|
|
/* If we are on Windows compile these functions */
|
|
#ifdef _WIN32
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
static char buffer[2048];
|
|
|
|
/* Fake readline function */
|
|
char* readline(char* prompt) {
|
|
fputs(prompt, stdout);
|
|
fgets(buffer, 2048, stdin);
|
|
char* cpy = malloc(strlen(buffer)+1);
|
|
assert(cpy != NULL)
|
|
strcpy(cpy, buffer);
|
|
cpy[strlen(cpy)-1] = '\0';
|
|
return cpy;
|
|
}
|
|
|
|
/* Fake add_history function */
|
|
void add_history(char* unused) {}
|
|
|
|
/* Otherwise include the editline headers
|
|
could use __APPLE__ for detection of OSX */
|
|
#else
|
|
#include <editline/readline.h>
|
|
#endif
|
|
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
/* Print version and exit information */
|
|
puts("Lispy version 0.0.0.0.1");
|
|
puts("Press Ctrl+c to exit\n");
|
|
|
|
/* In a never ending loop */
|
|
while (1) {
|
|
/* Output our prompt and get input */
|
|
char* input = readline("lispy> ");
|
|
|
|
/* Add input to history */
|
|
add_history(input);
|
|
|
|
/* Echo input back to user */
|
|
printf("No you're a %s\n", input);
|
|
|
|
/* Free retrieved input */
|
|
free(input);
|
|
}
|
|
|
|
return 0;
|
|
}
|