gdb-file.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* gdb_file.c -o/s specific-
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 1, or (at your option)
  7. any later version.
  8. GAS is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GAS; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. #include <stdio.h>
  16. #include <sys/types.h>
  17. #include <sys/stat.h>
  18. static long file_len;
  19. static FILE *file;
  20. extern long get_len();
  21. void
  22. gdb_file_begin ()
  23. {
  24. }
  25. void
  26. gdb_file_end()
  27. {
  28. }
  29. long int /* Open file, return size. 0: failed. */
  30. gdb_file_size (filename)
  31. char *filename;
  32. {
  33. struct stat stat_buf;
  34. void as_perror();
  35. file= fopen (filename, "r");
  36. if (file == (FILE *)NULL)
  37. {
  38. as_perror ("Can't read GDB symbolic information file", filename);
  39. file_len=0;
  40. } else {
  41. (void)fstat (fileno(file), &stat_buf);
  42. file_len=stat_buf . st_size;
  43. }
  44. return ((long int)file_len );
  45. }
  46. void /* Read the file, don't return if failed. */
  47. gdb_file_read (buffer, filename)
  48. char * buffer;
  49. char * filename;
  50. {
  51. register off_t size_wanted;
  52. void as_perror();
  53. size_wanted = file_len;
  54. if (fread (buffer, size_wanted, 1, file) != 1)
  55. {
  56. as_perror ("Can't read GDB symbolic info file", filename);
  57. as_fatal ("Failed to read %ld. chars of GDB symbolic information",
  58. size_wanted);
  59. }
  60. if (fclose(file)==EOF)
  61. {
  62. as_perror ("Can't close GDB symbolic info file", filename);
  63. as_fatal ("I quit in disgust");
  64. }
  65. }
  66. /* end: gdb_file.c */