1.删除一些备份文件

This commit is contained in:
payton 2023-07-21 10:45:33 +08:00
parent b292478830
commit 7ce29f235d
5 changed files with 0 additions and 1927 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "sf_type.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
static char * base64char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int sf_base64_decode(const char * base64, char * bindata)
{
int i, j;
U8 k;
U8 temp[4];
for (i = 0, j = 0; base64[i] != '\0'; i += 4)
{
memset(temp, 0xFF, sizeof(temp));
for (k = 0; k < 64; k++)
{
if (base64char[k] == base64[i])
temp[0] = k;
}
for (k = 0; k < 64; k++)
{
if (base64char[k] == base64[i + 1])
temp[1] = k;
}
for (k = 0; k < 64; k++)
{
if (base64char[k] == base64[i + 2])
temp[2] = k;
}
for (k = 0; k < 64; k++)
{
if (base64char[k] == base64[i + 3])
temp[3] = k;
}
bindata[j++] = ((U8)(((U8)(temp[0] << 2)) & 0xFC)) |
((U8)((U8)(temp[1] >> 4) & 0x03));
if (base64[i + 2] == '=')
break;
bindata[j++] = ((U8)(((U8)(temp[1] << 4)) & 0xF0)) |
((U8)((U8)(temp[2] >> 2) & 0x0F));
if (base64[i + 3] == '=')
break;
bindata[j++] = ((U8)(((U8)(temp[2] << 6)) & 0xF0)) |
((U8)(temp[3] & 0x3F));
}
return j;
}
char * sf_base64_encode(const char * bindata, char * base64, int binlength, int model)
{
int i, j;
unsigned char current;
for (i = 0, j = 0; i < binlength; i += 3)
{
current = (bindata[i] >> 2);
current &= (unsigned char)0x3F;
base64[j++] = base64char[(int)current];
current = ((unsigned char)(bindata[i] << 4)) & ((unsigned char)0x30);
if (i + 1 >= binlength)
{
base64[j++] = base64char[(int)current];
base64[j++] = '=';
base64[j++] = '=';
break;
}
current |= ((unsigned char)(bindata[i + 1] >> 4)) & ((unsigned char)0x0F);
base64[j++] = base64char[(int)current];
current = ((unsigned char)(bindata[i + 1] << 2)) & ((unsigned char)0x3C);
if (i + 2 >= binlength)
{
base64[j++] = base64char[(int)current];
base64[j++] = '=';
break;
}
current |= ((unsigned char)(bindata[i + 2] >> 6)) & ((unsigned char)0x03);
base64[j++] = base64char[(int)current];
current = ((unsigned char)bindata[i + 2]) & ((unsigned char)0x3F);
base64[j++] = base64char[(int)current];
}
if(model)
{
base64[j++] = '\n';
}
base64[j] = '\0';
return base64;
}
int URLEncode(const char* str, const int strSize, char* result, const int resultSize)
{
int i;
int j = 0;//for result index
char ch;
if ((str == 0) || (result == 0) || (strSize <= 0) || (resultSize <= 0)) {
return 0;
}
for (i = 0; (i<strSize) && (j<resultSize); ++i) {
ch = str[i];
if (((ch >= 'A') && (ch<='Z')) ||
((ch >= 'a') && (ch<='z')) ||
((ch >= '0') && (ch<='9'))) {
result[j++] = ch;
}
else if (ch == ' ') {
result[j++] = '+';
}
else if (ch == '.' || ch == '-' || ch == '_' || ch == '*') {
result[j++] = ch;
}
else {
if (j + 3 < resultSize) {
sprintf(result + j, "%%%02X", (unsigned char)ch);
j += 3;
}
else {
return 0;
}
}
}
result[j] = '\0';
return j;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

View File

@ -1,112 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <printf.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <sys/msg.h>
#include <sf_inc.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
int sf_msgQueueId = -1;
int cardv_msgQueueId = -1;
static SINT32 message_queue_send(SINT32 MsgQueueId,SF_MESSAGE_BUF_S *pMessageBuf)
{
size_t msgsz = sizeof(pMessageBuf->cmdId) + sizeof(pMessageBuf->s32Wait) + sizeof(pMessageBuf->arg1) + sizeof(pMessageBuf->arg2)+ sizeof(pMessageBuf->arg3);
if(msgsnd(MsgQueueId, pMessageBuf, msgsz, 0) == -1)
{
return SF_FAILURE;
}
return SF_SUCCESS;
}
static SINT32 message_queue_recv(SINT32 MsgQueueId,SF_MESSAGE_BUF_S *pMessageBuf)
{
size_t msgsz = sizeof(pMessageBuf->cmdId) + sizeof(pMessageBuf->s32Wait) + sizeof(pMessageBuf->arg1) + sizeof(pMessageBuf->arg2)+ sizeof(pMessageBuf->arg3);
if(msgrcv(MsgQueueId, pMessageBuf, msgsz,0,IPC_NOWAIT) == -1)
{
return SF_FAILURE;
}
return SF_SUCCESS;
}
static SINT32 message_queue_create(SF_CHAR *pathname,SINT32 *pMsgQueueId)
{
key_t key;
SF_CHAR touchPath[128] = {0};
if(access(pathname, F_OK) != 0)
{
sprintf(touchPath, "%s %s","touch",pathname);
system(touchPath);
}
if((key = ftok(pathname,'z')) < 0)
{
MLOGI("ftok error");
return SF_FAILURE;
}
if ((*pMsgQueueId = msgget(key, IPC_CREAT | 0660)) == -1)
{
MLOGI("MsgQueueId = %#x\n",*pMsgQueueId);
MLOGI("msgget failed errno.%02d is: %s\n", errno, strerror(errno));
return SF_FAILURE;
}
MLOGI("MsgQueueId = %#x\n",*pMsgQueueId);
return SF_SUCCESS;
}
SINT32 sf_com_message_app_init(void)
{
return message_queue_create((char*)"/tmp/sf_message",&sf_msgQueueId);
}
SINT32 sf_com_message_recv_from_app(SF_MESSAGE_BUF_S *pMessageBuf)
{
return message_queue_recv(sf_msgQueueId,pMessageBuf);
}
SINT32 sf_com_message_send_to_app(SF_MESSAGE_BUF_S *pMessageBuf)
{
pMessageBuf->mtype = 1;
return message_queue_send(sf_msgQueueId,pMessageBuf);
}
SINT32 sf_com_message_cardv_init(void)
{
return message_queue_create((char*)"/tmp/cardv_message",&cardv_msgQueueId);
}
SINT32 sf_com_message_recv_from_cardv(SF_MESSAGE_BUF_S *pMessageBuf)
{
return message_queue_recv(cardv_msgQueueId,pMessageBuf);
}
SINT32 sf_com_message_send_to_cardv(SF_MESSAGE_BUF_S *pMessageBuf)
{
pMessageBuf->mtype = 1;
return message_queue_send(cardv_msgQueueId,pMessageBuf);
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

View File

@ -1,216 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <printf.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#include <sf_inc.h>
int sf_semId = -1;
int sf_sharMemId = -1;
int sf_sharMemfileId = -1;
union semun {
int val;
struct semid_ds *buf;
unsigned short *array;
struct seminfo *__buf;
};
SINT32 sem_creat(SF_CHAR *pathname,SINT32 *psemid)
{
SF_CHAR touchPath[128] = {0};
if(access(pathname, F_OK) != 0)
{
sprintf(touchPath, "%s %s","touch",pathname);
system(touchPath);
}
key_t key = ftok(pathname, 111);
if(key < 0)
{
perror("ftok");
return SF_FAILURE;
}
*psemid = semget(key, 1, IPC_CREAT|IPC_EXCL|0666);
if(*psemid < 0)
{
perror("semget");
return SF_FAILURE;
}
union semun un;
un.val = 1;
if(semctl(*psemid, 0, SETVAL, un)<0)
{
perror("semctl");
return SF_FAILURE;
}
return SF_SUCCESS;
}
SINT32 sem_check(SINT32 semid, SINT32 who, SINT32 op)
{
struct sembuf sf;
sf.sem_num = who;
sf.sem_op = op;
sf.sem_flg = 0;
if(semop(semid, &sf, 1) < 0)
{
perror("semop");
return SF_FAILURE;
}
return SF_SUCCESS;
}
SINT32 sf_sem_init(SF_CHAR *pathname,SINT32 *psemid)
{
return sem_creat(pathname,psemid);
}
SINT32 sf_sem_down(SINT32 semid, SINT32 who)
{
return sem_check(semid, who, -1);
}
SINT32 sf_sem_up(SINT32 semid, SINT32 who)
{
return sem_check(semid, who, 1);
}
SINT32 sf_sem_deinit(SINT32 semid)
{
if(semctl(semid, 0, IPC_RMID) < 0)
{
perror("semctl");
return SF_FAILURE;
}
return SF_SUCCESS;
}
int share_mem_create(SF_CHAR *pathname,int size,SINT32 *pshmID)
{
SF_CHAR touchPath[128] = {0};
if(access(pathname, F_OK) != 0)
{
sprintf(touchPath, "%s %s","touch",pathname);
system(touchPath);
}
key_t key = ftok(pathname, 111);
if(key < 0)
{
perror("ftok");
return SF_FAILURE;
}
*pshmID = shmget(key, size, IPC_CREAT|0666);
if(*pshmID == -1)
{
perror("shmget");
return SF_FAILURE;
}
return SF_SUCCESS;
}
int share_mem_destory(int shmID)
{
if(shmctl(shmID, IPC_RMID, NULL) < 0 )
{
perror("shmctl");
return SF_FAILURE;
}
return SF_SUCCESS;
}
void* share_mem_get(int shmID)
{
return shmat(shmID, NULL, 0);
}
SINT32 sf_share_mem_init(SF_CHAR *pathname,int size,SINT32 *pshmID)
{
return share_mem_create(pathname,size,pshmID);
}
SINT32 sf_share_mem_deinit(SINT32 shmID)
{
return share_mem_destory(shmID);
}
void* sf_share_mem_get(int shmID)
{
return share_mem_get(shmID);
}
SINT32 sf_share_mem_file_init(void)
{
SF_SRCFILE_ATTR_S *pThumbFileCfg = 0;
if(SF_SUCCESS == sf_share_mem_init((char*)"/tmp/sf_file",sizeof(SF_SRCFILE_ATTR_S),&sf_sharMemfileId))
{
pThumbFileCfg = (SF_SRCFILE_ATTR_S *)sf_share_mem_get(sf_sharMemfileId);
if(pThumbFileCfg <= 0)
{
MLOGI("creat share mem failed!!!\n");
return SF_FAILURE;
}
else
{
//sf_file_thumb_cfg_set(pThumbFileCfg);
MLOGI("creat share mem succeed!!!\n");
return SF_SUCCESS;
}
}
return SF_FAILURE;
}
SINT32 sf_share_mem_customer_init(void)
{
UIMenuStoreInfo *pSfCustomerPara = 0;
if(SF_SUCCESS == sf_share_mem_init((char*)"/tmp/sf_share",sizeof(UIMenuStoreInfo),&sf_sharMemId))
{
pSfCustomerPara = (UIMenuStoreInfo *)sf_share_mem_get(sf_sharMemId);
if(pSfCustomerPara <= 0)
{
MLOGI("creat share mem failed!!!\n");
return SF_FAILURE;
}
else
{
//sf_customer_param_set(pSfCustomerPara);
MLOGI("creat share mem succeed!!!\n");
return SF_SUCCESS;
}
}
return SF_FAILURE;
}
SINT32 sf_share_mem_file_deinit(void)
{
return sf_share_mem_deinit(sf_sharMemfileId);
}
SINT32 sf_share_mem_customer_deinit(void)
{
return sf_share_mem_deinit(sf_sharMemId);
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif

View File

@ -1,274 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <stdarg.h>
#include <sf_type.h>
#include <sf_base64.h>
#include <sf_log.h>
#include "UIInfo/UIInfo.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#if SF_ENCRYPTION_ENBLE
U16 gDebugMode = 0;
#else
U16 gDebugMode = 1;
#endif
int gsave_logtxt = 0;
static SF_LOG_LEVEL_e enLogLevel = SF_LOG_LEVEL_DEBUG;
/*=========================================================================
* Log *
*=========================================================================*/
static char * base64char = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static void log_base64_encode(const char * bindata, char * base64, int binlength, int model)
{
int i, j;
unsigned char current;
for (i = 0, j = 0; i < binlength; i += 3)
{
current = (bindata[i] >> 2);
current &= (unsigned char)0x3F;
base64[j++] = base64char[(int)current];
current = ((unsigned char)(bindata[i] << 4)) & ((unsigned char)0x30);
if (i + 1 >= binlength)
{
base64[j++] = base64char[(int)current];
base64[j++] = '=';
base64[j++] = '=';
break;
}
current |= ((unsigned char)(bindata[i + 1] >> 4)) & ((unsigned char)0x0F);
base64[j++] = base64char[(int)current];
current = ((unsigned char)(bindata[i + 1] << 2)) & ((unsigned char)0x3C);
if (i + 2 >= binlength)
{
base64[j++] = base64char[(int)current];
base64[j++] = '=';
break;
}
current |= ((unsigned char)(bindata[i + 2] >> 6)) & ((unsigned char)0x03);
base64[j++] = base64char[(int)current];
current = ((unsigned char)bindata[i + 2]) & ((unsigned char)0x3F);
base64[j++] = base64char[(int)current];
}
if(model)
{
base64[j++] = '\n';
}
base64[j] = '\0';
//return base64;
}
static U16 sf_get_dbgmode(void)
{
return gDebugMode;
}
SINT32 sf_log_Level_set(SF_LOG_LEVEL_e enLevel)
{
enLogLevel = enLevel;
return SF_SUCCESS;
}
SF_LOG_LEVEL_e sf_log_Level_get()
{
return enLogLevel;
}
void sf_log_module(const char *pszFunc, U32 u32Line, const char *pszFmt, ...)
{
if(SysGetFlag(DebugMode) == 0)
return;
FILE* flog;
U16 debugMode = sf_get_dbgmode();
{
va_list args;
pszFmt = (NULL == pszFmt) ? "" : pszFmt;
CHAR timeBuf[128] = { 0 };
CHAR tmpBuf[512] = { 0 };
CHAR allBuf[640] = { 0 };
CHAR enCodeLog[1024] = { 0 };
#ifdef SF_LOG_USE_RTC_TIME
SF_PARA_TIME_S dateTime;
#endif
flog = fopen(LOG_TMP_MOD_FILE_PATH, "at");
if(flog != NULL)
{
fseek(flog, 0L, SEEK_END);
#ifdef SF_LOG_USE_RTC_TIME
sf_sys_rtc_time_get(&dateTime);
sprintf(timeBuf, "[%s-%d]:%04d/%02d/%02d %02d:%02d:%02d ", pszFunc, u32Line, dateTime.Year, dateTime.Mon, dateTime.Day,
dateTime.Hour, dateTime.Min, dateTime.Sec);
#else
time_t timep;
struct tm *p;
time(&timep);
p = gmtime(&timep);
sprintf((char*)timeBuf, "%04d/%02d/%02d %02d:%02d:%02d ", p->tm_year + 1900, p->tm_mon + 1, p->tm_mday,
p->tm_hour, p->tm_min, p->tm_sec);
#endif
va_start(args, pszFmt);
vsprintf((char*)tmpBuf, pszFmt, args);
if(debugMode == 0)
{
sprintf((char*)allBuf, "%s%s", timeBuf, tmpBuf);
log_base64_encode((char*)allBuf, (char*)enCodeLog, strlen((char*)allBuf),1);
fprintf(flog, "%s\n", enCodeLog);
}
else
{
fprintf(flog, "%s%s\n", timeBuf, tmpBuf);
}
fclose(flog);
}
else
{
MLOGE("LOG file[%s] open fail!\n",LOG_TMP_MOD_FILE_PATH);
}
fprintf(stdout, "[%s:%d]:",pszFunc, u32Line);
va_start(args, pszFmt);
vfprintf(stdout, pszFmt, args);
va_end(args);
}
return;
}
void sf_log_file(SF_LOG_LEVEL_e enLevel,const char *pszFunc, U32 u32Line,char *pszFmt, ...)
{
SF_LOG_LEVEL_e enDstLevel;
FILE* flog = NULL;
U16 debugMode = sf_get_dbgmode();
enDstLevel = sf_log_Level_get();
if(enLevel <= enDstLevel)
{
va_list args;
pszFmt = (NULL == pszFmt) ? "" : pszFmt;
if(enLevel <= SF_LOG_LEVEL_DEBUG)
{
CHAR tmpBuf[2048] = { 0 };
CHAR enCodeLog[2048] = { 0 };
if(SysGetFlag(DebugMode) == 1) {
flog = fopen(LOG_AT_FILE_PATH, "at");
}
else if(enLevel == SF_LOG_LEVEL_ERROR) {
flog = fopen(LOG_AT_FILE_PATH, "at");
}
else if(enLevel == SF_LOG_LEVEL_INFO) {
flog = fopen(INFO_FILE_PATH, "at");
}
if(flog != NULL)
{
fseek(flog, 0L, SEEK_END);
if(enLevel != SF_LOG_LEVEL_WARNING)
{
time_t timep;
struct tm *p;
time(&timep);
p = gmtime(&timep);
sprintf((char*)tmpBuf,"[%04d/%02d/%02d %02d:%02d:%02d] [%s-%d]:",p->tm_year + 1900, p->tm_mon + 1, p->tm_mday,
p->tm_hour, p->tm_min, p->tm_sec,pszFunc, u32Line);
if(debugMode == 1)
{
log_base64_encode((char*)tmpBuf, (char*)enCodeLog, strlen((char*)tmpBuf),1);
fprintf(flog, "%s", enCodeLog);
va_start(args, pszFmt);
vsprintf((char*)tmpBuf, pszFmt, args);
log_base64_encode((char*)tmpBuf, (char*)enCodeLog, strlen((char*)tmpBuf),1);
fprintf(flog, "%s", enCodeLog);
va_end(args);
}
else
{
fprintf(flog, "%s", tmpBuf);
va_start(args, pszFmt);
vsprintf((char*)tmpBuf, pszFmt, args);
fprintf(flog, "%s", tmpBuf);
va_end(args);
}
}
else
{
va_start(args, pszFmt);
vsprintf((char*)tmpBuf, pszFmt, args);
fprintf(flog, "%s", tmpBuf);
va_end(args);
}
fclose(flog);
}
}
if(enLevel == SF_LOG_LEVEL_ERROR)
{
fprintf(stdout,LIGHT_RED "[SF ERR][%s:%d]"NONE,pszFunc, u32Line);
}
else if(enLevel == SF_LOG_LEVEL_WARNING)
{
fprintf(stdout,YELLOW "[SF WARN][%s:%d]"NONE,pszFunc, u32Line);
}
else if(enLevel == SF_LOG_LEVEL_INFO)
{
fprintf(stdout,LIGHT_GREEN "[SF INFO][%s:%d]"NONE,pszFunc, u32Line);
}
else if(enLevel == SF_LOG_LEVEL_DEBUG)
{
fprintf(stdout,LIGHT_PURPLE "[SF DBG][%s:%d]"NONE,pszFunc, u32Line);
}
va_start(args, pszFmt);
vfprintf(stdout, pszFmt, args);
va_end(args);
}
return;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif