SCGUESS.BAK 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "scguess.h"
  5. int getSBParam(char *string, char field)
  6. {
  7. char *p;
  8. int rc;
  9. p = strchr(string, field);
  10. if (!p) return -1;
  11. else p++;
  12. if (field == 'A' || field == 'P') sscanf(p, "%x", &rc); // hex field
  13. else sscanf(p, "%d", &rc); // decimal field
  14. return rc;
  15. }
  16. /*
  17. * Returns 1 if it senses the BLASTER environment variable, 0 if it
  18. * doesn't. If it does return 1, it will also fill in as many fields
  19. * as it can extract from the environment variable. Any fields *not*
  20. * filled in will be set to -1. Of course, if the midi field is filled,
  21. * that means only that it's an SB16 and does not confirm whether the
  22. * WaveBlaster is present.
  23. */
  24. int SmellsLikeSB(int *addr, int *irq, int *dma, int *midi)
  25. {
  26. char *var = getenv("BLASTER");
  27. char *parm;
  28. if (!var) return 0;
  29. *addr = getSBParam(var, 'A');
  30. *irq = getSBParam(var, 'I');
  31. *dma = getSBParam(var, 'D');
  32. *midi = getSBParam(var, 'P');
  33. return 1;
  34. }
  35. /*
  36. * Returns 1 if it senses the ULTRASND environment variable, 0 if it
  37. * doesn't. If it does return 1, it will also fill in as many fields
  38. * as it can extract from the environment variable. Any fields *not*
  39. * filled in will be set to -1.
  40. */
  41. int SmellsLikeGUS(int *addr, int *irq, int *dma)
  42. {
  43. char *var = getenv("ULTRASND");
  44. int dummy;
  45. if (!var) return 0;
  46. else
  47. {
  48. sscanf(var, "%x,%d,%d,%d,%d", addr, dma, &dummy, irq, &dummy);
  49. return 1;
  50. }
  51. }