00001 /**********************************************************/ 00002 /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/ 00003 /* 00004 Copyright: 1993 - Grupo de Voz (DAET) ETSII/IT-Bilbao 00005 00006 Nombre fuente................ BLASTER.C 00007 Nombre paquete............... - 00008 Lenguaje fuente.............. C (Borland C/C++ 3.1) 00009 Estado....................... Completado 00010 Dependencia Hard/OS.......... Sound Blaster 00011 Codigo condicional........... - 00012 00013 Codificacion................. Borja Etxebarria 00014 00015 Version dd/mm/aa Autor Proposito de la edicion 00016 ------- -------- -------- ----------------------- 00017 2.0.0 24/08/94 Borja Manejo dec/hex. Param {hex} en blaster_env(). 00018 1.0.0 19/02/94 Borja Codificacion inicial. 00019 00020 ======================== Contenido ======================== 00021 Lectura de configuracion de tarjetas SoundBlaster a partir 00022 de la variable de entorno BLASTER. 00023 .................... 00024 Gets SoundBlaster card configuration reading the BLASTER 00025 environment variable. 00026 =========================================================== 00027 */ 00028 /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/ 00029 /**********************************************************/ 00030 00031 #include <stdlib.h> 00032 #include <stdio.h> 00033 #include <ctype.h> 00034 #include <string.h> 00035 00036 #include "tdef.h" 00037 #include "blaster.h" 00038 00039 /**********************************************************/ 00040 /* {devuelve} el valor del flag {code} o -1 en caso de error. 00041 Se escanea la cadena {env_str} en busca del caracter {code}, 00042 y se recupera el valor hexadecimal (si {hex}=TRUE) o decimal 00043 (si {hex}=FALSE) indicado a continuacion. 00044 .................... 00045 {returns} the value for flag {code} or -1 if error. 00046 The {env_str} environment string is searched for character 00047 {code}, and the function {returns} the numerical value appended 00048 to that character. The numerical value may be an hexa (send TRUE 00049 in {hex}) or decimal (send FALSE in {hex}) */ 00050 00051 PRIVATE INT blaster_field_value( CHAR code, pCHAR env_str, BOOL hex ) 00052 { 00053 pCHAR c; 00054 int n; 00055 00056 c=strchr(env_str,code); 00057 if (c!=NULL) { 00058 if (sscanf(c+1,((hex)?"%x":"%d"),&n) != 1) 00059 return -1; 00060 else 00061 return (INT)n; 00062 } 00063 else 00064 return -1; 00065 } 00066 00067 /**********************************************************/ 00068 /* {devuelve} el valor que tiene el campo {field} dentro de 00069 la variable de entorno BLASTER. Si sucede algun error (la 00070 variable BLASTER no esta definida, o el campo {field} no esta 00071 definido, se {devuelve} el valor por defecto {default_value}. 00072 La variable BLASTER es de la forma: BLASTER=Fnn Fnn ... 00073 En {hex} se debe indicar la base numerica del campo: FALSE para 00074 decimal, TRUE para hexadecimal. 00075 donde F es el caracter que identifica al campo (caracter {field}) 00076 y nn es el valor numerico hexadecimal/decimal correspondiente. 00077 En BLASTER.H estan definidos los campos {field} que se pueden 00078 sondear (constantes BLASTER_????) y los valores por 00079 defecto que se pueden utilizar BLASTER_DEFAULT_???? 00080 .................... 00081 {returns} the value for the field {field} in the BLASTER 00082 environment variable. If error (BLASTER not defined, {field} 00083 not valid...) {returns} the default value {default_value}. 00084 You must send un {hex} the field value numerical base : FALSE for 00085 decimal base and TRUE for hexadecimal base. 00086 The BLASTER env. var. sintaxis is: BLASTER=Fnn Fnn ... where 00087 F is the field identifier character ({field} parameter) 00088 and nn is a numerical hex/decimal value. The valid {field} values 00089 for SB16, the default values you can use and the base (hex/decimal) 00090 for each one, are defined as constants in BLASTER.H */ 00091 00092 INT blaster_env( CHAR field, INT default_value, BOOL hex ) 00093 { 00094 pCHAR e; 00095 INT i; 00096 00097 if ((e=getenv("BLASTER")) != NULL) { 00098 if ((i=blaster_field_value(toupper(field),e,hex)) != -1) 00099 return i; 00100 if ((i=blaster_field_value(tolower(field),e,hex)) != -1) 00101 return i; 00102 } 00103 00104 return default_value; 00105 } 00106 00107 /**********************************************************/ 00108