Example #1
0
static int	connectory (const char *host, const char *port)
{
	AI	hints;
	AI *	results;
	int 	retval;
	int	s;

	memset(&hints, 0, sizeof(hints));
	hints.ai_flags = 0;
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = 0;

	if ((retval = getaddrinfo(host, port, &hints, &results))) {
	    yell("getaddrinfo(%s): %s", host, gai_strerror(retval));
	    my_exit(6);
	}

	if ((s = socket(results->ai_family, results->ai_socktype, results->ai_protocol)) < 0) {
	    yell("socket(%s): %s", host, gai_strerror(retval));
	    my_exit(6);
	}

	if (connect(s, results->ai_addr, results->ai_addrlen) < 0) {
	    yell("connect(%s): %s", host, strerror(errno));
	    my_exit(6);
	}

	freeaddrinfo(results);
	return s;
}
Example #2
0
static void
syscall_handler (struct intr_frame *f) 
{
  
  int call_num, ret;
  int *esp = (int *)f->esp;
  // khg : valid check
  if(!address_valid((void *)esp))
  {
      my_exit(-1);
  }

  call_num = *esp;
  
  if(call_num < SYS_HALT || call_num > SYS_INUMBER)
  {
      my_exit(-1);
  }

  // I don't know how to check... more good.
  if(call_num == SYS_EXIT || call_num == SYS_EXEC || call_num == SYS_WAIT ||   
     call_num == SYS_OPEN || call_num == SYS_FILESIZE || call_num == SYS_TELL ||
     call_num == SYS_CLOSE || call_num == SYS_REMOVE)
  {
    if(!address_valid(esp + 1))
    {
        my_exit(-1);
    }
      
  }
  else if(call_num == SYS_CREATE || call_num == SYS_READ || call_num == SYS_SEEK)
  {
    if(!address_valid(esp + 1) || !address_valid(esp + 2))
    {
        my_exit(-1);
    }
  }
  else if(call_num == SYS_READ || call_num == SYS_WRITE)
  {
    if(!address_valid(esp + 1) || !address_valid(esp + 2) || !address_valid(esp + 3))
    {
       my_exit(-1);
    }
  }
  // -- end valid check
  
  func_p func;
  func = syscall_table[call_num];

  f->eax = func(*(esp + 1), *(esp + 2), *(esp + 3));
   return;


 //NOT_REACHED ();
 //  origin code 
 // thread_exit ();
}
Example #3
0
int
inkey(void)
{
register int i = 257;
int noflush = 1;

  sleeptimes = 0;
  while (i > DEL)
  {
    if (!tty)
    {
      if ((i = telrcv(&noflush)) < 0)
	my_exit(0);
      if (block)
        i = 257;
      else if (i != 17)
        byte++;
    }
    else
      if (!INPUT_LEFT())
      {
        if (noflush)
        {
          fflush(stdout);
          noflush = 0;
        }
	do
	{
	  if (f_alarm)
	    alarmclock();
	  if (f_death)
	    my_exit(5);
	  if (XPENDING)
	    checkx(1);
	}
	while ((i = getchar()) < 0 && errno == EINTR);
	if (i < 0)
	  my_exit(0);
      }
      else
	i = getchar();
    if (lastcr && i == '\n' && !client)
      i = 255;
    lastcr = 0;
  }
  /* Change a couple values to the C/Unix standard */
  if (i == DEL)
    i = BS;
  else if (i == '\r')
  {
    i = '\n';
    lastcr = 1;
  }
  else if (i == CTRL_U)
    i = CTRL_X;
  return (i);
}
Example #4
0
void
alarmclock(void)
{
  f_alarm = 0;
  logintime += 5;
  sleeptimes += 5;
  alarm(mybtmp->time + (logintime + 5) * 60 - (msg->t = time(0)));
  xcount = xcount > logintime * 4 ? xcount : logintime * 4;
  postcount = postcount > logintime * 2 ? postcount : logintime * 2;

  if (!ouruser && nonew >= 0)
  {
    colorize("\n\n\a@CYou have exceeded the time limit for entering your name and password.\n\n");
    my_exit(10);
  }
  else if (nonew < 0 && logintime == 30)
  {
    colorize("\n\n\a@CYou have exceeded the time limit for entering your information.\n\n");
    my_exit(10);
  }
  else if (sleeptimes == 20 + 40 * !(!client))
  {
    colorize("\n\n\a@CYou have been logged out due to inactivity.\n\n");
    my_exit(10);
  }
  else if (logintime == 240)
  {
    colorize("\n\n\a@CYou have been on four hours.  That is plenty long enough.  Goodbye.\n\n");
    my_exit(10);
  }
  else if (logintime == 225)
  { 
    colorize("\n\n\a@YYou have 15 minutes left before you are logged out!\n\n");
    fflush(stdout);
  }
  else if (logintime == 235)
  {
    colorize("\n\n\a@YYou have 5 minutes left before you are logged out!\n\n");
    fflush(stdout);
  }
  if (sleeptimes == 15 + 40 * (client > 0))
  {
    colorize("\n\n\a@YHello???  Is anyone out there?\n@RYou will be logged off unless you start looking more alive!\n\n\a");
    fflush(stdout);
  }
  else if (client && sleeptimes >= 15)
  {
    dead = 1;
    putchar(IAC);
    putchar(CLIENT);
    fflush(stdout);
  } 

  if (ouruser && !guest && !(logintime % 30))
    msync((caddr_t)ouruser, sizeof(struct user), MS_ASYNC);
}
Example #5
0
void	canon_term(t_data *data)
{
  if (tgetent(NULL, "xterm") == ERR)
    my_exit("tgetent failed");
  if (tcgetattr(0, &data->term) == -1)
    my_exit("tcgetattr failed");
  data->term.c_lflag &= ~(ICANON);
  data->term.c_lflag &= ~(ECHO);
  data->term.c_cc[VMIN] = 1;
  data->term.c_cc[VTIME] = 0;
  if (tcsetattr(0, TCSANOW, &data->term) == -1)
    exit (3);
}
Example #6
0
void	malloc_double_tab(t_all *a)
{
  int	y;

  y = 0;
  if ((a->tab = malloc(a->ty * sizeof(char *))) == NULL)
    my_exit("Error -> malloc failed");
  while (y <= a->ty)
    {
      if ((a->tab[y] = malloc(sizeof(char) * a->tx)) == NULL)
	my_exit("Error -> malloc failed");
      y++;
    }
}
Example #7
0
t_node		*_input_isexit(t_node *list_start, int input)
{
  if (clear() == ERR || endwin() == ERR)
    my_exit(EXIT_FAILURE, "Failed to exit ncurses window!\n");
  if (input == MY_KEY_ESC)
    exit(EXIT_SUCCESS);
  else if (input == KEY_ENTER || input == '\n')
    {
      if (clear() == ERR || endwin() == ERR)
	my_exit(EXIT_FAILURE, "Failed to exit ncurses window!\n");
      return (list_start);
    }
  return (NULL);
}
Example #8
0
int		main()
{
  t_mysh	mysh;

  my_printf(GREEN "\t\t\t\t\tWelcome to mysh v_1\n\n" DEFAULT_COLOR);
  if (signal(SIGINT, SIG_IGN) == SIG_ERR)
    exit(0);
  recup_env(&mysh);
  if (my_getenv("PWD", &mysh) != 0)
    {
      if ((mysh.previous = my_strdup(mysh.recup_getenv)) == NULL)
	return (0);
    }
  else
    mysh.previous = NULL;
  while (42)
    {
      prompt(&mysh);
      if ((mysh.command = get_next_line(0, &mysh)) == NULL)
	{
	  my_putchar('\n');
	  my_exit(&mysh);
	}
      else
	init_command(&mysh);
    }
  return (0);
}
Example #9
0
void my_builtins(t_mysh *mysh)
{
  my_exit(mysh);
  my_cd(mysh);
  my_set_env(mysh);
  my_unset_env(mysh);
}
Example #10
0
void nrerror(const char error_text[])
{
	fprintf(stderr,"Run-time error...\n\n");
	fprintf(stderr,"%s\n\n",error_text);
	fprintf(stderr,"...now exiting to system...\n");
	my_exit("Bye!", -1);
}
Example #11
0
void            send_file(int sock, char buff[1024], char *file, char *path)
{
  char          filelocation[1024];
  FILE          *f;

  f = NULL;
  bzero(filelocation, 1024);
  strcat(filelocation, path);
  strcat(filelocation, "/");
  strcat(filelocation, file);
  puts(filelocation);
  f = fopen(filelocation, "r");
  if (f == NULL)
    {
      puts(filelocation);
      puts("the file does not exist");
      send_error(sock, "the file does not exist");
    }
  else
    {
      if (write(sock, buff, 1024) == -1)
	my_exit("fail to write on server", -1);
      do_send(sock, file, filelocation, f);
    }
}
Example #12
0
static int 
my_read(int fd, void *buffer, unsigned size)
{
	lock_acquire(&filesys_lock);
	if(!address_valid(buffer)){
		lock_release(&filesys_lock);
		my_exit(-1);
	}
	if(fd == STDIN_FILENO){
		unsigned i = 0;
		uint8_t* local_buffer = (uint8_t *)buffer;
		for(;i< size; i++)
			local_buffer[i] = input_getc();
		lock_release(&filesys_lock);
		return size;
	}
	
	struct file * fp = get_file_by_fd(fd);
	
	if(!fp){
		lock_release(&filesys_lock);
		return -1;
	}
	
	int byte = file_read(fp, buffer, size);
	lock_release(&filesys_lock);
	return byte;

}
Example #13
0
static char	*get_exec_dir(char *input, char **path)
{
  DIR		*dirp;
  struct dirent	*file;
  int		idx;
  char		*exec_dir;

  exec_dir = NULL;
  idx = 0;
  while (path != NULL && path[idx])
    {
      if ((dirp = opendir(path[idx])) != NULL)
	{
	  while ((file = readdir(dirp)) != NULL)
	    {
	      if (my_cmp(input, file->d_name))
		exec_dir = path[idx];
	    }
	  if (closedir(dirp) == -1)
	    my_exit(EXIT_FAILURE, "ERROR: closedir() failed.\n");
	}
      idx += 1;
    }
  return (exec_dir);
}
Example #14
0
int		check_player(t_game *game, t_allum *allum)
{
  if (game->player == 69)
    {
      my_exit(game, allum);
      return (-1);
    }
  else if (game->player == 42)
    {
      system("clear");
      my_putstr("Congratulation, you have found an EASTER EGGS\n");
      my_putstr("Loading");
      sleep(1);
      my_putchar('.');
      sleep(1);
      my_putchar('.');
      sleep(1);
      my_putstr(".\n");
      sleep(1);
      system("clear");
    }
  else if (game->player > 2 || game->player < 1)
    return (my_puterror("You can only choose 1 or 2 player."));
  return (0);
}
Example #15
0
int			main(int argc, char **argv)
{
  struct termios	oldline;
  t_area		ar;

  if (argc > 1)
    {
      non_canonical_mode(&oldline);
      init_term(&ar, argv, argc);
      display_arguments(&ar);
      while ((ar.len = read(0, ar.buff, sizeof(ar.buff))))
	{
	  x_read(ar.len);
	  init_lines(&ar, &oldline);
	  check_ctrl(&ar);
	  check_keys(&ar, ar.len);
	  check_select(&ar);
	  if (my_exit(&oldline, &ar) == 1 || void_exit(&ar, &oldline) == 1)
	    return (EXIT_SUCCESS);
	}
      restore_mode(&oldline, &ar);
      free_struct(&ar);
    }
  else
    my_put_error(ERR_ARGV);
  return (EXIT_SUCCESS);
}
Example #16
0
File: tools.c Project: j13s/devil
/* gives the current node corresponding to 'it' */
struct node *getnode(enum datastructs it) {
    switch (it) {
        case ds_wall:
        case ds_corner:
        case ds_producer:
        case ds_cube:
        case ds_flickeringlight:
            return view.pcurrcube;
            break;

        case ds_point:
            return view.pcurrpnt;
            break;

        case ds_sdoor:
        case ds_door:
            return view.pcurrdoor;
            break;

        case ds_thing:
            return view.pcurrthing;
            break;

        case ds_internal:
        case ds_leveldata:
            return NULL;

        default:
            fprintf(errf, "getdata: value of info not known: %d\n", it);
            my_exit();
    }

    return NULL;
}
Example #17
0
/*
** brief: we will try to find the good command
** @env: our env list
** @arr: contain the command and values
** return: 1 if we found our cmd but it's not cd, 0 if the cmd is not found
** and 2 if we have change the dir and 43 if exit
*/
static int	_my_builtin_fun(char **arr, t_list *env)
{
  char		*pwd;

  if (my_strcmp(arr[0], "exit", 0))
    return (my_exit(env, arr));
  else if (my_strcmp(arr[0], "env", 0))
    my_env(env, arr);
  else if (my_strcmp(arr[0], "cd", 0))
    return (my_cd(arr) + 1);
  else if (my_strcmp(arr[0], "pwd", 0))
    {
      pwd = my_find_element(env, "PWD");
      write(1, pwd, my_strlen(pwd));
      write(1, "\n", 1);
      return (1);
    }
  else if (my_strcmp(arr[0], "setenv", 0))
    my_setenv(env, arr);
  else if (my_strcmp(arr[0], "unsetenv", 0))
    my_unsetenv(env, arr);
  else
    return (0);
  return (1);
}
Example #18
0
int	exec_process(t_cmd *cmd, t_fds *fd, t_sh *shell,
                 int (*f)(char *cmd, char **argv, t_sh *shell))
{
  int	ret_exec;

  if ((cmd->pid.pid = check_perror("Fork", fork())) == 0)
    {
      if (cmd->pid.pgid != -1)
        {
          if (check_perror("Setpgid", setpgid(0, cmd->pid.pgid)) == -1)
            check_perror("Setpgid", setpgid(0, 0));
        }
      else
        check_perror("Setpgid", setpgid(0, 0));
      check_perror("Dup2", dup2(fd->stdin, 0));
      check_perror("Dup2", dup2(fd->stdout, 1));
      check_perror("Dup2", dup2(fd->stderr, 2));
      if ((ret_exec = f(cmd->cmd_fpath, cmd->argv, shell)) == -1)
        my_perror(cmd->cmd_fpath);
      my_exit(ret_exec);
      SETFLAG(shell->beepbeepexit, FLAGPOS(EXIT_FORK));
    }
  else if (cmd->pid.pid != -1)
    check_grp_set(cmd->pid.pid,
                  (cmd->pid.pgid == -1) ? cmd->pid.pid : cmd->pid.pgid);
  return (cmd->pid.pid);
}
Example #19
0
// 置換表のサイズを確保しなおす。
void TranspositionTable::resize(size_t mbSize) {

	size_t newClusterCount = size_t(1) << MSB64((mbSize * 1024 * 1024) / sizeof(Cluster));

	// 同じサイズなら確保しなおす必要はない。
	if (newClusterCount == clusterCount)
		return;

	clusterCount = newClusterCount;

	free(mem);

	// tableはCacheLineSizeでalignされたメモリに配置したいので、CacheLineSize-1だけ余分に確保する。
	// callocではなくmallocにしないと初回の探索でTTにアクセスするとき、特に巨大なTTだと
	// 極めて遅くなるので、mallocで確保して、ゼロクリアすることでこれを回避する。
	// cf. Explicitly zero TT upon resize. : https://github.com/official-stockfish/Stockfish/commit/2ba47416cbdd5db2c7c79257072cd8675b61721f
	mem = malloc(clusterCount * sizeof(Cluster) + CacheLineSize - 1);

	if (!mem)
	{
		std::cout << "info string Error : Failed to allocate " << mbSize
			<< "MB for transposition table. ClusterCount = " << newClusterCount << std::endl;
		my_exit();
	}

	table = (Cluster*)((uintptr_t(mem) + CacheLineSize - 1) & ~(CacheLineSize - 1));
}
Example #20
0
static void
my_timeout(int dummy ATTRIBUTE_UNUSED) {
  fprintf(stderr, "TIMEOUT\n");
  if (output_argument)
    fprintf(output_file, "TIMEOUT\n");
  my_exit(0);
}
Example #21
0
t_uchar		chck_exec_path(char *exec_path, char **argv)
{
  struct stat	file_data;

  if (exec_path == NULL || (exec_path[0] != '/' && exec_path[0] != '.')
      || access(exec_path, F_OK) == -1)
    {
      free(exec_path);
      my_dprintf(STDERR, "%S: Command not found.\n", argv[0]);
      return (1);
    }
  if (stat(exec_path, &file_data) == -1)
    my_exit(EXIT_FAILURE, "ERROR: stat() failed!\n");
  if (!S_ISREG(file_data.st_mode))
    {
      free(exec_path);
      my_dprintf(STDERR, "%S: Command not found.\n", argv[0]);
      return (1);
    }
  if (access(exec_path, X_OK) == -1)
    {
      my_dprintf(STDERR, "%s: Pemission denied.\n", exec_path);
      free(exec_path);
      return (1);
    }
  return (0);
}
Example #22
0
void g_suicide( void )
{
    out_msg( "\n\nWGML suicide\n\n" );
    if( GlobalFlags.research ) {        // TBD

        print_macro_dict( macro_dict, true );

        if( tag_dict != NULL ) {
            print_tag_dict( tag_dict );
        }
        print_single_funcs_research();
        print_multi_funcs_research();

        if( global_dict != NULL ) {
            print_sym_dict( global_dict );
        }
        print_sym_dict( sys_dict );
    }
    out_msg( "\n\nWGML suicide\n\n" );
    flushall();                         // TBD
    fcloseall();                        // TBD
    if( environment ) {
        longjmp( *environment, 1 );
    }
    my_exit( 16 );
}
Example #23
0
static pid_t
my_exec(const char *cmd_line)
{
    //printf("execute\n");
    if(!address_valid(cmd_line))
        my_exit(-1);

    struct thread *t = thread_current();
    //printf("process_execute start\n");
	tid_t tid = process_execute(cmd_line);
   	//printf("process_execute finish tid %d\n",tid);
    //printf("my_exec_new_tid : %d\n", tid);
    //printf("my_exec : %p, tid : %d, name : %s\n", t, t->tid, t->pname);
	struct child_process* cp = get_child_by_tid(tid);
	//printf("cp in exec : %p : load : %d\n", cp, cp->load);
    //printf("process_execute end tid: %d && cp->load : %d\n", tid, cp->load);

	 	while(cp->not_load == true)
        timer_sleep(1);
    if(cp->load == false)
        return -1;
   // printf("exec return tid: %d\n",tid);
    return tid;
	
}
Example #24
0
t_uchar		run_setenv(char ***env, char **argv)
{
  char		*tmp;

  if (count_args(argv) < 2)
    {
      my_printenv(*env, '\n');
      return (0);
    }
  else if (count_args(argv) > 3 || !my_str_isalpha(argv[1]) ||
	   (!my_char_islower(argv[1][0]) && !my_char_islower(argv[1][0])))
    {
      if (count_args(argv) > 3)
	my_dprintf(STDERR, "setenv: Too many arguments.\n");
      else if ((!my_char_islower(argv[1][0]) && !my_char_islower(argv[1][0])))
	my_dprintf(STDERR, "setenv: Variable name must begin with a letter.\n");
      else if (!my_str_isalpha(argv[1]))
	my_dprintf(STDERR, ERALPH);
      return (1);
    }
  if ((tmp = malloc(sizeof(char) * (my_strlen(argv[1]) + 2))) == NULL)
    my_exit(EXIT_FAILURE, "ERROR: Out of memory! malloc() failed\n");
  tmp = my_strncpy(tmp, argv[1], my_strlen(argv[1]));
  tmp = my_strncat(tmp, "=", 1);
  my_setenv(env, tmp, argv[2]);
  free(tmp);
  return (0);
}
Example #25
0
void
my_close(int fd)
{
	lock_acquire(&filesys_lock);

	struct thread *t = thread_current();
	struct list_elem *e = list_begin(&t->file_list);
	struct process_file *pf;
	int count = 0;
	while(e != list_end(&t->file_list)){
		pf = list_entry (e, struct process_file, elem);
		// khg : order is important
        e = list_next(e);
		if(fd == pf->fd || fd == CLOSE_ALL){
			file_allow_write(pf->file);
			file_close(pf->file);
			list_remove(&pf->elem);
			free(pf);
			count++;

            // khg : fd reset....
            //(t->fd)--;
			if(fd != CLOSE_ALL)
				break;

        }
	}
	
	lock_release(&filesys_lock);
	
	if(count == 0 && fd != CLOSE_ALL)
		my_exit(-1);
	
	return;
}
Example #26
0
/**
 * @brief Wrapper around MPI_Finalize
 *
 * This method prints the total time spent in MPI processes and during idle time
 * to the stdout. It also frees the node communicator.
 *
 * @return The error code of MPI_Finalize
 */
inline int MyMPI_Finalize() {
    int status = MPI_Comm_free(&MPIGlobal::nodecomm);
    if(status != MPI_SUCCESS) {
        std::cerr << "Error while freeing node communicator!" << std::endl;
        my_exit();
    }

    // deallocate communication buffers
    delete[] MPIGlobal::sendbuffer;
    delete[] MPIGlobal::recvbuffer;

    double locidletime, loccommtime;
    double totidletime, totcommtime;
    locidletime = MPIGlobal::idletimer.value();
    loccommtime = MPIGlobal::commtimer.value();
    // funny detail: calling MyMPI_Reduce below will increase the commtimer
    // we however do not take this (small) extra time in account, because we
    // already stored the old value and that one is communicated
    MyMPI_Reduce(&locidletime, &totidletime, 1, MPI_DOUBLE, MPI_SUM, 0);
    MyMPI_Reduce(&loccommtime, &totcommtime, 1, MPI_DOUBLE, MPI_SUM, 0);
    // we take the average over all MPI processes
    totidletime /= MPIGlobal::size;
    totcommtime /= MPIGlobal::size;
    std::cout << "Spent " << totidletime << "s waiting for other MPI processes"
              << std::endl;
    std::cout << "Spent " << totcommtime << "s in MPI communications"
              << std::endl;
    return MPI_Finalize();
}
Example #27
0
Note * build_note_list_from_input(void) {
    /* build the note list, also create the note array, also set N_notes */
    Event * e;
    Note * nl;
    e = build_event_list_and_beat_list_from_input();
    if (e == NULL) {
	fprintf(stderr, "%s: No notes in the input.\n", this_program);
	my_exit(1);
    }

    build_beat_array();
    
    global_DN_list = build_direct_note_list_from_event_list(e);

    compute_adjusted_direct_notes();

    free_event_list(e);

    e = build_event_list_from_direct_notes();
    
    nl = build_note_list_from_event_list(e);

    free_event_list(e);
    
    return nl;
}
Example #28
0
pascal OSStatus my_win_handler(EventHandlerCallRef handlerRef, EventRef event, void *userdata)                 {
  OSStatus os_result;
  UInt32 event_kind;

  os_result = eventNotHandledErr;

  // SysBeep(1);

  event_kind = GetEventKind(event);
  // show_alert("win handler", event_kind);
  if(event_kind == kEventWindowDrawContent)
  {
    update_window();
  } if(event_kind == kEventWindowClose) {

    // OG Use HALT_WANTTOQUIT pardigme
    //g_quit_sim_now = 1;
    set_halt_act(HALT_WANTTOQUIT);

#ifndef ACTIVEGS
    g_quit_seen = 1;
    my_exit(0);
#endif
  } else {
    //show_event(GetEventClass(event), event_kind, 0);
    update_window();
  }

  return os_result;
}
Example #29
0
int
my_systemv (const char *command, char *const argv[])
{
    my_fork_state_t fork_state;
    int status = 0;
    my_system_sigactions_t sigactions;

    my_system__save_sigaction_handlers (&sigactions);

    fork_state = my_fork ();
    switch (fork_state)
    {
    case FORK_ERROR:
        status = -1;
        break;
    case FORK_CHILD:
        {
            signal (SIGINT, SIG_DFL);
            signal (SIGQUIT, SIG_DFL);
            signal (SIGTSTP, SIG_DFL);
            signal (SIGCHLD, SIG_DFL);

            execvp (command, argv);
            my_exit (127);      /* Exec error */
        }
        break;
    default:
        status = 0;
        break;
    }
    my_system__restore_sigaction_handlers (&sigactions);

    return status;
}
Example #30
0
char	*convert_bin(int nb, int i)
{
  char	*str;
  int	a;
  int	r;

  a = 0;
  if ((str = malloc(sizeof(i))) == NULL)
    my_exit("MALLOC FAILED\n");
  while (i != -1)
    {
      r = my_pow(2, i);
      if (nb - r >= 0)
        {
          str[a] = '1';
          nb = nb - r;
        }
      else
        str[a] = '0';
      a++;
      i--;
    }
  str[a] = '\0';
  return (str);
}