void PreferencesDialog::GetPreferencesInfo(PreferencesInfo* info) { LONG r = ERROR_SUCCESS; LONG d; for (int i = 0; r == ERROR_SUCCESS && i < PrefsKeyValuesNum; i++) { d = sizeof(PrefsKeyValues[i][1]); r = RegQueryValue(HKEY_CURRENT_USER, (const char*)PrefsKeyValues[i][0], PrefsKeyValues[i][1], &d); } info->autoIndent = PrefsKeyValues[0][1][0] == '1' ? true : false; info->parenthesesMatching = PrefsKeyValues[1][1][0] == '1' ? true : false; info->autoPrototypeOnMouseMove= PrefsKeyValues[2][1][0] == '1' ? true : false; info->autoPrototypeOnKeyDown = PrefsKeyValues[3][1][0] == '1' ? true : false; info->appendLispOutputToEnd = PrefsKeyValues[4][1][0] == '1' ? true : false; int n; char* s = PrefsKeyValues[5][1]; if (s != 0 && s[0] != 0) { n = atoi(s); if (n < 1 || n > 16) n = 4; } info->tab = n; s = PrefsKeyValues[6][1]; if (s != 0 && s[0] != 0) { n = atoi(s); if (n < 4 || n > 72) n = 10; } info->charSize = n; strncpy_s(info->fontName, sizeof(info->fontName), PrefsKeyValues[7][1], 127); info->charBold = PrefsKeyValues[8][1][0] == '1' ? true : false; info->charItalic = PrefsKeyValues[9][1][0] == '1' ? true : false; s = PrefsKeyValues[10][1]; if (s != 0 && s[0] != 0) info->textColor = hextoi(s); s = PrefsKeyValues[11][1]; if (s != 0 && s[0] != 0) info->highlightTextColor = hextoi(s); s = PrefsKeyValues[12][1]; if (s != 0 && s[0] != 0) info->outputTextColor = hextoi(s); s = PrefsKeyValues[13][1]; if (s != 0 && s[0] != 0) info->hintBackgroundColor = hextoi(s); info->replaceTabsWithSpaces = PrefsKeyValues[14][1][0] == '1' ? true : false; info->rememberOpenDocuments = PrefsKeyValues[15][1][0] == '1' ? true : false; info->rememberDocumentPositions=PrefsKeyValues[16][1][0] == '1' ? true : false; info->fullPathInTitle = PrefsKeyValues[17][1][0] == '1' ? true : false; info->autoColorize = PrefsKeyValues[18][1][0] == '1' ? true : false; }
void fileinit(Void) { register char *s; register int i, j; lastiolabno = 100000; lastlabno = 0; lastvarno = 0; nliterals = 0; nerr = 0; infile = stdin; maxtoklen = 502; token = (char *)ckalloc(maxtoklen+2); memset(dflttype, tyreal, 26); memset(dflttype + 'i' - 'a', tyint, 6); memset(hextoi_tab, 16, sizeof(hextoi_tab)); for(i = 0, s = "0123456789abcdef"; *s; i++, s++) hextoi(*s) = i; for(i = 10, s = "ABCDEF"; *s; i++, s++) hextoi(*s) = i; for(j = 0, s = "abcdefghijklmnopqrstuvwxyz"; i = *s++; j++) Letters[i] = Letters[i+'A'-'a'] = j; ctls = ALLOCN(maxctl+1, Ctlframe); extsymtab = ALLOCN(maxext, Extsym); eqvclass = ALLOCN(maxequiv, Equivblock); hashtab = ALLOCN(maxhash, Hashentry); labeltab = ALLOCN(maxstno, Labelblock); litpool = ALLOCN(maxliterals, Literal); labarray = (struct Labelblock **)ckalloc(maxlablist* sizeof(struct Labelblock *)); fmt_init(); mem_init(); np_init(); ctlstack = ctls++; lastctl = ctls + maxctl; nextext = extsymtab; lastext = extsymtab + maxext; lasthash = hashtab + maxhash; labtabend = labeltab + maxstno; highlabtab = labeltab; main_alias[0] = '\0'; if (forcedouble) dfltproc[TYREAL] = dfltproc[TYDREAL]; /* Initialize the routines for providing C output */ out_init (); }
unsigned Logger::parse_log_level( const char* level ) { unsigned log_level = Logger::None; if( 0 == strncasecmp( level, __levels[0], sizeof( __levels[0] ) ) ) { log_level = Logger::None; } else if ( 0 == strncasecmp( level, __levels[1], sizeof( __levels[1] ) ) ) { log_level = Logger::Error; } else if ( 0 == strncasecmp( level, __levels[2], sizeof( __levels[2] ) ) ) { log_level = Logger::Error | Logger::Warning; } else if ( 0 == strncasecmp( level, __levels[3], sizeof( __levels[3] ) ) ) { log_level = Logger::Error | Logger::Warning | Logger::Info; } else if ( 0 == strncasecmp( level, __levels[4], sizeof( __levels[4] ) ) ) { log_level = Logger::Error | Logger::Warning | Logger::Info | Logger::Debug; } else { #ifdef HAVE_SSCANF int val = sscanf( level,"%x",&log_level ); if( val != 1 ) { log_level = Logger::Error; } #else int log_level = hextoi( level, -1 ); if( log_level==-1 ) { log_level = Logger::Error; } #endif } return log_level; }
static int match_op(const unsigned char *re, const unsigned char *s, struct regex_info *info) { int result = 0; switch (*re) { case '\\': /* Metacharacters */ switch (re[1]) { case 'S': FAIL_IF(isspace(*s), static_error_no_match); result++; break; case 's': FAIL_IF(!isspace(*s), static_error_no_match); result++; break; case 'd': FAIL_IF(!isdigit(*s), static_error_no_match); result++; break; case 'x': /* Match byte, \xHH where HH is hexadecimal byte representaion */ FAIL_IF(!(isxdigit(re[2]) && isxdigit(re[3])), static_error_invalid_metacharacter); FAIL_IF(hextoi(re + 2) != *s, static_error_no_match); result++; break; default: if (is_metacharacter(re + 1)) { FAIL_IF(re[1] != s[0], static_error_no_match); result++; } else { FAIL_IF(1, static_error_invalid_metacharacter); } break; } break; case '|': FAIL_IF(1, static_error_internal); break; case '$': FAIL_IF(1, static_error_no_match); break; case '.': result++; break; default: if (info->flags & IGNORE_CASE) { FAIL_IF(tolower(*re) != tolower(*s), static_error_no_match); } else { FAIL_IF(*re != *s, static_error_no_match); } result++; break; } return result; }
fileinit() { register char *s; register int i; procno = 0; lwmno = 0; lastiolabno = 100000; lastlabno = 0; lastvarno = 0; nliterals = 0; nerr = 0; memset(dflttype, tyreal, 26); memset(dflttype + 'i' - 'a', tyint, 6); memset(hextoi_tab, 16, sizeof(hextoi_tab)); for(i = 0, s = "0123456789abcdef"; *s; i++, s++) hextoi(*s) = i; for(i = 10, s = "ABCDEF"; *s; i++, s++) hextoi(*s) = i; ctls = ALLOCN(maxctl, Ctlframe); extsymtab = ALLOCN(maxext, Extsym); eqvclass = ALLOCN(maxequiv, Equivblock); hashtab = ALLOCN(maxhash, Hashentry); labeltab = ALLOCN(maxstno, Labelblock); ctlstack = ctls - 1; lastctl = ctls + maxctl; nextext = extsymtab; lastext = extsymtab + maxext; lasthash = hashtab + maxhash; labtabend = labeltab + maxstno; highlabtab = labeltab; main_alias[0] = '\0'; if (forcedouble) dfltproc[TYREAL] = dfltproc[TYDREAL]; /* Initialize the routines for providing C output */ output_init (); }
static int match_op(const unsigned char *re, const unsigned char *s, struct regex_info *info) { int result = 0; switch (*re) { case '\\': /* Metacharacters */ switch (re[1]) { case 'S': FAIL_IF(isspace(*s), SLRE_NO_MATCH); result++; break; case 's': FAIL_IF(!isspace(*s), SLRE_NO_MATCH); result++; break; case 'd': FAIL_IF(!isdigit(*s), SLRE_NO_MATCH); result++; break; case 'x': /* Match byte, \xHH where HH is hexadecimal byte representaion */ FAIL_IF(hextoi(re + 2) != *s, SLRE_NO_MATCH); result++; break; default: /* Valid metacharacter check is done in bar() */ FAIL_IF(re[1] != s[0], SLRE_NO_MATCH); result++; break; } break; case '|': FAIL_IF(1, SLRE_INTERNAL_ERROR); break; case '$': FAIL_IF(1, SLRE_NO_MATCH); break; case '.': result++; break; default: if (info->flags & IGNORE_CASE) { FAIL_IF(tolower(*re) != tolower(*s), SLRE_NO_MATCH); } else { FAIL_IF(*re != *s, SLRE_NO_MATCH); } result++; break; } return result; }
/* * hextobytes() */ int hextobytes(const char *hexstr, uint8_t *ba) { int i, hi, lo, hexlen; hexlen = strlen(hexstr); if ((hexlen & 1) == 1) { errno = EINVAL; return -1; } for (i=0; i < hexlen/2; i++) { hi = hextoi(hexstr[2*i]); lo = hextoi(hexstr[2*i+1]); if (hi == -1 || lo == -1) { errno = EINVAL; return -1; } ba[i] = hi*16 + lo; } return 0; }
int dump_mem(char *start, char *len){ if (!is_hex(start) || !is_number(len)) return -1; int st=hextoi(start),ed=st+atoi(len),i,total; char output[2]; total=0; memset(output,0,sizeof(output)); for (i=st; i<ed; i++){ u8 temp=read_mem_byte(i); display_byte_hex(temp); ++total; if (total%8==0 && total%16!=0) display_string("-"); else display_string(" "); if ((total)%16==0) display_string("\n"); } if (total%16!=0) display_string("\n"); return 0; }
static int parseDigestNonce(char *nonce, char **secret, char **realm, WebsTime *when) { char *tok, *decoded, *whenStr; assure(nonce && *nonce); assure(secret); assure(realm); assure(when); if ((decoded = websDecode64(nonce)) == 0) { return -1; } *secret = stok(decoded, ":", &tok); *realm = stok(NULL, ":", &tok); whenStr = stok(NULL, ":", &tok); *when = hextoi(whenStr); return 0; }
void GetNumber() { int i=0; if ('\'' == *src) { tok.ident[0]=*src++; tok.ident[1]=*src++; tok.ident[2]=*src++; tok.ident[3]='\0'; //token[0]=*src++; //token[1]=*src++; //token[2]=*src++; //token[3]=0; } else { i=0; while (chr_table[*src] != SPECIAL) { //token[i++]=*src++; tok.ident[i++]=*src++; } //token[i]=0; tok.ident[i]='\0'; } //if (token[0]=='$') if ('$' == tok.ident[0]) { //token_nvalue=hextoi(token+1); tok.value=hextoi(tok.ident+1); } //else if (token[0]=='\'') else if ('\'' == tok.ident[0]) { DoTickMarks(); } else { //token_nvalue=atoi(token); tok.value=atoi(tok.ident); } }
/* from parse,c : */ const char *asim_parse_argb_color( const char *color, CARD32 *pargb ) { #define hextoi(h) (isdigit(h)?((h)-'0'):(isupper(h)?((h)-'A'+10):((h)-'a'+10))) if( color ) { if( *color == '#' ) { CARD32 argb = 0 ; int len = 0 ; register const char *ptr = color+1 ; while( isxdigit((int)ptr[len]) ) len++; if( len >= 3) { if( (len&0x3) == 0 && len != 12 ) { /* we do have alpha channel !!! */ len = len>>2 ; argb = (hextoi((int)ptr[0])<<28)&0xF0000000 ; if( len > 1 ) argb |= (hextoi((int)ptr[1])<<24)&0x0F000000 ; else argb |= 0x0F000000; ptr += len ; }else { len = len/3 ; argb = 0xFF000000; } /* processing rest of the channels : */ if( len == 1 ) { argb |= 0x000F0F0F; argb |= (hextoi((int)ptr[0])<<20)&0x00F00000 ; argb |= (hextoi((int)ptr[1])<<12)&0x0000F000 ; argb |= (hextoi((int)ptr[2])<<4 )&0x000000F0 ; ptr += 3 ; }else { argb |= (hextoi((int)ptr[0])<<20)&0x00F00000 ; argb |= (hextoi((int)ptr[1])<<16)&0x000F0000 ; ptr += len ; argb |= (hextoi((int)ptr[0])<<12)&0x0000F000 ; argb |= (hextoi((int)ptr[1])<<8) &0x00000F00 ; ptr += len ; argb |= (hextoi((int)ptr[0])<<4 )&0x000000F0 ; argb |= (hextoi((int)ptr[1])) &0x0000000F ; ptr += len ; } *pargb = argb ; return ptr; }
// Initializes internal variables to their default value and reads the parameters in the // specified INI file. Then initializes the camera using current settings. If BaseAddress // or RegOffset parameters are specified (not equal to -1) then one or both of these // values are used for the m_BaseAddress and m_RegisterOffset properties overriding those // settings in the INI file. long config_load( char* cfgname, short BaseAddress, short RegOffset ) { short plen; char retbuf[256]; if ((strlen(cfgname) == 0) || (cfgname[0] == '\0')) return CCD_OPEN_CFGNAME; // attempt to open INI file FILE* inifp = NULL; if ((inifp = fopen(cfgname,"r")) == NULL) return CCD_OPEN_CFGDATA; // Check whether we are on an NT platform OSVERSIONINFO VersionInfo; memset(&VersionInfo, 0, sizeof(OSVERSIONINFO)); VersionInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); GetVersionEx ( &VersionInfo ); bool IsNT = VersionInfo.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS; // System if (CfgGet (inifp, "system", "interface", retbuf, sizeof(retbuf), &plen)) { // Assume cam is currently null if ( stricmp( "isa", retbuf ) == 0 ) { if ( IsNT ) cam = new CCameraIO_ISA_NT; else cam = new CCameraIO_ISA_9x; } else if ( stricmp( "ppi", retbuf ) == 0 ) { if ( IsNT ) cam = new CCameraIO_PPI_NT; else cam = new CCameraIO_PPI_9x; } else if ( stricmp( "pci", retbuf ) == 0 ) { cam = new CCameraIO_PCI; } if ( cam == NULL ) { fclose( inifp ); return CCD_OPEN_ALLOC; } } else { fclose( inifp ); return CCD_OPEN_CFGDATA; } ///////////////////////////////////////////////////////////////////////////////// // Settings which are stored in a class member (not in firmware) are already set // to a default value in the constructor. Settings accessed by get/put functions // must be set to a default value in this routine, after the base address and // communication protocal is setup. ///////////////////////////////////////////////////////////////////////////////// // These settings must done first since they affect communication with the camera if ( BaseAddress == -1 ) { if (CfgGet (inifp, "system", "base", retbuf, sizeof(retbuf), &plen)) cam->m_BaseAddress = hextoi(retbuf) & 0xFFF; else { fclose( inifp ); delete cam; cam = NULL; return CCD_OPEN_CFGDATA; // base address MUST be defined } } else cam->m_BaseAddress = BaseAddress & 0xFFF; if ( RegOffset == -1 ) { if (CfgGet (inifp, "system", "reg_offset", retbuf, sizeof(retbuf), &plen)) { unsigned short val = hextoi(retbuf); if ( val >= 0x0 && val <= 0xF0 ) cam->m_RegisterOffset = val & 0xF0; } } else { if ( RegOffset >= 0x0 && RegOffset <= 0xF0 ) cam->m_RegisterOffset = RegOffset & 0xF0; } ///////////////////////////////////////////////////////////////////////////////// // Necessary geometry settings if (CfgGet (inifp, "geometry", "rows", retbuf, sizeof(retbuf), &plen)) { short val = hextoi(retbuf); if ( val >= 1 && val <= MAXTOTALROWS ) cam->m_Rows = val; } else { fclose( inifp ); delete cam; cam = NULL; return CCD_OPEN_CFGDATA; // rows MUST be defined } if (CfgGet (inifp, "geometry", "columns", retbuf, sizeof(retbuf), &plen)) { short val = hextoi(retbuf); if ( val >= 1 && val <= MAXTOTALCOLUMNS ) cam->m_Columns = val; } else { fclose( inifp ); delete cam; cam = NULL; return CCD_OPEN_CFGDATA; // columns MUST be defined } ///////////////////////////////////////////////////////////////////////////////// if (CfgGet (inifp, "system", "pp_repeat", retbuf, sizeof(retbuf), &plen)) { short val = hextoi( retbuf ); if ( val > 0 && val <= 1000 ) cam->m_PPRepeat = val; } ///////////////////////////////////////////////////////////////////////////////// // First actual communication with camera if in PPI mode if ( !cam->InitDriver() ) { delete cam; cam = NULL; fclose( inifp ); if ( IsNT ) return CCD_OPEN_NTIO; else return CCD_OPEN_LOOPTST; } ///////////////////////////////////////////////////////////////////////////////// // First actual communication with camera if in ISA mode cam->Reset(); // Read in command register to set shadow register known state ///////////////////////////////////////////////////////////////////////////////// if (CfgGet (inifp, "system", "cable", retbuf, sizeof(retbuf), &plen)) { if (!stricmp("LONG",retbuf)) cam->write_LongCable( true ); else if ( !stricmp("SHORT",retbuf) ) cam->write_LongCable( false ); } else cam->write_LongCable( false ); // default if ( !cam->read_Present() ) { delete cam; cam = NULL; fclose( inifp ); return CCD_OPEN_LOOPTST; } ///////////////////////////////////////////////////////////////////////////////// // Set default setting and read other settings from ini file cam->write_UseTrigger( false ); cam->write_ForceShutterOpen( false ); if (CfgGet (inifp, "system", "high_priority", retbuf, sizeof(retbuf), &plen)) { if (!stricmp("ON",retbuf) || !stricmp("TRUE",retbuf) || !stricmp("1",retbuf)) { cam->m_HighPriority = true; } else if (!stricmp("OFF",retbuf) || !stricmp("FALSE",retbuf) || !stricmp("0",retbuf)) { cam->m_HighPriority = false; } } if (CfgGet (inifp, "system", "data_bits", retbuf, sizeof(retbuf), &plen)) { short val = hextoi( retbuf ); if ( val >= 8 && val <= 18 ) cam->m_DataBits = val; } if (CfgGet (inifp, "system", "sensor", retbuf, sizeof(retbuf), &plen)) { if ( stricmp( "ccd", retbuf ) == 0 ) { cam->m_SensorType = Camera_SensorType_CCD; } else if ( stricmp( "cmos", retbuf ) == 0 ) { cam->m_SensorType = Camera_SensorType_CMOS; } } if (CfgGet (inifp, "system", "mode", retbuf, sizeof(retbuf), &plen)) { unsigned short val = hextoi(retbuf) & 0xF; cam->write_Mode( val ); } else cam->write_Mode( 0 ); // default if (CfgGet (inifp, "system", "test", retbuf, sizeof(retbuf), &plen)) { unsigned short val = hextoi(retbuf) & 0xF; cam->write_TestBits( val ); } else cam->write_TestBits( 0 ); //default if (CfgGet (inifp, "system", "test2", retbuf, sizeof(retbuf), &plen)) { unsigned short val = hextoi(retbuf) & 0xF; cam->write_Test2Bits( val ); } else cam->write_Test2Bits( 0 ); // default cam->write_FastReadout( false ); //default if (CfgGet (inifp, "system", "shutter_speed", retbuf, sizeof(retbuf), &plen)) { if (!stricmp("normal",retbuf)) { cam->m_FastShutter = false; cam->m_MaxExposure = 10485.75; cam->m_MinExposure = 0.01; } else if (!stricmp("fast",retbuf)) { cam->m_FastShutter = true; cam->m_MaxExposure = 1048.575; cam->m_MinExposure = 0.001; } else if ( !stricmp("dual",retbuf)) { cam->m_FastShutter = true; cam->m_MaxExposure = 10485.75; cam->m_MinExposure = 0.001; } } if (CfgGet (inifp, "system", "shutter_bits", retbuf, sizeof(retbuf), &plen)) { unsigned short val = hextoi(retbuf); cam->m_FastShutterBits_Mode = val & 0x0F; cam->m_FastShutterBits_Test = ( val & 0xF0 ) >> 4; }