Professional Documents
Culture Documents
Code
Code
#include "main.h"
/**
* Return: no return
*/
char pwd[PATH_MAX];
getcwd(pwd, sizeof(pwd));
cp_pwd = _strdup(pwd);
my_directory = my_data_sh->args[1];
if (_strcmp(".", my_directory) == 0)
free(cp_pwd);
return;
if (_strcmp("/", cp_pwd) == 0)
free(cp_pwd);
return;
cp_strtok_pwd = cp_pwd;
rev_string(cp_strtok_pwd);
if (cp_strtok_pwd != NULL)
if (cp_strtok_pwd != NULL)
rev_string(cp_strtok_pwd);
if (cp_strtok_pwd != NULL)
chdir(cp_strtok_pwd);
else
chdir("/");
my_data_sh->status = 0;
free(cp_pwd);
/**
* by the user
* Return: no return
*/
char pwd[PATH_MAX];
getcwd(pwd, sizeof(pwd));
my_directory = my_data_sh->args[1];
if (chdir(my_directory) == -1)
get_error(my_data_sh, 2);
return;
cp_pwd = _strdup(pwd);
cp_dir = _strdup(my_directory);
free(cp_pwd);
free(cp_dir);
my_data_sh->status = 0;
chdir(my_directory);
/**
*/
char pwd[PATH_MAX];
getcwd(pwd, sizeof(pwd));
cp_pwd = _strdup(pwd);
if (p_oldpwd == NULL)
cp_oldpwd = cp_pwd;
else
cp_oldpwd = _strdup(p_oldpwd);
if (chdir(cp_oldpwd) == -1)
else
free(cp_pwd);
if (p_oldpwd)
free(cp_oldpwd);
my_data_sh->status = 0;
chdir(p_pwd);
/**
* Return: no return
*/
char pwd[PATH_MAX];
getcwd(pwd, sizeof(pwd));
p_pwd = _strdup(pwd);
if (home == NULL)
free(p_pwd);
return;
if (chdir(home) == -1)
{
get_error(my_data_sh, 2);
free(p_pwd);
return;
free(p_pwd);
my_data_sh->status = 0;
cmd_exec
#include "main.h"
/**
*/
if (path[*i] == ':')
return (1);
*i += 1;
if (path[*i])
*i += 1;
return (0);
/**
*/
if (path)
ptr_path = _strdup(path);
len_cmd = _strlen(cmd);
i = 0;
if (is_cdir(path, &i))
if (stat(cmd, &st) == 0)
return (cmd);
len_dir = _strlen(token_path);
dir = malloc(len_dir + len_cmd + 2);
_strcpy(dir, token_path);
_strcat(dir, "/");
_strcat(dir, cmd);
_strcat(dir, "\0");
if (stat(dir, &st) == 0)
free(ptr_path);
return (dir);
free(dir);
free(ptr_path);
if (stat(cmd, &st) == 0)
return (cmd);
return (NULL);
if (cmd[0] == '/')
if (stat(cmd, &st) == 0)
return (cmd);
return (NULL);
/**
*/
int i;
char *input;
input = datash->args[0];
if (input[i] == '.')
if (input[i + 1] == '.')
return (0);
if (input[i + 1] == '/')
continue;
else
break;
if (input[i + 1] == '.')
continue;
i++;
break;
else
break;
if (i == 0)
return (0);
if (stat(input + i, &st) == 0)
{
return (i);
get_error(datash, 127);
return (-1);
/**
*/
if (dir == NULL)
get_error(datash, 127);
return (1);
if (_strcmp(datash->args[0], dir) != 0)
get_error(datash, 126);
free(dir);
return (1);
free(dir);
}
else
get_error(datash, 126);
return (1);
return (0);
/**
* Return: 1 on success.
*/
pid_t pd;
pid_t wpd;
int state;
int exec;
char *dir;
(void) wpd;
exec = is_executable(datash);
if (exec == -1)
return (1);
if (exec == 0)
if (check_error_cmd(dir, datash) == 1)
return (1);
pd = fork();
if (pd == 0)
if (exec == 0)
else
dir = datash->args[0];
perror(datash->av[0]);
return (1);
else
do {
return (1);
}
env1
#include "main.h"
/**
*/
int i;
if (nenv[i] != name[i])
return (0);
return (i + 1);
/**
*/
char *ptr_env;
int i, mov;
ptr_env = NULL;
mov = 0;
if (mov)
ptr_env = _environ[i];
break;
/**
*
* @datash: data relevant.
* Return: 1 on success.
*/
int i, j;
datash->status = 0;
return (1);
Env2
#include "main.h"
/**
* copy_info - copies info to create
* a new env or alias
* @name: name (env or alias)
* @value: value (env or alias)
*
* Return: new env or alias.
*/
char *copy_info(char *name, char *value)
{
char *new;
int len_name, len_value, len;
len_name = _strlen(name);
len_value = _strlen(value);
len = len_name + len_value + 2;
new = malloc(sizeof(char) * (len));
_strcpy(new, name);
_strcat(new, "=");
_strcat(new, value);
_strcat(new, "\0");
return (new);
}
/**
* set_env - sets an environment variable
*
* @name: name of the environment variable
* @value: value of the environment variable
* @datash: data structure (environ)
* Return: no return
*/
void set_env(char *name, char *value, data_shell *datash)
{
int i;
char *var_env, *name_env;
for (i = 0; datash->_environ[i]; i++)
{
var_env = _strdup(datash->_environ[i]);
name_env = _strtok(var_env, "=");
if (_strcmp(name_env, name) == 0)
{
free(datash->_environ[i]);
datash->_environ[i] = copy_info(name_env, value);
free(var_env);
return;
}
free(var_env);
}
/**
* _setenv - compares env variables names
* with the name passed.
* @datash: data relevant (env name and env value)
*
* Return: 1 on success.
*/
int _setenv(data_shell *datash)
{
if (datash->args[1] == NULL || datash->args[2] == NULL)
{
get_error(datash, -1);
return (1);
}
return (1);
}
execute_some_line
/**
* _unsetenv - deletes a environment variable
*
* @datash: data relevant (env name)
*
* Return: 1 on success.
*/
int _unsetenv(data_shell *datash)
{
char **realloc_environ;
char *var_env, *name_env;
int i, j, k;
if (datash->args[1] == NULL)
{
get_error(datash, -1);
return (1);
}
k = -1;
for (i = 0; datash->_environ[i]; i++)
{
var_env = _strdup(datash->_environ[i]);
name_env = _strtok(var_env, "=");
if (_strcmp(name_env, datash->args[1]) == 0)
{
k = i;
}
free(var_env);
}
if (k == -1)
{
get_error(datash, -1);
return (1);
}
realloc_environ = malloc(sizeof(char *) * (i));
for (i = j = 0; datash->_environ[i]; i++)
{
if (i != k)
{
realloc_environ[j] = datash->_environ[i];
j++;
}
}
realloc_environ[j] = NULL;
free(datash->_environ[k]);
free(datash->_environ);
datash->_environ = realloc_environ;
return (1);
}
#include "main.h"
/**
* exec_line - finds builtins and commands
*
* @my_data_sh: data relevant (args)
* Return: 1 on success.
*/
int exec_line(data_shell *my_data_sh)
{
int (*builtin)(data_shell *my_data_sh);
if (my_data_sh->args[0] == NULL)
return (1);
builtin = get_builtin(my_data_sh->args[0]);
if (builtin != NULL)
return (builtin(my_data_sh));
return (cmd_exec(my_data_sh));
}
get_error
#include "main.h"
/**
* get_error - calls the error according the builtin, syntax or permission
* @datash: data structure that contains arguments
* @eval: error value
* Return: error
*/
int get_error(data_shell *datash, int eval)
{
char *error;
switch (eval)
{
case -1:
error = error_env(datash);
break;
case 126:
error = error_path_126(datash);
break;
case 127:
error = error_not_found(datash);
break;
case 2:
if (_strcmp("exit", datash->args[0]) == 0)
error = error_exit_shell(datash);
else if (_strcmp("cd", datash->args[0]) == 0)
error = error_get_cd(datash);
break;
}
if (error)
{
write(STDERR_FILENO, error, _strlen(error));
free(error);
}
datash->status = eval;
return (eval);
}
get_line
#include "main.h"
/**
* bring_line - assigns the line var for get_line
* @lineptr: Buffer that store the input str
* @buffer: str that is been called to line
* @n: size of line
* @j: size of buffer
*/
void bring_line(char **lineptr, size_t *n, char *buffer, size_t j)
{
if (*lineptr == NULL)
{
if (j > BUFSIZE)
*n = j;
else
*n = BUFSIZE;
*lineptr = buffer;
}
else if (*n < j)
{
if (j > BUFSIZE)
*n = j;
else
*n = BUFSIZE;
*lineptr = buffer;
}
else
{
_strcpy(*lineptr, buffer);
free(buffer);
}
}
/**
* get_line - Read inpt from stream
* @lineptr: buffer that stores the input
* @n: size of lineptr
* @stream: stream to read from
* Return: The number of bytes
*/
ssize_t get_line(char **lineptr, size_t *n, FILE *stream)
{
int i;
static ssize_t input;
ssize_t retval;
char *buffer;
char t = 'z';
if (input == 0)
fflush(stream);
else
return (-1);
input = 0;
/**
*/
(void)sig;
get_some_help
#include "main.h"
/**
* Return: Return 0
*/
{
if (my_data_sh->args[1] == 0)
aux_help_general();
aux_help_setenv();
aux_help_env();
aux_help_unsetenv();
aux_help();
aux_help_exit();
aux_help_cd();
aux_help_alias();
else
write(STDERR_FILENO, my_data_sh->args[0],
_strlen(my_data_sh->args[0]));
my_data_sh->status = 0;
return (1);
getting_some_builtin
#include "main.h"
/**
* @cmd: command
*/
int (*get_builtin(char *cmd))(data_shell *)
builtin_t blt_in[] = {
{ "env", _env },
{ "exit", exit_shell },
{ "setenv", _setenv },
{ "unsetenv", _unsetenv },
{ "cd", cd_shell },
{ "help", get_help },
{ NULL, NULL }
};
int m;
if (_strcmp(blt_in[m].name, cmd) == 0)
break;
return (blt_in[m].f);
help_auxios
#include "main.h"
/**
* Return: no return
*/
void aux_help_env(void)
/**
* Return: no return
*/
void aux_help_setenv(void)
char *may_be_some_help = "setenv: setenv (const char *name, const char *value,";
/**
* Return: no return
*/
void aux_help_unsetenv(void)
/**
* aux_help_general - Entry point for help information for the help builtin
* Return: no return
*/
void aux_help_general(void)
may_be_some_help = "These commands are defined internally.Type 'help' to see the list";
may_be_some_help = "Type 'help name' to find out more about the function 'name'.\n\n ";
may_be_some_help = " alias: alias [name=['string']]\n cd: cd [-L|[-P [-e]] [-@]] ";
may_be_some_help = "[dir]\nexit: exit [n]\n env: env [option] [name=value] [command ";
/**
* Return: no return
*/
void aux_help_exit(void)
{
help_auxios2
#include "main.h"
/**
* Return: no return
*/
void aux_help(void)
/**
* Return: no return
*/
void aux_help_alias(void)
{
/**
* Return: no return
*/
void aux_help_cd(void)
lists_auxios
#include "main.h"
/**
* of a sep_list.
*/
{
sep_list *new, *temp;
new = malloc(sizeof(sep_list));
if (new == NULL)
return (NULL);
new->separator = my_sepr;
new->next = NULL;
temp = *hd;
if (temp == NULL)
*hd = new;
else
temp = temp->next;
temp->next = new;
return (*hd);
/**
* Return: no return.
*/
{
sep_list *temp;
sep_list *curr;
if (hd != NULL)
curr = *hd;
curr = curr->next;
free(temp);
*hd = NULL;
/**
* of a line_list.
*/
new = malloc(sizeof(line_list));
if (new == NULL)
return (NULL);
new->line = line;
new->next = NULL;
temp = *hd;
if (temp == NULL)
*hd = new;
else
temp = temp->next;
temp->next = new;
return (*hd);
/**
* Return: no return.
*/
line_list *temp;
line_list *curr;
if (hd != NULL)
curr = *hd;
curr = curr->next;
free(temp);
*hd = NULL;
lists_auxios2
#include "main.h"
/**
* of a r_var list.
*/
my_new = malloc(sizeof(r_var));
if (my_new == NULL)
return (NULL);
my_new->len_var = lvar;
my_new->val = val;
my_new->len_val = lval;
my_new->next = NULL;
my_temp = *hd;
if (my_temp == NULL)
*hd = my_new;
else
my_temp = my_temp->next;
my_temp->next = my_new;
return (*hd);
/**
* Return: no return.
*/
r_var *my_temp;
r_var *my_currently;
if (hd != NULL)
my_currently = *hd;
my_currently = my_currently->next;
free(my_temp);
*hd = NULL;
Main
#include "main.h"
/**
* Return: no return
*/
unsigned int i;
free(datash->_environ[i]);
free(datash->_environ);
free(datash->pid);
/**
* Return: no return
*/
unsigned int i;
datash->av = av;
datash->input = NULL;
datash->args = NULL;
datash->status = 0;
datash->counter = 1;
datash->_environ[i] = _strdup(environ[i]);
datash->_environ[i] = NULL;
datash->pid = aux_itoa(getpid());
/**
* Return: 0 on success.
*/
data_shell datash;
(void) ac;
signal(SIGINT, get_sigint);
set_data(&datash, av);
shell_loop(&datash);
free_data(&datash);
if (datash.status < 0)
return (255);
return (datash.status);
Main.h
#ifndef MAIN
#define MAIN
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <limits.h>
/**
*/
char **av;
char *input;
char **args;
int status;
int counter;
char **_environ;
char *pid;
} data_shell;
/**
* @separator: ; | &
*/
char separator;
} sep_list;
/**
*/
char *line;
} line_list;
/**
*/
int len_var;
char *val;
int len_val;
} r_var;
/**
* @name: The name of the command builtin i.e cd, exit, env
*/
char *name;
} builtin_t;
/* aux_lists.c */
/* aux_lists2.c */
/* aux_mem.c */
/* aux_str2.c */
/* aux_str3.c */
/* check_syntax_error.c */
/* shell_loop.c */
/* read_line.c */
/* split.c */
/* rep_var.c */
/* get_line.c */
/* exec_line */
/* cmd_exec.c */
/* env2.c */
/* cd.c */
/* cd_shell.c */
/* get_builtin */
/* _exit.c */
/* aux_stdlib.c */
/* aux_error2.c */
/* get_error.c */
/* get_sigint.c */
/* aux_help.c */
void aux_help_env(void);
void aux_help_setenv(void);
void aux_help_unsetenv(void);
void aux_help_general(void);
void aux_help_exit(void);
/* aux_help2.c */
void aux_help(void);
void aux_help_alias(void);
void aux_help_cd(void);
/* get_help.c */
#endif
memo_auxios
#include "main.h"
/**
* Return: no return.
*/
unsigned int i;
char_newptr[i] = char_ptr[i];
/**
* Return: my_ptr.
*/
void *my_newptr;
if (my_ptr == NULL)
return (malloc(new_size));
if (new_size == 0)
free(my_ptr);
return (NULL);
if (new_size == old_size)
return (my_ptr);
my_newptr = malloc(new_size);
if (my_newptr == NULL)
return (NULL);
else
free(my_ptr);
return (my_newptr);
/**
* Return: ptr.
*/
char **my_newptr;
unsigned int i;
if (my_ptr == NULL)
if (new_size == old_size)
return (my_ptr);
if (my_newptr == NULL)
return (NULL);
my_newptr[i] = my_ptr[i];
free(my_ptr);
return (my_newptr);
reading_some_line
#include "main.h"
/**
*/
size_t my_bfr_sz = 0;
return (my_inpt);
rep_var
#include "main.h"
/**
* Return: no return
*/
char **_envr;
_envr = data->_environ;
if (_envr[row][chr] == '=')
return;
if (in[j] == _envr[row][chr])
j++;
else
break;
break;
}
/**
* Return: no return
*/
lst = _strlen(st);
lpd = _strlen(data->pid);
if (in[i] == '$')
if (in[i + 1] == '?')
else
check_env(h, in + i, data);
return (i);
/**
*/
r_var *indx;
int i, j, k;
indx = *head;
for (j = i = 0; i < nlen; i++)
if (input[j] == '$')
new_input[i] = input[j];
j++;
j++;
i--;
else
new_input[i] = indx->val[k];
i++;
j += (indx->len_var);
i--;
indx = indx->next;
else
new_input[i] = input[j];
j++;
}
return (new_input);
/**
*/
status = aux_itoa(datash->status);
head = NULL;
if (head == NULL)
free(status);
return (input);
indx = head;
nlen = 0;
indx = indx->next;
nlen += olen;
new_input[nlen] = '\0';
free(input);
free(status);
free_rvar_list(&head);
return (new_input);
shell_change_directory
#include "main.h"
/**
* Return: 1 on success
*/
char *my_directory;
my_directory = my_data_sh->args[1];
if (my_directory != NULL)
cd_to_home(my_data_sh);
return (1);
if (_strcmp("-", my_directory) == 0)
cd_previous(my_data_sh);
return (1);
cd_dot(my_data_sh);
return (1);
cd_to(my_data_sh);
return (1);
}
shell_exit
#include "main.h"
/**
* Return: 0 on success.
*/
int is_it_digit;
int my_string_l;
int my_bg_num;
if (my_data_sh->args[1] != NULL)
my_status = _atoi(my_data_sh->args[1]);
is_it_digit = _isdigit(my_data_sh->args[1]);
my_string_l = _strlen(my_data_sh->args[1]);
get_error(my_data_sh, 2);
my_data_sh->status = 2;
return (1);
}
return (0);
shell_loop
#include "main.h"
/**
*/
int i, up_to;
up_to = 0;
if (in[i] == '#')
if (i == 0)
free(in);
return (NULL);
up_to = i;
}
}
if (up_to != 0)
in[up_to] = '\0';
return (in);
/**
* Return: no return.
*/
char *input;
loop = 1;
while (loop == 1)
input = read_line(&i_eof);
if (i_eof != -1)
input = without_comment(input);
if (input == NULL)
continue;
if (check_syntax_error(datash, input) == 1)
datash->status = 2;
free(input);
continue;
datash->counter += 1;
free(input);
else
loop = 0;
free(input);
split
#include "main.h"
/**
*/
char *swap_char(char *input, int bool)
int i;
if (bool == 0)
if (input[i] == '|')
if (input[i + 1] != '|')
input[i] = 16;
else
i++;
if (input[i] == '&')
if (input[i + 1] != '&')
input[i] = 12;
else
i++;
else
return (input);
/**
* Return: no return
*/
int i;
char *line;
if (input[i] == ';')
add_sep_node_end(head_s, input[i]);
add_sep_node_end(head_s, input[i]);
i++;
}
line = _strtok(input, ";|&");
do {
add_line_node_end(head_l, line);
/**
* Return: no return
*/
int loop_sep;
sep_list *ls_s;
line_list *ls_l;
loop_sep = 1;
ls_s = *list_s;
ls_l = *list_l;
if (datash->status == 0)
{
loop_sep = 0;
if (ls_s->separator == '|')
else
loop_sep = 0;
if (ls_s->separator == '&')
ls_s = ls_s->next;
*list_s = ls_s;
*list_l = ls_l;
/**
*/
{
sep_list *head_s, *list_s;
int loop;
head_s = NULL;
head_l = NULL;
list_s = head_s;
list_l = head_l;
datash->input = list_l->line;
datash->args = split_line(datash->input);
loop = exec_line(datash);
free(datash->args);
if (loop == 0)
break;
if (list_l != NULL)
list_l = list_l->next;
free_sep_list(&head_s);
free_line_list(&head_l);
if (loop == 0)
return (0);
return (1);
/**
*/
size_t bsize;
size_t i;
char **tokens;
char *token;
bsize = TOK_BUFSIZE;
if (tokens == NULL)
exit(EXIT_FAILURE);
tokens[0] = token;
if (i == bsize)
bsize += TOK_BUFSIZE;
if (tokens == NULL)
exit(EXIT_FAILURE);
tokens[i] = token;
return (tokens);
standar_lib_auxios
#include "main.h"
/**
*/
int get_len(int n)
int my_l = 1;
if (n < 0)
{
my_l++;
n1 = n * -1;
else
n1 = n;
my_l++;
n1 = n1 / 10;
return (my_l);
/**
* Return: String.
*/
char *aux_itoa(int n)
char *my_bfr;
if (my_bfr == 0)
return (NULL);
if (n < 0)
n1 = n * -1;
my_bfr[0] = '-';
else
n1 = n;
lenght--;
do
n1 = n1 / 10;
lenght--;
return (my_bfr);
/**
* Return: integer.
*/
if (sz > 0 && (*(s + my_counter) < '0' || *(s + my_counter) > '9'))
break;
pn *= -1;
{
if (sz > 0)
m *= 10;
sz++;
my_counter++;
m /= 10;
string_auxios
#include "main.h"
/**
*/
int m;
int n;
destination[m] = src[n];
m++;
destination[m] = '\0';
return (destination);
/**
*/
size_t a;
destination[a] = src[a];
destination[a] = '\0';
return (destination);
/**
* Return: Always 0.
*/
int m;
return (1);
return (-1);
return (0);
/**
* @s: string.
* @c: character.
*/
unsigned int i = 0;
if (*(s + i) == c)
return (s + i);
if (*(s + i) == c)
return (s + i);
return ('\0');
/**
*/
int m, n, bool;
bool = 1;
bool = 0;
break;
if (bool == 1)
break;
return (m);
string_auxios2
#include "main.h"
/**
*/
char *_strdup(const char *my_str)
char *my_new;
size_t my_l;
my_l = _strlen(my_str);
if (my_new == NULL)
return (NULL);
return (my_new);
/**
* Return: Always 0.
*/
int len;
return (len);
/**
*/
unsigned int m, n, o;
if (str[m] == delim[n])
o++;
break;
if (m == o)
return (1);
return (0);
/**
* @delim: delimiter.
*/
char *_strtok(char str[], const char *delim)
char *strat_string;
if (str != NULL)
if (cmp_chars(str, delim))
return (NULL);
i = _strlen(str);
strat_string = my_spliter;
return (NULL);
if (my_spliter != strat_string)
break;
if (*my_spliter == delim[i])
*my_spliter = '\0';
if (my_spliter == strat_string)
strat_string++;
break;
bool = 1;
return (NULL);
return (strat_string);
/**
*/
unsigned int i;
return (0);
return (1);
}
string_auxios3
#include "main.h"
/**
* Return: no return.
*/
int full_counter = 0, m, n;
if (s[full_counter] == '\0')
break;
full_counter++;
my_str = s;
}
}
syntax_err_checking
#include "main.h"
/**
* @i: index
* Return: repetitions
*/
if (*(my_inpt - 1) == *my_inpt)
return (i);
/**
* @m: index
* errors
*/
int full_counter;
full_counter = 0;
if (*my_inpt == '\0')
return (0);
if (*my_inpt == ';')
return (m);
if (*my_inpt == '|')
return (m);
if (my_lst == '|')
return (m);
if (*my_inpt == '&')
return (m);
if (my_lst == '&')
{
return (m);
/**
* @i: index
*/
continue;
return (-1);
break;
}
return (0);
/**
* Return: no return
*/
int my_l;
if (input[m] == ';')
if (bool == 0)
else
if (input[m] == '|')
if (input[m] == '&')
if (some_err == 0)
free(full_counter);
return;
_strcpy(some_err, my_data_sh->av[0]);
_strcat(some_err, full_counter);
_strcat(some_err, my_message2);
_strcat(some_err, my_message);
_strcat(some_err, my_message3);
_strcat(some_err, "\0");
free(some_err);
free(full_counter);
/**
*/
{
int begin = 0;
int f_char = 0;
int i = 0;
if (f_char == -1)
return (1);
if (i != 0)
return (1);
return (0);
we_get_err2
#include "main.h"
/**
*/
{
int my_l;
char *my_err;
char *ver_str;
char *my_message;
ver_str = aux_itoa(my_data_sh->counter);
if (my_err == 0)
free(my_err);
free(ver_str);
return (NULL);
_strcpy(my_err, my_data_sh->av[0]);
_strcat(my_err, ver_str);
_strcat(my_err, my_data_sh->args[0]);
_strcat(my_err, my_message);
_strcat(my_err, "\0");
free(ver_str);
return (my_err);
/**
int my_l;
char *ver_str;
char *my_err;
ver_str = aux_itoa(my_data_sh->counter);
if (my_err == 0)
free(my_err);
free(ver_str);
return (NULL);
_strcpy(my_err, my_data_sh->av[0]);
_strcat(my_err, ver_str);
_strcat(my_err, my_data_sh->args[0]);
_strcat(my_err, "\0");
free(ver_str);
return (my_err);
}
we_got_err1
#include "main.h"
/**
*/
char *illegal_flag;
_strcpy(my_err, my_data_sh->av[0]);
_strcat(my_err, my_ver_string);
_strcat(my_err, my_data_sh->args[0]);
_strcat(my_err, my_message);
if (my_data_sh->args[1][0] == '-')
illegal_flag = malloc(3);
illegal_flag[0] = '-';
illegal_flag[1] = my_data_sh->args[1][1];
illegal_flag[2] = '\0';
_strcat(my_err, illegal_flag);
free(illegal_flag);
}
else
_strcat(my_err, my_data_sh->args[1]);
_strcat(my_err, "\n");
_strcat(my_err, "\0");
return (my_err);
/**
*/
ver_str = aux_itoa(my_data_sh->counter);
if (my_data_sh->args[1][0] == '-')
my_l_id = 2;
else
my_l_id = _strlen(my_data_sh->args[1]);
}
my_l = _strlen(my_data_sh->av[0]) + _strlen(my_data_sh->args[0]);
if (my_err == 0)
free(ver_str);
return (NULL);
free(ver_str);
return (my_err);
/**
*/
int my_l;
char *my_err;
char *my_ver_string;
my_ver_string = aux_itoa(my_data_sh->counter);
if (my_err == 0)
free(my_err);
free(my_ver_string);
return (NULL);
_strcpy(my_err, my_data_sh->av[0]);
_strcat(my_err, my_ver_string);
_strcat(my_err, my_data_sh->args[0]);
_strcat(my_err, "\0");
free(my_ver_string);
return (my_err);
/**
*/
int my_l;
char *my_err;
char *my_ver_string;
my_ver_string = aux_itoa(my_data_sh->counter);
if (my_err == 0)
{
free(my_ver_string);
return (NULL);
_strcpy(my_err, my_data_sh->av[0]);
_strcat(my_err, my_ver_string);
_strcat(my_err, my_data_sh->args[0]);
_strcat(my_err, my_data_sh->args[1]);
_strcat(my_err, "\n\0");
free(my_ver_string);
return (my_err);