/* link utility for GNU.                                                        This is the link utility
   Copyright (C) 2001-2018 Free Software Foundation, Inc.                       
                                                                                
   This program is free software: you can redistribute it and/or modify         
   it under the terms of the GNU General Public License as published by         
   the Free Software Foundation, either version 3 of the License, or            
   (at your option) any later version.                                          
                                                                                
   This program is distributed in the hope that it will be useful,              
   but WITHOUT ANY WARRANTY; without even the implied warranty of               
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                
   GNU General Public License for more details.                                 
                                                                                
   You should have received a copy of the GNU General Public License            
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */   The GNUv3 license
                                                                                
/* Written by Michael Stone */                                                  
                                                                                
/* Implementation overview:                                                     
                                                                                
   Simply call the system 'link' function */                                    
                                                                                
#include <config.h>                                                             Provides system specific information
#include <stdio.h>                                                              Provides standard I/O capability
#include <getopt.h>                                                             ...!includes auto-comment...
#include <sys/types.h>                                                          Provides system data types
                                                                                
#include "system.h"                                                             ...!includes auto-comment...
#include "die.h"                                                                ...!includes auto-comment...
#include "error.h"                                                              ...!includes auto-comment...
#include "long-options.h"                                                       ...!includes auto-comment...
#include "quote.h"                                                              ...!includes auto-comment...
                                                                                
/* The official name of this program (e.g., no 'g' prefix).  */                 
#define PROGRAM_NAME "link"                                                     Line 35
                                                                                
#define AUTHORS proper_name ("Michael Stone")                                   Line 37
                                                                                
static struct option const long_options[] =                                     Line 39
{                                                                               
  {NULL, 0, NULL, 0}                                                            Line 41
};                                                                              Block 1
                                                                                
void                                                                            Line 44
usage (int status)                                                              Line 45
{                                                                               
  if (status != EXIT_SUCCESS)                                                   Line 47
    emit_try_help ();                                                           ...!common auto-comment...
  else                                                                          Line 49
    {                                                                           
      printf (_("\                                                              Line 51
Usage: %s FILE1 FILE2\n\                                                        Line 52
  or:  %s OPTION\n"), program_name, program_name);                              Line 53
      fputs (_("Call the link function to create a link named FILE2\            Line 54
 to an existing FILE1.\n\n"),                                                   Line 55
             stdout);                                                           Line 56
      fputs (HELP_OPTION_DESCRIPTION, stdout);                                  Line 57
      fputs (VERSION_OPTION_DESCRIPTION, stdout);                               Line 58
      emit_ancillary_info (PROGRAM_NAME);                                       Line 59
    }                                                                           
  exit (status);                                                                Line 61
}                                                                               Block 2
                                                                                
int                                                                             
main (int argc, char **argv)                                                    Line 65
{                                                                               
  initialize_main (&argc, &argv);                                               VMS-specific entry point handling wildcard expansion
  set_program_name (argv[0]);                                                   Retains program name and discards path
  setlocale (LC_ALL, "");                                                       Sets up internationalization (i18n)
  bindtextdomain (PACKAGE, LOCALEDIR);                                          Assigns i18n directorySets text domain for _() [gettext()] function
  textdomain (PACKAGE);                                                         Sets text domain for _() [gettext()] function
                                                                                
  atexit (close_stdout);                                                        Close stdout on exit (see gnulib)
                                                                                
  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,          ...!common auto-comment...
                      usage, AUTHORS, (char const *) NULL);                     Line 76
  if (getopt_long (argc, argv, "", long_options, NULL) != -1)                   Line 77
    usage (EXIT_FAILURE);                                                       Line 78
                                                                                
  if (argc < optind + 2)                                                        Line 80
    {                                                                           
      if (argc < optind + 1)                                                    Line 82
        error (0, 0, _("missing operand"));                                     Line 83
      else                                                                      Line 84
        error (0, 0, _("missing operand after %s"), quote (argv[optind]));      Line 85
      usage (EXIT_FAILURE);                                                     Line 86
    }                                                                           
                                                                                
  if (optind + 2 < argc)                                                        Line 89
    {                                                                           
      error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));            Line 91
      usage (EXIT_FAILURE);                                                     Line 92
    }                                                                           
                                                                                
  if (link (argv[optind], argv[optind + 1]) != 0)                               Line 95...!syscalls auto-comment...
    die (EXIT_FAILURE, errno, _("cannot create link %s to %s"),                 Line 96
         quoteaf_n (0, argv[optind + 1]), quoteaf_n (1, argv[optind]));         Line 97
                                                                                
  return EXIT_SUCCESS;                                                          Line 99
}