You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifndef MAINH
|
|
|
|
#define MAINH
|
|
|
|
|
|
|
|
#define INITIAL_LINE_BUFFER 80
|
|
|
|
#define INITIAL_WORD_SIZE 80
|
|
|
|
#define INITIAL_NUM_ALIASES 50
|
|
|
|
#define INITIAL_NUM_VARIABLES 200
|
|
|
|
|
|
|
|
// the minimum size of an array, the automaic array allocator will not make
|
|
|
|
// arrays smaller than this
|
|
|
|
#define MIN_ARRAY_SIZE 50
|
|
|
|
|
|
|
|
#define NUM_BUILTINS 3
|
|
|
|
|
|
|
|
struct Alias {
|
|
|
|
char *name;
|
|
|
|
char *substitution;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ArrayElement {
|
|
|
|
void *value;
|
|
|
|
char *key;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct ArrayElement ArrayElement;
|
|
|
|
|
|
|
|
struct GrowingArray {
|
|
|
|
struct ArrayElement *inner;
|
|
|
|
int elements;
|
|
|
|
int space;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct GrowingArray GrowingArray;
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
struct Alias* aliases;
|
|
|
|
struct GrowingArray variables;
|
|
|
|
int num_aliases;
|
|
|
|
FILE* code;
|
|
|
|
|
|
|
|
FILE* input;
|
|
|
|
FILE* output;
|
|
|
|
|
|
|
|
bool interactive;
|
|
|
|
char *ps1;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct State State;
|
|
|
|
typedef struct Alias Alias;
|
|
|
|
|
|
|
|
#endif
|