-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.c
37 lines (33 loc) · 969 Bytes
/
editor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "editor.h"
//Declarations.
char buffer[buffer_max_size];
char * message;
fstr *f_str;
const char * error_message = "You should use programm like this ./editor {file_name}\n";
//Start editor and print the state.
void start_editor(char * filename){
f_str = file_string_open(filename);
start_display(f_str);
}
// Main
int main(int argc, char * argv[]){
if(argc<2){
write(STDIN_FILENO,error_message,strlen(error_message));
return -1;
}
// Good case.!!!
else if(argc==2){
message = "Editor started\n";
snprintf(buffer,strlen(message)+1,message);
write(STDIN_FILENO,buffer,strlen(buffer));
start_editor(argv[1]);
}
else{
char * message = "You pushed too much arguments %d.\n";
sprintf(buffer,message,argc);
write(STDOUT_FILENO,buffer,strlen(buffer));
write(STDOUT_FILENO,error_message,strlen(error_message));
return -1;
}
return 0;
}