Esempio n. 1
0
/*
**  retourne le vrai path change le ~
*/
char	*eval_tild(char **my_env, char *path)
{
  char	*new_path;
  int	len1;
  char	*home;

  if ((exist_label("HOME", my_env) == 1) && (*path == '~'))
    {
      home = del_label(recup_line("HOME", my_env), "HOME");
      len1 = my_strlen(home);
      path++;
      len1 = len1 + my_strlen(path);
      if ((new_path = malloc(sizeof(*new_path) * (len1 + 1))) == NULL)
        exit(-1);
      my_strcpy(new_path, home);
      my_strcat(new_path, path);
      return (new_path);
    }
  return (path);
}
Esempio n. 2
0
/*
** Retourne le path adequate a a partir de la chaine path 
*/
char	*recup_goodpath(char **cmd, char *pathline)
{
  char	**path_tab;
  int	i;
  char	*full_path;

  i = 0;
  path_tab = my_str_to_wordtab2(del_label(pathline, "PATH"), ':');
  while (path_tab[i])
    {
      full_path = mk_fullpath(path_tab[i], cmd[0]);
      if (access(full_path, F_OK) == 0)
	{
	  my_free_tab(path_tab);
	  return (full_path);
	}
      i++;
      free(full_path);
    }
  my_free_tab(path_tab);
  return (NULL);
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
    char ans[2];
    char *fileargs[64];
    char *optargs[64];
    int n_options;
    int index;
    int help_flag = 0;

#ifdef __TURBOC__
    setvect(0x23, ctrlc_hndlr);
#else
    _dos_setvect(0x23, ctrlc_hndlr);
#endif
    atexit(on_exit);
    n_options = classify_args(argc, argv, fileargs, optargs);
    for (index=0;index<n_options;index++)
        {
        if (optargs[index][0] == '?') help_flag=1;
        else
            {
            myprintf("Invalid parameter - /",0);
            myprintf(optargs[index],0); /* removed strupr */
            myprintf("\r\n",0);
            exit(1);
            } /* end else. */

        } /* end for. */

    if (help_flag)
        {
        myprintf("\r\nLABEL Version " VERSION "\r\n", 0);
        myprintf("Creates, changes or deletes the volume label of a disk.\r\n",0);
        myprintf("\r\n",0);
        myprintf("Syntax: LABEL [drive:][label] [/?]\r\n",0);
        myprintf("  [drive:]  Specifies which drive you want to label\r\n",0);
        myprintf("  [label]   Specifies the new label you want to label the drive\r\n",0);
        myprintf("  /?        Displays this help message\r\n",0);
        return 0;
        } /* end if. */

    do_cmdline(argc, argv);
    if (*Drive == '?')  /* If no drive specified, use current. */
        GetDrive();

    /* Save current directory and move to root. */
    GetCurDir(curdir);
    if (curdir[0] != 0)
        {
        *rootdir = *Drive;
        SetCurDir(rootdir);
        } /* end if. */

    /* If no label was specified, show current one first and then get new one. */
    if (*Label == '\0')
        {
        disp_label();
        get_label();
        } /* end if. */

    /* If they entered an empty label, then ask them if they want to */
    /* delete the existing volume label. */
    if ((*Label == '\0') && (!NoLabel))
        {
        do
            {
            myprintf("\nDelete current volume label (Y/N)? ",0);
            mygets(ans,2); /* WHY not use getch? ??? */
            } /* end do. */
        while (((*ans=(char)toupper(*ans)) != 'Y') && (*ans != 'N'));

        if (toupper(*ans) == 'N')
            exit(1);

        } /* end if. */

    /* Delete the old volume label. */
    del_label();

    /* Create the new one, if there is one to create. */
    if (*Label != '\0')
        {
        if (make_label())
            {
            exit(1);
            } /* end if. */

        } /* end if. */

    exit(0);
    return 0;

} /* end main. */