-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_setup.h
43 lines (39 loc) · 1.25 KB
/
mod_setup.h
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
38
39
40
41
42
43
#ifndef _MOD_SETUP_H
#define _MOD_SETUP_H
#include <stdio.h>
#include <unistd.h>
#include <string.h>
extern void editcfg(char cfgpath[512]){
/* Var Init */
char editor[16] = "";
/* set editor */
if ((access("/bin/nano", F_OK)) != -1)
{strcpy(editor, "nano");}
else if ((access("/usr/bin/nano", F_OK)) != -1)
{strcpy(editor, "nano");}
else if ((access("/usr/local/bin/nano", F_OK)) != -1)
{strcpy(editor, "nano");}
else if ((access("/bin/vi", F_OK)) != -1)
{strcpy(editor, "vi");}
else if ((access("/usr/bin/vi", F_OK)) != -1)
{strcpy(editor, "vi");}
else if ((access("/usr/local/bin/vi", F_OK)) != -1)
{strcpy(editor, "vi");}
else if ((access("/bin/vim", F_OK)) != -1)
{strcpy(editor, "vim");}
else if ((access("/usr/bin/vim", F_OK)) != -1)
{strcpy(editor, "vim");}
else if ((access("/usr/local/bin/vim", F_OK)) != -1)
{strcpy(editor, "vim");}
else if ((access("/bin/emacs", F_OK)) != -1)
{strcpy(editor, "emacs");}
else if ((access("/usr/bin/emacs", F_OK)) != -1)
{strcpy(editor, "emacs");}
else if ((access("/usr/local/bin/emacs", F_OK)) != -1)
{strcpy(editor, "emacs");}
else
{printf("No editor (nano, vi, vim, emacs) found!"); exit(225);}
/* execute editor to edit cfg file */
execlp(editor, "edit config", cfgpath, NULL);
}
#endif