BlueSCSI_config.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * Copyright (C) 2023 Eric Helgeson
  3. *
  4. * This file is part of BlueSCSI
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. **/
  19. #include "minIni.h"
  20. #include "BlueSCSI_config.h"
  21. int getBlockSize(char *filename, int scsiId, int default_size)
  22. {
  23. char section[6] = "SCSI0";
  24. section[4] = '0' + scsiId;
  25. default_size = ini_getl(section, "BlockSize", default_size, CONFIGFILE);
  26. // Parse block size (HD00_NNNN)
  27. const char *blksize = strchr(filename, '_');
  28. if (blksize)
  29. {
  30. int blktmp = strtoul(blksize + 1, NULL, 10);
  31. if (blktmp == 256 || blktmp == 512 || blktmp == 1024 ||
  32. blktmp == 2048 || blktmp == 4096 || blktmp == 8192)
  33. {
  34. return blktmp;
  35. }
  36. }
  37. return default_size;
  38. }
  39. int getImgDir(int scsiId, char* dirname)
  40. {
  41. char section[6] = "SCSI0";
  42. section[4] = '0' + scsiId;
  43. char key[] = "ImgDir";
  44. int dirlen = ini_gets(section, key, "", dirname, sizeof(dirname), CONFIGFILE);
  45. return dirlen;
  46. }
  47. int getImg(int scsiId, int img_index, char* filename)
  48. {
  49. char section[6] = "SCSI0";
  50. section[4] = '0' + scsiId;
  51. char key[] = "IMG0";
  52. key[3] = '0' + img_index;
  53. int dirlen = ini_gets(section, key, "", filename, sizeof(filename), CONFIGFILE);
  54. return dirlen;
  55. }
  56. int getToolBoxSharedDir(char * dir_name)
  57. {
  58. return ini_gets("SCSI", "ToolBoxSharedDir", "/shared", dir_name, MAX_FILE_PATH, CONFIGFILE);
  59. }