home *** CD-ROM | disk | FTP | other *** search
/ Mega CD-ROM 1 / megacd_rom_1.zip / megacd_rom_1 / GNUISH / SWALIB0.ZIP / SW_LINK.C < prev    next >
C/C++ Source or Header  |  1990-09-10  |  2KB  |  95 lines

  1. /* sw_link.c - respondfiles for the Microsoft linker.
  2.    Copyright (C) 1990 by Thorsten Ohl, td12@ddagsi3.bitnet
  3.  
  4.    This file is part of SWAPLIB (the library), a library for efficient
  5.    execution of child processes under MS-DOS.
  6.  
  7.    The library is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 1, or (at your option)
  10.    any later version.
  11.  
  12.    The library is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with the library; if not, write to the Free Software
  19.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.    $Header: e:/gnu/swaplib/RCS/sw_link.c'v 0.9 90/09/09 21:43:59 tho Stable $
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27.  
  28. #include "swaplib.h"
  29.  
  30. /* Build a respondfile for the Microsoft linker from ARGV.  */
  31.  
  32. int
  33. _swap_build_link_respond_file (char **argv, char **envv)
  34. {
  35.   int col = 0;
  36.   FILE *respond_file;
  37.   _swap_respond_file_name = swap_back_slashify (swap_mktmpname ("lk"));
  38.  
  39.   respond_file = fopen (_swap_respond_file_name, "w");
  40.   if (!respond_file)
  41.     {
  42.       int last_errno = errno;
  43.       fprintf (stderr, "can't open link respond file: ");
  44.       errno = last_errno;
  45.       perror (_swap_respond_file_name);
  46.       return -1;
  47.     }
  48.  
  49.   argv++;
  50.  
  51.   /* Loop over the arguments.  */
  52.  
  53.   while (*argv)
  54.     {
  55.       char *cp;
  56.  
  57.       if (strlen (*argv) + col > 50)
  58.     {
  59.       /* Break the line.  */
  60.  
  61.       fprintf (respond_file, "+\n");
  62.       col = 0;
  63.     }
  64.  
  65.       while (cp = strchr (*argv, ','))        /* new respond group? */
  66.     {
  67.       /* Break the line at a new group of responses.  */
  68.  
  69.       *cp = '\n';
  70.  
  71.       /* No more line breaks. */
  72.  
  73.       col = 0;
  74.     }
  75.  
  76.       col += fprintf (respond_file, "%s ", *argv);
  77.  
  78.       argv++;
  79.     }
  80.  
  81.   fprintf (respond_file, "\n\n\n");    /* avoid prompts! */
  82.   fclose (respond_file);
  83.  
  84.   sprintf (_swap_cmdline_buf, "/batch @%s", _swap_respond_file_name);
  85.   return _swap_format_msdos_environment (NULL, envv, NULL);
  86. }
  87.  
  88. /* 
  89.  * Local Variables:
  90.  * mode:C
  91.  * ChangeLog:ChangeLog
  92.  * compile-command:make
  93.  * End:
  94.  */
  95.