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