2024-02-01 20:02:30 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2024-02-02 17:52:21 +01:00
|
|
|
#include "constants.h"
|
2024-02-01 20:02:30 +01:00
|
|
|
#include "history.h"
|
2024-07-01 18:40:47 +02:00
|
|
|
#include "90s.h"
|
2024-02-11 02:01:28 +01:00
|
|
|
#include "job.h"
|
2024-02-01 20:02:30 +01:00
|
|
|
|
2024-02-08 20:49:11 +01:00
|
|
|
int execute(char **args);
|
|
|
|
|
2024-02-01 20:02:30 +01:00
|
|
|
// Function declarations for builtin commands
|
|
|
|
int cd(char **args);
|
|
|
|
int help(char **args);
|
|
|
|
int quit(char **args);
|
|
|
|
int history(char **args);
|
2024-02-02 17:52:21 +01:00
|
|
|
int export(char **args);
|
|
|
|
int source(char **args);
|
2024-02-11 02:01:28 +01:00
|
|
|
int j(char **args);
|
|
|
|
int bg(char **args);
|
2024-02-01 20:02:30 +01:00
|
|
|
|
|
|
|
// List of builtin commands' names
|
|
|
|
char *builtin_cmds[] = {
|
|
|
|
"cd",
|
|
|
|
"help",
|
|
|
|
"exit",
|
2024-02-02 17:52:21 +01:00
|
|
|
"history",
|
|
|
|
"export",
|
2024-02-11 02:01:28 +01:00
|
|
|
"source",
|
|
|
|
"j",
|
|
|
|
"bg",
|
2024-02-01 20:02:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int (*builtin_func[]) (char **) = {
|
|
|
|
&cd,
|
|
|
|
&help,
|
|
|
|
&quit, // cant name it exit as it is taken
|
2024-02-02 17:52:21 +01:00
|
|
|
&history,
|
|
|
|
&export,
|
2024-02-11 02:01:28 +01:00
|
|
|
&source,
|
|
|
|
&j,
|
|
|
|
&bg,
|
2024-02-01 20:02:30 +01:00
|
|
|
};
|
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
char *shortcut_dirs[] = {
|
2024-07-01 18:40:47 +02:00
|
|
|
"90s",
|
2024-02-11 02:01:28 +01:00
|
|
|
"bin",
|
|
|
|
"localbin",
|
|
|
|
};
|
|
|
|
|
|
|
|
char *shortcut_expand_dirs[] = {
|
2024-07-01 18:40:47 +02:00
|
|
|
"~/.nky/Coding/C/90s",
|
2024-02-11 02:01:28 +01:00
|
|
|
"~/.local/bin",
|
|
|
|
"/usr/local/bin",
|
|
|
|
};
|
|
|
|
|
|
|
|
char *gethome() {
|
|
|
|
char *home = getenv("HOME");
|
|
|
|
if (home == NULL) {
|
|
|
|
fprintf(stderr, "Error: HOME environment variable not set.\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
return home;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *replace_home_dir(char *str) {
|
|
|
|
char *home_path = gethome();
|
|
|
|
|
|
|
|
int path_len = strlen(str);
|
|
|
|
int home_len = strlen(home_path);
|
|
|
|
|
|
|
|
// Allocate memory for the new path
|
|
|
|
char* new_path = memalloc(sizeof(char) * (path_len + home_len + 1));
|
|
|
|
|
|
|
|
int i = 0, j = 0;
|
|
|
|
while (str[i] != '\0') {
|
|
|
|
if (str[i] == '~') {
|
|
|
|
// Copy HOME environment variable value
|
|
|
|
for (int k = 0; k < home_len; k++) {
|
|
|
|
new_path[j++] = home_path[k];
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
new_path[j++] = str[i++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new_path[j] = '\0';
|
|
|
|
return new_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *replace_absolute_home(char *str) {
|
|
|
|
char *home_path = gethome();
|
|
|
|
|
|
|
|
int path_len = strlen(str);
|
|
|
|
int home_len = strlen(home_path);
|
|
|
|
|
|
|
|
// Allocate memory for the new path
|
|
|
|
char* new_path = memalloc(sizeof(char) * (path_len - home_len + 2));
|
|
|
|
|
|
|
|
int i = 0, j = 0;
|
|
|
|
while (str[i] != '\0') {
|
|
|
|
if (strncmp(&str[i], home_path, home_len) == 0) {
|
|
|
|
// Copy HOME environment variable value
|
|
|
|
new_path[j++] = '~';
|
|
|
|
i += home_len;
|
|
|
|
} else {
|
|
|
|
new_path[j++] = str[i++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new_path[j] = '\0';
|
|
|
|
return new_path;
|
|
|
|
}
|
|
|
|
|
2024-02-01 20:02:30 +01:00
|
|
|
// number of built in commands
|
|
|
|
int num_builtins() {
|
|
|
|
return sizeof(builtin_cmds) / sizeof(char *);
|
|
|
|
}
|
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
// autojump
|
|
|
|
int j(char **args) {
|
|
|
|
if (args[1] == NULL) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: not enough arguments\n");
|
2024-02-11 02:01:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < sizeof(shortcut_dirs) / sizeof(char *); i++) {
|
|
|
|
int len = strlen(shortcut_dirs[i]);
|
|
|
|
if (strncmp(args[1], shortcut_dirs[i], len) == 0) {
|
|
|
|
char **merged_cd = memalloc(sizeof(char *) * 3);
|
|
|
|
merged_cd[0] = "cd";
|
|
|
|
merged_cd[1] = shortcut_expand_dirs[i];
|
|
|
|
merged_cd[2] = NULL;
|
|
|
|
cd(merged_cd);
|
|
|
|
printf("jumped to %s\n", shortcut_expand_dirs[i]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-02-01 20:02:30 +01:00
|
|
|
// change directory
|
|
|
|
int cd(char **args) {
|
2024-02-11 02:01:28 +01:00
|
|
|
int i = 0;
|
2024-02-01 20:02:30 +01:00
|
|
|
if (args[1] == NULL) {
|
2024-02-11 02:01:28 +01:00
|
|
|
char *home = gethome();
|
2024-02-01 20:02:30 +01:00
|
|
|
if (chdir(home) != 0) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-01 20:02:30 +01:00
|
|
|
}
|
|
|
|
} else {
|
2024-02-11 02:01:28 +01:00
|
|
|
while (args[1][i] != '\0') {
|
|
|
|
if (args[1][i] == '~') {
|
|
|
|
args[1] = replace_home_dir(args[1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2024-02-01 20:02:30 +01:00
|
|
|
if (chdir(args[1]) != 0) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-01 20:02:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// show help menu
|
|
|
|
int help(char **args) {
|
2024-07-01 18:40:47 +02:00
|
|
|
printf("90s %s\n", VERSION);
|
2024-02-01 20:02:30 +01:00
|
|
|
printf("Built in commands:\n");
|
|
|
|
|
|
|
|
for (int i = 0; i < num_builtins(); i++) {
|
|
|
|
printf(" %s\n", builtin_cmds[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Use 'man' to read manual of programs\n");
|
|
|
|
printf("Licensed under GPL v3\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int quit(char **args) {
|
|
|
|
return 0; // exit prompting loop, which also the shell
|
|
|
|
}
|
|
|
|
|
|
|
|
int history(char **args) {
|
2024-02-08 20:49:11 +01:00
|
|
|
char **history = get_all_history(true);
|
2024-02-01 20:02:30 +01:00
|
|
|
|
|
|
|
for (int i = 0; history[i] != NULL; ++i) {
|
|
|
|
printf("%s\n", history[i]);
|
|
|
|
free(history[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(history);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-02-02 17:52:21 +01:00
|
|
|
int export(char **args) {
|
|
|
|
args++; // skip the command
|
|
|
|
while (*args != NULL) {
|
|
|
|
char *variable = strtok(*args, "=\n");
|
|
|
|
char *value = strtok(NULL, "=\n");
|
|
|
|
if (variable != NULL && value != NULL) {
|
|
|
|
if (setenv(variable, value, 1) != 0) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: Error setting environment variable\n");
|
2024-02-02 17:52:21 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: Syntax error when setting environment variable\nUse \"export VARIABLE=VALUE\"\n");
|
2024-02-02 17:52:21 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
args++;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int source(char **args) {
|
|
|
|
if (args[1] == NULL) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: not enough arguments\n");
|
2024-02-02 17:52:21 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
FILE *file = fopen(args[1], "r");
|
|
|
|
|
|
|
|
if (file == NULL) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: no such file or directory '%s'\n", args[1]);
|
2024-02-02 17:52:21 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char line[RL_BUFSIZE];
|
|
|
|
int status;
|
|
|
|
while (fgets(line, sizeof(line), file) != NULL) {
|
|
|
|
// Remove newline character if present
|
|
|
|
size_t len = strlen(line);
|
|
|
|
if (len > 0 && line[len - 1] == '\n') {
|
|
|
|
line[len - 1] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
char **args = argsplit(line);
|
|
|
|
status = execute(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(file);
|
|
|
|
return status; // Indicate success
|
|
|
|
}
|
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
int bg(char **args) {
|
|
|
|
if (args[1] == NULL) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: not enough arguments\n");
|
2024-02-11 02:01:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
int job_index = atoi(args[1]);
|
|
|
|
if (job_index == 0) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: invalid job index\n");
|
2024-02-11 02:01:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
job *search = get_job(job_index - 1);
|
|
|
|
if (search == NULL) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: no such job\n");
|
2024-02-11 02:01:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
printf("Job %i: %s\n", job_index, search->command);
|
|
|
|
return 1;
|
|
|
|
}
|
2024-02-01 20:02:30 +01:00
|
|
|
bool is_builtin(char *command) {
|
|
|
|
for (int i = 0; i < num_builtins(); i++) {
|
|
|
|
if (strcmp(command, builtin_cmds[i]) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
int launch(char **args, int fd, int options) {
|
|
|
|
int is_bgj = (options & OPT_BGJ) ? 1 : 0;
|
|
|
|
int redirect_stdout = (options & OPT_STDOUT) ? 1 : 0;
|
|
|
|
int redirect_stdin = (options & OPT_STDIN) ? 1 : 0;
|
|
|
|
int redirect_stderr = (options & OPT_STDERR) ? 1 : 0;
|
|
|
|
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
int status;
|
|
|
|
if ((pid = fork()) == 0) {
|
|
|
|
// Child process
|
|
|
|
if (fd > 2) {
|
|
|
|
// not stdin, stdout, or stderr
|
|
|
|
if (redirect_stdout) {
|
|
|
|
if (dup2(fd, STDOUT_FILENO) == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (redirect_stdin) {
|
|
|
|
if (dup2(fd, STDIN_FILENO) == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (redirect_stderr) {
|
|
|
|
if (dup2(fd, STDERR_FILENO) == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close(fd); // close fd as it is duplicated already
|
|
|
|
}
|
|
|
|
if (execvp(args[0], args) == -1) {
|
|
|
|
if (errno == ENOENT) {
|
2024-07-01 18:40:47 +02:00
|
|
|
fprintf(stderr, "90s: command not found: %s\n", args[0]);
|
2024-02-11 02:01:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(EXIT_FAILURE); // exit the child
|
|
|
|
} else if (pid < 0) {
|
|
|
|
perror("fork failed");
|
|
|
|
} else {
|
|
|
|
// Parent process
|
|
|
|
if (is_bgj) {
|
|
|
|
int job_index = add_job(pid, args[0], true);
|
|
|
|
printf("[Job: %i] [Process ID: %i] [Command: %s]\n", job_index + 1, pid, args[0]);
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
waitpid(pid, &status, WUNTRACED); // wait child to be exited to return to prompt
|
|
|
|
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2024-02-01 20:02:30 +01:00
|
|
|
// execute built in commands or launch commands and wait it to terminate, return 1 to keep shell running
|
|
|
|
int execute(char **args) {
|
|
|
|
if (args[0] == NULL) { // An empty command was entered.
|
|
|
|
return 1;
|
|
|
|
}
|
2024-02-08 13:31:57 +01:00
|
|
|
|
|
|
|
// prioritize builtin commands
|
2024-02-01 20:02:30 +01:00
|
|
|
for (int i = 0; i < num_builtins(); i++) {
|
|
|
|
if (strcmp(args[0], builtin_cmds[i]) == 0) {
|
|
|
|
return (*builtin_func[i])(args);
|
|
|
|
}
|
|
|
|
}
|
2024-02-08 20:49:11 +01:00
|
|
|
int num_arg = 0;
|
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
while (args[num_arg] != NULL) {
|
|
|
|
if (strncmp(args[num_arg], "&", 1) == 0) {
|
|
|
|
args[num_arg] = NULL;
|
|
|
|
if (args[num_arg + 1] != NULL) {
|
|
|
|
// have commands after &
|
|
|
|
execute(&args[num_arg + 1]);
|
|
|
|
}
|
|
|
|
launch(args, STDOUT_FILENO, OPT_BGJ);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (strncmp(args[num_arg], ">", 1) == 0) {
|
|
|
|
int fd = fileno(fopen(args[num_arg + 1], "w+"));
|
|
|
|
if (fd == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
args[num_arg] = NULL;
|
|
|
|
int asdf = 0;
|
|
|
|
while (args[asdf] != NULL) {
|
|
|
|
fprintf(stderr, "args[%i]: %s\n", asdf, args[asdf]);
|
|
|
|
asdf++;
|
|
|
|
}
|
2024-02-01 20:02:30 +01:00
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
return launch(args, fd, OPT_FGJ | OPT_STDOUT);
|
|
|
|
}
|
|
|
|
if (strncmp(args[num_arg], "<", 1) == 0) {
|
|
|
|
int fd = fileno(fopen(args[num_arg + 1], "r"));
|
|
|
|
if (fd == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
return 1;
|
2024-02-01 20:02:30 +01:00
|
|
|
}
|
2024-02-11 02:01:28 +01:00
|
|
|
args[num_arg] = NULL;
|
|
|
|
return launch(args, fd, OPT_FGJ | OPT_STDIN);
|
2024-02-01 20:02:30 +01:00
|
|
|
}
|
2024-02-11 02:01:28 +01:00
|
|
|
if (strncmp(args[num_arg], "2>", 2) == 0) {
|
|
|
|
int fd = fileno(fopen(args[num_arg + 1], "w+"));
|
|
|
|
if (fd == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
args[num_arg] = NULL;
|
|
|
|
return launch(args, fd, OPT_FGJ | OPT_STDERR);
|
|
|
|
}
|
|
|
|
if (strncmp(args[num_arg], ">&", 2) == 0) {
|
|
|
|
int fd = fileno(fopen(args[num_arg + 1], "w+"));
|
|
|
|
if (fd == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
args[num_arg] = NULL;
|
|
|
|
return launch(args, fd, OPT_FGJ | OPT_STDOUT | OPT_STDERR);
|
|
|
|
}
|
|
|
|
if (strncmp(args[num_arg], ">>", 2) == 0) {
|
|
|
|
int fd = fileno(fopen(args[num_arg + 1], "a+"));
|
|
|
|
if (fd == -1) {
|
2024-07-01 18:40:47 +02:00
|
|
|
perror("90s");
|
2024-02-11 02:01:28 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
args[num_arg] = NULL;
|
|
|
|
return launch(args, fd, OPT_FGJ | OPT_STDOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
num_arg++; // count number of args
|
2024-02-01 20:02:30 +01:00
|
|
|
}
|
|
|
|
|
2024-02-11 02:01:28 +01:00
|
|
|
return launch(args, STDOUT_FILENO, OPT_FGJ);
|
2024-02-01 20:02:30 +01:00
|
|
|
}
|
2024-02-09 02:18:14 +01:00
|
|
|
|
|
|
|
// execute_pipe with as many pipes as needed
|
|
|
|
int execute_pipe(char ***args) {
|
|
|
|
int pipefd[2];
|
|
|
|
pid_t pid;
|
|
|
|
int in = 0;
|
|
|
|
|
2024-02-09 12:27:13 +01:00
|
|
|
int num_cmds = 0;
|
|
|
|
while (args[num_cmds] != NULL) {
|
2024-02-11 02:01:28 +01:00
|
|
|
int num_args = 0;
|
|
|
|
while (args[num_cmds][num_args] != NULL) {
|
|
|
|
num_args++;
|
|
|
|
}
|
2024-02-09 12:27:13 +01:00
|
|
|
num_cmds++;
|
2024-02-09 02:18:14 +01:00
|
|
|
}
|
2024-02-09 12:27:13 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < num_cmds - 1; i++) {
|
2024-02-09 02:18:14 +01:00
|
|
|
pipe(pipefd);
|
|
|
|
if ((pid = fork()) == 0) {
|
2024-02-09 18:20:38 +01:00
|
|
|
// then this (child)
|
|
|
|
dup2(in, STDIN_FILENO); // get input from previous command
|
2024-02-09 12:27:13 +01:00
|
|
|
if (i < num_cmds - 1) {
|
2024-02-09 18:20:38 +01:00
|
|
|
dup2(pipefd[1], STDOUT_FILENO); // make output go to pipe (next output)
|
2024-02-09 02:18:14 +01:00
|
|
|
}
|
2024-02-09 18:20:38 +01:00
|
|
|
close(pipefd[0]); // close original input
|
2024-02-11 02:01:28 +01:00
|
|
|
execute(args[i]);
|
|
|
|
exit(EXIT_SUCCESS);
|
2024-02-09 02:18:14 +01:00
|
|
|
} else if (pid < 0) {
|
|
|
|
perror("fork failed");
|
|
|
|
}
|
2024-02-09 18:20:38 +01:00
|
|
|
// this will be executed first
|
|
|
|
close(pipefd[1]); // close output
|
|
|
|
in = pipefd[0]; // save the input for the next command
|
2024-02-09 02:18:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((pid = fork()) == 0) {
|
2024-02-09 18:20:38 +01:00
|
|
|
dup2(in, STDIN_FILENO); // get input from pipe
|
2024-02-11 02:01:28 +01:00
|
|
|
execute(args[num_cmds - 1]);
|
|
|
|
exit(EXIT_SUCCESS);
|
2024-02-09 02:18:14 +01:00
|
|
|
} else if (pid < 0) {
|
|
|
|
perror("fork failed");
|
|
|
|
}
|
|
|
|
|
2024-02-09 12:27:13 +01:00
|
|
|
close(in);
|
|
|
|
for (int i = 0; i < num_cmds; i++) {
|
2024-02-11 02:01:28 +01:00
|
|
|
waitpid(pid, NULL, 0);
|
2024-02-09 02:18:14 +01:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|