prolatex.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: prolatex.c /main/3 1996/06/11 17:38:30 cde-hal $ */
  24. #include <stdio.h>
  25. #include <string.h>
  26. #define BUFSIZ 1000
  27. int replace();
  28. main(argc, argv)
  29. int argc;
  30. char* argv[];
  31. {
  32. char buf[BUFSIZ];
  33. while ( fgets(buf, BUFSIZ, stdin) != NULL ) {
  34. buf[strlen(buf)-1] = '\0';
  35. if ( replace(buf, "\\epsffile{", argv[1]) == 0 )
  36. continue;
  37. if ( replace(buf, "\\input{", argv[1]) == 0 )
  38. continue;
  39. else {
  40. fputs(buf, stdout);
  41. fputs("\n", stdout);
  42. }
  43. }
  44. }
  45. int replace(buf, pattern, s)
  46. char* buf;
  47. char* pattern;
  48. char* s;
  49. {
  50. int loc = strlen(pattern);
  51. char c = buf[loc];
  52. buf[loc] = '\0';
  53. if ( strcmp(buf, pattern) == 0 ) {
  54. fputs(buf, stdout);
  55. /*fputs(getenv("PWD"), stdout);*/
  56. fputs(s, stdout);
  57. fputs("/", stdout);
  58. buf[loc] = c;
  59. fputs(buf + loc, stdout);
  60. fputs("\n", stdout);
  61. return 0;
  62. } else {
  63. buf[loc] = c;
  64. return -1;
  65. }
  66. }