📄 ctrlthread.c
字号:
step=3;
break;
case 3:
if( szFileData[ i ] == '\r' )
{
step = 0;
continue;
}
if( szFileData[ i ] == '\n' )
{
step = 0;
continue;
}
if( szFileData[ i ] == '=' )
{
memset( KeyName, 0, sizeof(KeyName) );
memcpy( KeyName, &szFileData[ idx ], i - idx );
for( idx = i - idx - 1; idx > 0; idx -- )
{
if( KeyName[ idx ] == ' ' )
KeyName[ idx ] = 0;
if( KeyName[ idx ] == '\t' )
KeyName[idx]=0;
}
if( 0 == strcmp( KeyName, lpKeyName ) )
step=4;
else
step=-1;
}
break;
case 4:
if( szFileData[ i ] == '\r' )
continue;
if( szFileData[ i ] == '\n' )
continue;
if( szFileData[ i ] == '\t' )
continue;
if( szFileData[ i ] == ' ' )
continue;
idx = i;
step = 5;
break;
case 5:
if( szFileData[ i ] == '\r' )
step=6;
break;
case 6:
if( szFileData[ i ] == '\n' )
{
if( ( i - idx - 1 ) > nSize )
goto ExitSub;
memcpy( lpReturnedString, &szFileData[ idx ], i - idx - 1 );
lpReturnedString[ i - idx - 1 ] = 0;
goto ExitSub;
}
break;
default:
continue;
}
}
}
if(step==5)
{
memcpy( lpReturnedString, &szFileData[ idx ], i - idx + 1 );
lpReturnedString[ i - idx + 1 ] = 0;
}
ExitSub:
kfree( szFileData );
return 1;
}
char InitWebMailConfig()
{
char *pKey = NULL;
char *pEnd = NULL;
char *pBuffer = NULL;
char *p = NULL;
UCHAR *pDot = NULL;
PWEB_MAIL_CONFIG pWebMailConfig = NULL;
UCHAR uChar = '\0';
UINT uAttr = 0;
UINT uCrypt = 1;
// UINT uHttpType = 1;
pBuffer = ReadWebMailConfig();
if( !pBuffer )
{
printk( "read failed!\r\n" );
return 0;
}
pKey = pBuffer;
pKey = strstr( pKey, WEB_MAIL_BEGIN);
while( pKey )
{
uAttr = 0;
uCrypt = 1;
while( pKey )
{
switch( *((UINT *)pKey) )
{
case 0x69676562://0x62656769://begi
pWebMailConfig = (PWEB_MAIL_CONFIG)kmalloc( sizeof(WEB_MAIL_CONFIG), GFP_ATOMIC );
if( !pWebMailConfig )
goto quit;
memset( pWebMailConfig, 0, sizeof(WEB_MAIL_CONFIG) );
pWebMailConfig->uiLocation = 0;
pWebMailConfig->pNext = gVar.gWebMailConfig;
gVar.gWebMailConfig = pWebMailConfig;
break;
case 0x72747461://0x61747472://attr
pKey += strlen( WEB_MAIL_HOST_ATTR ) + 1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
pWebMailConfig->IPType = atoi( pKey );
*pEnd = uChar;
break;
case 0x70797263://crypt
pKey += strlen(WEB_MAIL_CRYPTOGRAM)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
pWebMailConfig->crypt = atoi( pKey );
*pEnd = uChar;
break;
case 0x74736f68://0x686f7374://host
pKey += strlen(WEB_MAIL_HOST);
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
sprintf( pWebMailConfig->host, "%s", pKey + 1 );
pDot = pKey;
p = strstr( pKey, WEB_MAIL_HOST_SEQ );
while( p )
{
*pDot = (UCHAR)( ( (UCHAR *)p - pDot ) - 1 );
pDot = p;
p = strstr( p + 1, WEB_MAIL_HOST_SEQ );
}
*pDot = (UCHAR)(( (UCHAR *)pEnd - pDot ) -1);
AddDomain( pKey, uAttr, pWebMailConfig, 0 );
*pEnd = uChar;
break;
case 0x72657375://0x75736572://user
pKey += strlen(WEB_MAIL_USERNAME)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_USERNAME_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_USERNAME_LEN-1;
sprintf( pWebMailConfig->username, "%s", pKey );
*pEnd = uChar;
break;
case 0x73736170://0x70617373://pass
pKey += strlen(WEB_MAIL_PASSWORD)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_PASSWORD_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_PASSWORD_LEN-1;
sprintf( pWebMailConfig->password, "%s", pKey );
*pEnd = uChar;
break;
case 0x61706573://0x73657061://sepa rator
pKey += strlen(WEB_MAIL_SEPARATOR)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_SEPARATOR_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_SEPARATOR_LEN-1;
sprintf( pWebMailConfig->separator, "%s", pKey );
*pEnd = uChar;
break;
case 0x69676f6c://logi nflag
pKey += strlen(WEB_MAIL_LOGIN_FLAG)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_LOGIN_FLAG_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_LOGIN_FLAG_LEN-1;
sprintf( pWebMailConfig->loginflag, "%s", pKey );
*pEnd = uChar;
break;
case 0x66667573://suff ix
pKey += strlen(WEB_MAIL_SUFFIX)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_SUFFIX_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_SUFFIX_LEN-1;
sprintf( pWebMailConfig->suffix, "%s", pKey );
*pEnd = uChar;
break;
case 0x61636f6c://loca tion
if( pWebMailConfig->uiLocation >= WEB_MAIL_LOCATION_NUM )
break;
pKey += strlen(WEB_MAIL_LOCATION)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_LOCATION_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_LOCATION_LEN-1;
sprintf( pWebMailConfig->location[pWebMailConfig->uiLocation],
"%s", pKey );
*pEnd = uChar;
break;
case 0x65636f6c://loce nd
if( pWebMailConfig->uiLocation >= WEB_MAIL_LOCATION_NUM )
break;
pKey += strlen(WEB_MAIL_LOCEND)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_LOCATION_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_LOCATION_LEN-1;
sprintf( pWebMailConfig->locend[pWebMailConfig->uiLocation],
"%s", pKey );
*pEnd = uChar;
pWebMailConfig->uiLocation++;
break;
case 0x6c666372://rcfl ag
pKey += strlen(WEB_MAIL_RCFLAG)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_RCFLAG_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_RCFLAG_LEN-1;
sprintf( pWebMailConfig->rcflag, "%s", pKey );
*pEnd = uChar;
break;
case 0x6c646461://addlist
pKey += strlen(WEB_MAIL_ADDLIST)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_ADDLIST_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_ADDLIST_LEN-1;
sprintf( pWebMailConfig->addlist, "%s", pKey );
*pEnd = uChar;
break;
case 0x6f636372://rcco ntinue
pKey += strlen(WEB_MAIL_RCCONTINUE)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_RCCONTINUE_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_RCCONTINUE_LEN-1;
sprintf( pWebMailConfig->rccontinue, "%s", pKey );
*pEnd = uChar;
break;
case 0x6c666172://rafl ag
pKey += strlen(WEB_MAIL_RAFLAG)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_RAFLAG_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_RAFLAG_LEN-1;
sprintf( pWebMailConfig->raflag, "%s", pKey );
*pEnd = uChar;
break;
case 0x6c666373://scfl ag
pKey += strlen(WEB_MAIL_SCFLAG)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_SCFLAG_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_SCFLAG_LEN-1;
sprintf( pWebMailConfig->scflag, "%s", pKey );
*pEnd = uChar;
break;
case 0x6c666173://safl ag
pKey += strlen(WEB_MAIL_SAFLAG)+1;
pEnd = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( !pEnd )
goto quit;
uChar = *pEnd;
*pEnd = '\0';
if( (pEnd-pKey)>(WEB_MAIL_SAFLAG_LEN-1))
pKey += (pEnd-pKey)-WEB_MAIL_SAFLAG_LEN-1;
sprintf( pWebMailConfig->saflag, "%s", pKey );
*pEnd = uChar;
break;
default:
break;
}
pKey = strstr( pKey, WEB_MAIL_CONFIG_SEQ );
if( pKey )
{
pKey += strlen( WEB_MAIL_CONFIG_SEQ );
if(*(UINT *)pKey == 0x75646e65) //endu p
{
break;
}
}
}
pKey = strstr( pKey, WEB_MAIL_BEGIN);
}
kfree( pBuffer );
return 1;
quit:
kfree( pBuffer );
return 0;
}
char * ReadWebMailConfig()
{
struct file *file = NULL;
mm_segment_t old_fs;
int nRead;
char cstepfilePathName[_MAX_OUTPUT_FILE_LENGTH];
void *pBuffer=NULL;
memset( cstepfilePathName, 0, _MAX_OUTPUT_FILE_LENGTH );
sprintf( cstepfilePathName, "%s", WEB_MAIL_CONFIGURE_FILE );
file = filp_open( cstepfilePathName, O_RDWR | O_APPEND | O_CREAT, 0644 );
if( IS_ERR(file) )
{
printk( "error occured while opening file %s, exiting...\n", cstepfilePathName );
return NULL;
}
pBuffer = kmalloc( WEB_MAIL_CONFIG_BUF_LEN, GFP_ATOMIC );
if( !pBuffer )
{
printk( "Error: Con't allocat webconfig buf, exiting...\r\n" );
kfree( pBuffer );
return NULL;
}
memset( pBuffer, 0, WEB_MAIL_CONFIG_BUF_LEN );
old_fs = get_fs();
set_fs(KERNEL_DS);
nRead = generic_file_read( file, pBuffer, WEB_MAIL_CONFIG_BUF_LEN, &file->f_pos );
set_fs(old_fs);
if( file != NULL )
filp_close( file, NULL );
return pBuffer;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -