DWORD FInit(MemTagTypes eMemTag) { InitTag(eMemTag); m_pSOSPacketCache = SOS_ObjectStore::CreateStore( L"SNIPacket", OBJECTSTORE_SNI_PACKET, MAX_PACKET_CACHE_SIZE, SNIMemRegion::DestroyCallback); if ( NULL == m_pSOSPacketCache ) return ERROR_OUTOFMEMORY; // Permanently bind packet cache to system pool since in a lot of cases packets are // allocated in system pool and released in user pool // m_pSOSPacketCache->SetStaticallyBoundPoolId (SOS_ResourceManager::SYSTEM_ID); m_pPacketPmo = m_pSOSPacketCache->CreateMemObject(MEMOBJ_SNIPACKETOBJECTSTORE , bThreadSafe | bPageHeap | bNoSlots ); if ( NULL == m_pPacketPmo) { SOS_ObjectStore::DestroyStore (m_pSOSPacketCache); m_pSOSPacketCache = NULL; return ERROR_OUTOFMEMORY; } return ERROR_SUCCESS; }
//读取JPEG代码,并解码 BOOL LoadJpegFile (const unsigned char *JpegFileName) { DWORD JpegBufSize; const unsigned char *hJpegBuf; int funcret; hJpegBuf=JpegFileName;//JPEG文件头 lpJpegBuf=(unsigned char*)hJpegBuf;//转换为变量指针 InitTable(); if((funcret=InitTag())!=FUNC_OK)//初始化表头不成功 { showerror(funcret);//错误信息显示 return FALSE; } if((SampRate_Y_H==0)||(SampRate_Y_V==0)) { return FALSE ; } funcret=Decode(); if(funcret==FUNC_OK)//解码成功 { return TRUE; } else { return FALSE; } }
char* LoadJpegFile (char *jpegbuf, char *bmpbuf) { DWORD ImgSize; DWORD JpegBufSize; int funcret; LPBITMAPINFOHEADER lpImgData; //JpegBufSize=size; lpJpegBuf=jpegbuf; InitTable(); if((funcret=InitTag())!=FUNC_OK) { showerror(funcret); return NULL; } //create new bitmapfileheader and bitmapinfoheader memset((char *)&bf,0,sizeof(BITMAPFILEHEADER)); memset((char *)&bi,0,sizeof(BITMAPINFOHEADER)); bi.biSize=(DWORD)sizeof(BITMAPINFOHEADER); bi.biWidth=(LONG)(ImgWidth); bi.biHeight=(LONG)(ImgHeight); bi.biPlanes=1; bi.biBitCount=24; bi.biClrUsed=0; bi.biClrImportant=0; bi.biCompression=BI_RGB; NumColors=0; LineBytes=(DWORD)WIDTHBYTES(bi.biWidth*bi.biBitCount); ImgSize=(DWORD)LineBytes*bi.biHeight; bf.bfType=0x4d42; bf.bfSize=/*sizeof(BITMAPFILEHEADER)*/ 14+sizeof(BITMAPINFOHEADER)+NumColors*sizeof(RGBQUAD)+ImgSize; bf.bfOffBits=(DWORD)(NumColors*sizeof(RGBQUAD)+14/*sizeof(BITMAPFILEHEADER)*/+sizeof(BITMAPINFOHEADER)); lpPtr = (char*)bmpbuf + 54; if((SampRate_Y_H==0)||(SampRate_Y_V==0)) { showerror(FUNC_FORMAT_ERROR); return NULL ; } funcret=Decode(); memcpy(bmpbuf, &bf.bfType,sizeof(WORD)); memcpy(bmpbuf+2, ((char*)&bf)+4, 12); memcpy(bmpbuf+14, (LPSTR)&bi,sizeof(BITMAPINFOHEADER)); if(funcret!=FUNC_OK) { showerror(funcret); return NULL; } return lpPtr; }
//智能画图 //FileName:要显示的图片文件 BMP/JPG/JPEG //(sx,sy) :开始显示的坐标点 //(ex,ey) :结束显示的坐标点 //图片在开始和结束的坐标点范围内显示 BOOL AI_LoadPicFile(u8 *filename,u16 sx,u16 sy,u16 ex,u16 ey) {// FIL* f_bmp; int funcret;//返回值 //得到显示方框大小 u8 fileTpe; int index; for( index=0;index<1024;index++) iclip[index]=0; if(ey>sy)PICINFO.S_Height=ey-sy; else PICINFO.S_Height=sy-ey; if(ex>sx)PICINFO.S_Width=ex-sx; else PICINFO.S_Width=sx-ex; //显示区域无效 if(PICINFO.S_Height==0||PICINFO.S_Width==0) { PICINFO.S_Height=LCD_H; PICINFO.S_Width=LCD_W; return FALSE; } //影响速度 //SD_Init();//初始化SD卡,在意外拔出之后可以正常使用 //显示的开始坐标点 PICINFO.S_YOFF=sy; PICINFO.S_XOFF=sx; fileTpe=f_typetell((u8*)filename); //得到文件的类型 if(fileTpe==T_BMP)//得到一个BMP图像 { funcret=BmpDecode(filename); //得到一个BMP图像 return funcret; } else if(fileTpe==T_JPG||fileTpe==T_JPEG)//得到JPG/JPEG图片 { funcret=f_open(f_jpeg,(const TCHAR*)filename,FA_READ);//打开文件 if(funcret==FR_OK){ f_read(f_jpeg,jpg_buffer,1024,(UINT*)&br); InitTable(); if((funcret=InitTag())!=FUNC_OK)return FALSE; if((SampRate_Y_H==0)||(SampRate_Y_V==0))return FALSE ; AI_Drow_Init(); funcret=Decode(); } f_close(f_jpeg); }else return FALSE; //非图片格式!!! if(funcret==FUNC_OK)return TRUE;//解码成功 else return FALSE; //解码失败 }
DWORD FInit(MemTagTypes eMemTag) { InitTag(eMemTag); return ERROR_SUCCESS; }
/* * Show filelist from current area, called from the menu. */ void File_List() { int FileCount = 0; unsigned FileBytes = 0; _Tag T; struct _fdbarea *fdb_area = NULL; char temp[81]; iLineCount = 0; WhosDoingWhat(FILELIST, NULL); Syslog('+', "Listing File Area # %d", iAreaNumber); if (Access(exitinfo.Security, area.LTSec) == FALSE) { Enter(1); /* You don't have enough security to list this area */ pout(YELLOW, BLACK, (char *) Language(236)); Enter(2); Pause(); return; } InitTag(); if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) return; if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'b'); clear(); Header(); if (iLC(2) == 1) { mbsedb_CloseFDB(fdb_area); chartran_close(); return; } while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { memset(&T, 0, sizeof(T)); T.Area = iAreaNumber; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, chartran(fdb.LName), 80); SetTag(T); if (ShowOneFile() == 1) { mbsedb_CloseFDB(fdb_area); chartran_close(); return; } if (fdb.Deleted) { /* D E L E T E D */ /* Uploaded by: */ snprintf(temp, 81, " -- %-12s %s [%4d] %s%s\n", fdb.Name, (char *) Language(239), fdb.TimesDL, (char *) Language(238), fdb.Uploader); PUTSTR(temp); } FileCount++; /* Increase File Counter by 1 */ FileBytes += fdb.Size; /* Increase File Byte Count */ } Mark(); Enter(1); /* Total Files: */ snprintf(temp, 81, "%s%d / %d bytes", (char *) Language(242), FileCount, FileBytes); pout(LIGHTCYAN, BLACK, temp); Enter(2); chartran_close(); iLineCount = 0; mbsedb_CloseFDB(fdb_area); Pause(); }
/* * Scan for new files, called from menu. */ int NewfileScan(int AskStart) { FILE *pAreas; int ifDate, itDate; char *temp, *Date; int Found, Count = 0; _Tag T; struct _fdbarea *fdb_area = NULL; Date = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char)); iLineCount = 2; arecno = 1; /* Reset Area Number to One */ if (AskStart) { Enter(2); /* Search for new since your last call [Y/n]: */ pout(LIGHTCYAN, BLACK, (char *) Language(273)); colour(CFG.InputColourF, CFG.InputColourB); if (toupper(Readkey()) == Keystroke(273, 1)) { Enter(1); /* Enter new date to search for [DD-MM-YYYY]: */ pout(GREEN, BLACK, (char *) Language(274)); colour(CFG.InputColourF, CFG.InputColourB); GetDate(temp, 10); } else { strcpy(temp, LastLoginDate); } } else { strcpy(temp, LastLoginDate); } Syslog('+', "NewfileScan() since %s", temp); clear(); /* File Search by Date */ pout(WHITE, BLACK, (char *) Language(275)); Enter(2); Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ itDate = atol(Date); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Sheader(); Found = FALSE; Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */ Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ /* and invalid to this cause */ ifDate = atol(Date); if (ifDate >= itDate) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } } /* End of if */ } /* End of while */ mbsedb_CloseFDB(fdb_area); /* * Add 2 blank lines after found files. */ if (Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); fclose(pAreas); return 1; } } } /* End of open filebase */ } /* End of check new files scan */ arecno++; /* Go to next file area */ } /* End of Main */ if (Count) Syslog('+', "Found %d new files", Count); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); free(temp); free(Date); return 1; }
/* * Search for a file, called from the menu. */ int FilenameScan() { FILE *pAreas; int Found, Count = 0; char mask[256]; char *Name; _Tag T; unsigned int OldArea; struct _fdbarea *fdb_area = NULL; Name = calloc(81, sizeof(char)); OldArea = iAreaNumber; iLineCount = 2; /* Reset Line Counter to Zero */ arecno = 1; /* Reset Area Number to One */ Enter(2); /* Accepts wildcards such as : *.zip, *.gz, *.* */ pout(WHITE, BLACK, (char *) Language(269)); Enter(2); /* Enter filename to search for : */ pout(LIGHTCYAN, BLACK, (char *) Language(271)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Name, 80); if ((strcmp(Name, "")) == 0) { free(Name); return 0; } strcpy(mask, re_mask(Name, TRUE)); Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask); free(Name); re_comp(mask); clear(); /* File Search by Filename */ pout(WHITE, BLACK, (char *) Language(272)); Enter(1); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Found = FALSE; Sheader(); Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { if (re_exec(fdb.Name) || re_exec(fdb.LName)) { if (!Found) { Enter(2); if (iLC(2) == 1) { SetFileArea(OldArea); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 81); SetTag(T); Count++; if (ShowOneFile() == 1) { SetFileArea(OldArea); return 1; } } } /* End of while */ mbsedb_CloseFDB(fdb_area); if (Found) { Enter(2); if (iLC(2) == 1) { SetFileArea(OldArea); return 1; } } } /* End Check for LTSec */ } /* if access */ arecno++; /* Go to next file area */ } /* End of Main */ Syslog('+', "Found %d files", Count); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); SetFileArea(OldArea); return 1; }
/* * Search for keyword, called from menu. */ int KeywordScan() { FILE *pAreas; int i, z, y, Found, Count = 0; char *Name, *tmpname, *BigDesc, temp[81]; _Tag T; unsigned int OldArea; struct _fdbarea *fdb_area = NULL; Name = calloc(81, sizeof(char)); tmpname = calloc(81, sizeof(char)); BigDesc = calloc(1230, sizeof(char)); OldArea = iAreaNumber; iLineCount = 2; /* Reset Line Counter to Zero */ arecno = 1; /* Reset Area Number to One */ Enter(2); /* Enter keyword to use for Search: */ pout(LIGHTCYAN, BLACK, (char *) Language(267)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Name, 80); if ((strcmp(Name, "")) == 0) return 0; strcpy(tmpname, tl(Name)); strcpy(Name, ""); y = strlen(tmpname); for (z = 0; z < y; z++) { if (tmpname[z] != '*') { snprintf(temp, 81, "%c", tmpname[z]); strcat(Name, temp); } } Syslog('+', "KeywordScan(): \"%s\"", Name); clear(); /* File search by keyword */ pout(WHITE, BLACK, (char *) Language(268)); Enter(1); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Nopper(); Found = FALSE; Sheader(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { for (i = 0; i < 25; i++) snprintf(BigDesc, 1230, "%s%s", BigDesc, *(fdb.Desc + i)); if ((strstr(fdb.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(BigDesc); free(Name); free(tmpname); SetFileArea(OldArea); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { free(BigDesc); free(Name); free(tmpname); SetFileArea(OldArea); return 1; } } strcpy(BigDesc, ""); /* Clear BigDesc */ } /* while */ mbsedb_CloseFDB(fdb_area); if (Found) { Enter(2); if (iLC(2) == 1) { free(BigDesc); free(Name); free(tmpname); SetFileArea(OldArea); return 1; } } } /* End check for LTSec */ } /* if access */ arecno++; /* Go to next file area */ } /* End of Main */ Syslog('+', "Found %d files", Count); free(BigDesc); free(Name); free(tmpname); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); SetFileArea(OldArea); return 1; }