2022-09-18 06:46:23 +00:00
|
|
|
/*
|
|
|
|
* @Author: 1ridic
|
|
|
|
* @Date: 2022-09-18 14:13:59
|
|
|
|
* @Last Modified by: 1ridic
|
2022-09-18 14:12:57 +00:00
|
|
|
* @Last Modified time: 2022-09-18 22:01:12
|
2022-09-18 06:46:23 +00:00
|
|
|
*/
|
2022-09-18 03:15:07 +00:00
|
|
|
#include <signal.h>
|
2022-09-18 03:24:31 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2022-09-18 03:44:39 +00:00
|
|
|
#include <stdlib.h>
|
2022-09-18 14:12:57 +00:00
|
|
|
#include <strings.h>
|
2022-09-18 05:14:30 +00:00
|
|
|
#include "loop.h"
|
2022-09-18 03:24:31 +00:00
|
|
|
|
2022-09-18 06:46:23 +00:00
|
|
|
char volatile isWaiting = 0;
|
2022-09-18 03:24:31 +00:00
|
|
|
void intHandler(int dummy) {
|
2022-09-18 12:43:39 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stdout,"\ndebug: enter soft-irq. isWaiting=%d\n",isWaiting);
|
|
|
|
#endif
|
|
|
|
if (isWaiting==1) {
|
2022-09-18 06:46:23 +00:00
|
|
|
return;
|
2022-09-18 12:43:39 +00:00
|
|
|
}
|
2022-09-18 14:12:57 +00:00
|
|
|
extern FILE* hf;
|
|
|
|
fprintf(stderr,"\nSIGINT exit.");
|
|
|
|
fclose(hf);
|
2022-09-18 03:44:39 +00:00
|
|
|
exit(EXIT_FAILURE);
|
2022-09-18 12:43:39 +00:00
|
|
|
|
2022-09-18 03:24:31 +00:00
|
|
|
}
|
2022-09-18 03:15:07 +00:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2022-09-18 06:53:38 +00:00
|
|
|
/* soft irq */
|
2022-09-18 03:24:31 +00:00
|
|
|
signal(SIGINT, intHandler);
|
2022-09-18 06:53:38 +00:00
|
|
|
/* clear screen */
|
|
|
|
fprintf(stdout,"\033[H\033[J");
|
2022-09-18 14:12:57 +00:00
|
|
|
/* open history file */
|
|
|
|
extern FILE* hf;
|
|
|
|
hf = fopen(strcat(getenv("HOME"), "/.dish_history"), "w");
|
|
|
|
|
2022-09-18 03:24:31 +00:00
|
|
|
#ifdef DEBUG
|
2022-09-18 06:53:38 +00:00
|
|
|
fprintf(stdout,"DEBUG is defined\n");
|
2022-09-18 03:24:31 +00:00
|
|
|
#endif
|
2022-09-18 03:44:39 +00:00
|
|
|
while (1) {
|
2022-09-18 05:14:30 +00:00
|
|
|
loop();
|
2022-09-18 03:24:31 +00:00
|
|
|
}
|
2022-09-18 14:12:57 +00:00
|
|
|
|
|
|
|
fclose(hf);
|
2022-09-18 03:24:31 +00:00
|
|
|
return 0;
|
2022-09-18 03:15:07 +00:00
|
|
|
}
|