doc-pld.txt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. devil1pld.h / devil1pld.c
  2. Handles .pld files.
  3. File Format
  4. PLDs are simple packages of different files, and do not contain a table
  5. of contents. The header consists only of the number of files packaged
  6. and the offsets from the beginning of the .pld that marks the starting
  7. location of the file.
  8. Functions
  9. All functions are static but exposed by a function pointer in a constant
  10. struct called DEVIL1PLD. For example, clients call functions using
  11. DEVIL1PLD.getheader(..., ...);
  12. bool getheader(struct PldHeader*, const char*);
  13. Places file header into the struct pointed at by the first parameter
  14. from the information given in by the second parameter.
  15. inputs: pointer to a struct, pointer to file data
  16. Neither parameter should be NULL.
  17. output: true or false, whether or not operation succeeds or fails.
  18. Will return false if one or both of the parameters are NULL
  19. pointers.
  20. Will return false if the attribute numOffset is less than 0-
  21. i.e file is not valid.
  22. int sizeofsector(struct PldHeader*, unsigned int i, unsigned int max);
  23. Returns the size of the i-th file packed in the pld.
  24. inputs: pointer to a struct, i-th element in pld, file size
  25. output: (-1), [0, maximum value of int)
  26. -1 indicates an invalid input.
  27. void printheader(struct PldHeader*);
  28. Shows contents of a PLD header in standard output.
  29. inputs: pointer of a struct
  30. Example logic to iterate through a .pld
  31. {
  32. ...
  33. // Get information about the file
  34. struct PldHeader h;
  35. DEVIL1PLD.getheader(&h, data);
  36. unsigned int i;
  37. for (i = 0; i < h.numOffset; i++) {
  38. const char *currentfile = filedata + h.offset[i];
  39. ...
  40. }
  41. ...
  42. }