home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / a-argv.c < prev    next >
C/C++ Source or Header  |  2000-07-19  |  4KB  |  109 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                         GNAT COMPILER COMPONENTS                         */
  4. /*                                                                          */
  5. /*                              A - A R G V                                 */
  6. /*                                                                          */
  7. /*                          C Implementation File                           */
  8. /*                                                                          */
  9. /*                            $Revision: 1.7 $                              */
  10. /*                                                                          */
  11. /*  Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc.   */
  12. /*                                                                          */
  13. /* GNAT is free software;  you can  redistribute it  and/or modify it under */
  14. /* terms of the  GNU General Public License as published  by the Free Soft- */
  15. /* ware  Foundation;  either version 2,  or (at your option) any later ver- */
  16. /* sion.  GNAT is distributed in the hope that it will be useful, but WITH- */
  17. /* OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY */
  18. /* or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License */
  19. /* for  more details.  You should have  received  a copy of the GNU General */
  20. /* Public License  distributed with GNAT;  see file COPYING.  If not, write */
  21. /* to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, */
  22. /* MA 02111-1307, USA.                                                      */
  23. /*                                                                          */
  24. /* As a  special  exception,  if you  link  this file  with other  files to */
  25. /* produce an executable,  this file does not by itself cause the resulting */
  26. /* executable to be covered by the GNU General Public License. This except- */
  27. /* ion does not  however invalidate  any other reasons  why the  executable */
  28. /* file might be covered by the  GNU Public License.                        */
  29. /*                                                                          */
  30. /* GNAT was originally developed  by the GNAT team at  New York University. */
  31. /* It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). */
  32. /*                                                                          */
  33. /****************************************************************************/
  34.  
  35. /* Routines for accessing command line arguments from both the runtime
  36.    library and from the compiler itself. In the former case, gnat_argc
  37.    and gnat_argv are the original argc and argv values as stored by the
  38.    binder generated main program, and these routines are accessed from
  39.    the Ada.Command_Line package. In the compiler case, gnat_argc and
  40.    gnat_argv are the values as modified by toplev, and these routines
  41.    are accessed from the Osint package. */
  42.  
  43. /* Also routines for accessing the environment from the runtime library.
  44.    Gnat_envp is the original envp value as stored by the binder generated
  45.    main program, and these routines are accessed from the
  46.    Ada.Command_Line.Environment package. */
  47.  
  48. #include <string.h>
  49.  
  50. /* argc and argv of the main program are saved under gnat_argc and gnat_argv */
  51.  
  52. /* envp of the main program is saved under gnat_envp */
  53.  
  54. int gnat_argc = 0;
  55. char **gnat_argv = (char **) 0;
  56. char **gnat_envp = (char **) 0;
  57.  
  58. int
  59. arg_count ()
  60. {
  61.   return gnat_argc;
  62. }
  63.  
  64. char **
  65. gnat_argval ()
  66. {
  67.  return gnat_argv;
  68. }
  69.  
  70. int
  71. len_arg (arg_num)
  72.    int arg_num;
  73. {
  74.   return strlen(gnat_argv[arg_num]);
  75. }
  76.  
  77. int
  78. fill_arg (a, i)
  79.    char * a;
  80.    int i;
  81. {
  82.   strncpy (a, gnat_argv[i], strlen(gnat_argv[i]));
  83. }
  84.  
  85. int
  86. env_count ()
  87. {
  88.   int i;
  89.  
  90.   for (i=0; gnat_envp[i]; i++);
  91.   return i;
  92. }
  93.  
  94.  
  95. int
  96. len_env (env_num)
  97.    int env_num;
  98. {
  99.   return strlen(gnat_envp[env_num]);
  100. }
  101.  
  102. int
  103. fill_env (a, i)
  104.    char * a;
  105.    int i;
  106. {
  107.   strncpy (a, gnat_envp[i], strlen(gnat_envp[i]));
  108. }
  109.