fdos.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * (C) Copyright 2002
  3. * Stäubli Faverges - <www.staubli.com>
  4. * Pierre AUBERT p.aubert@staubli.com
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #ifndef _FDOS_H_
  25. #define _FDOS_H_
  26. #undef FDOS_DEBUG
  27. #ifdef FDOS_DEBUG
  28. #define PRINTF(fmt,args...) printf (fmt ,##args)
  29. #else
  30. #define PRINTF(fmt,args...)
  31. #endif
  32. /* Data structure describing media */
  33. typedef struct fs
  34. {
  35. unsigned long tot_sectors;
  36. int cluster_size;
  37. int num_clus;
  38. int fat_start;
  39. int fat_len;
  40. int nb_fat;
  41. int num_fat;
  42. int dir_start;
  43. int dir_len;
  44. unsigned char *fat_buf;
  45. } Fs_t;
  46. /* Data structure describing one file system slot */
  47. typedef struct slot {
  48. int (*map) (struct fs *fs,
  49. struct slot *file,
  50. int where,
  51. int *len);
  52. unsigned long FileSize;
  53. unsigned short int FirstAbsCluNr;
  54. unsigned short int PreviousAbsCluNr;
  55. unsigned short int PreviousRelCluNr;
  56. Directory_t dir;
  57. } Slot_t;
  58. typedef struct file {
  59. char *name;
  60. int Case;
  61. Fs_t *fs;
  62. Slot_t subdir;
  63. Slot_t file;
  64. } File_t;
  65. /* dev.c */
  66. int dev_read (void *buffer, int where, int len);
  67. int dev_open (void);
  68. int check_dev (BootSector_t *boot, Fs_t *fs);
  69. /* fat.c */
  70. unsigned int fat_decode (Fs_t *fs, unsigned int num);
  71. int read_fat (BootSector_t *boot, Fs_t *fs);
  72. /* vfat.c */
  73. int vfat_lookup (Slot_t *dir,
  74. Fs_t *fs,
  75. Directory_t *dirent,
  76. int *entry,
  77. int *vfat_start,
  78. char *filename,
  79. int flags,
  80. char *outname,
  81. Slot_t *file);
  82. /* subdir.c */
  83. char *basename (char *name);
  84. int open_subdir (File_t *desc);
  85. int open_file (Slot_t *file, Directory_t *dir);
  86. int read_file (Fs_t *fs,
  87. Slot_t *file,
  88. char *buf,
  89. int where,
  90. int len);
  91. void init_subdir (void);
  92. /* fs.c */
  93. int fs_init (Fs_t *fs);
  94. #endif