static void utf16big_start(txtEncodeParser *thiz, int startoffset) { __u8 *buff; int len; buff = thiz->bufferTxt + BufferLenght; //缓冲区指针 if( startoffset <= 2 ) { thiz->bof = EPDK_TRUE; thiz->start = 2; eLIBs_fseek(thiz->fd, thiz->start , ELIBS_SEEK_SET); //待定-------------- return; } thiz->bof = EPDK_FALSE; startoffset = (startoffset%2)?(startoffset+1):(startoffset); eLIBs_fseek(thiz->fd, startoffset , ELIBS_SEEK_SET); len = eLIBs_fread(buff, sizeof(char), BufferLenght, thiz->fd); if( len != BufferLenght) { thiz->eof = EPDK_TRUE; } thiz->eof = EPDK_FALSE; thiz->start = startoffset; return; }
static void utf16big_next(txtEncodeParser *thiz, int current_start) { int len, end; thiz->start = current_start; thiz->bof = (current_start < 2)?EPDK_TRUE : EPDK_FALSE; thiz->bufferTxtlen = 0; //文件数据缓冲清0 eLIBs_fseek( thiz->fd, thiz->start, ELIBS_SEEK_SET); len = eLIBs_fread(thiz->bufferTxt, sizeof(char), BufferLenght, thiz->fd); if (len != BufferLenght) //已读到了文章的尾部 { thiz->eof = EPDK_TRUE; //置文件尾部标志位 thiz->bufferTxtlen = len; __inf("%s %d len = %d \n", __FUNCTION__, __LINE__, len); return; } thiz->eof = EPDK_FALSE; //删除缓冲区中最后一个回车以后的字符 end = (len%2)?(len+1):len; thiz->bufferTxtlen = end; __inf("%s %d len = %d \n", __FUNCTION__, __LINE__, end); return; }
char *__sdlx_getenvr(void) { __u8 err; __krnl_tcb_t *tcb; #if 0 ES_FILE * edebug; #endif // 由于EPDK本身的krnl.h久未更新,因此申请内存不能按照sizeof(__krnl_tcb_t)来 // 进行,否则会导致堆栈溢出。 tcb = (__krnl_tcb_t *)malloc(max(sizeof(__krnl_tcb_t), 0x1000)); err = esKRNL_TaskQuery(OS_PRIO_SELF, tcb); if(err == OS_NO_ERR) { // OS_NO_ERR if (tcb->xcb != NULL) { strcpy(xfile, tcb->xcb->xfile); xdirp = strlen(xfile); while(xdirp>=0 && xfile[xdirp] != '\\' && xfile[xdirp] != '/') --xdirp; #if 0 edebug = eLIBs_fopen("e:\\tcb_xcb.txt", "w+"); eLIBs_fseek(edebug, 0, 2); fprintf((FILE *)edebug, "%s\n%d\n", xfile, xdirp); eLIBs_fclose(edebug); #endif } } free(tcb); return xfile; }
static void utf16big_prev(txtEncodeParser *thiz, int current_start) { int start; int len; //__u8 *b; start = current_start - BufferLenght; thiz->bof = EPDK_FALSE; //b = thiz->bufferTxt + BufferLenght; if(start < 0) { start = 2; thiz->bof = EPDK_TRUE; eLIBs_fseek( thiz->fd, start, ELIBS_SEEK_SET); len = eLIBs_fread(thiz->bufferTxt, sizeof(char), current_start, thiz->fd); thiz->bufferTxtlen = current_start; thiz->start = 0; return; } start = (start%2)?(start+1):start; thiz->start = start; __inf(" %s %d start = %d end = %d \n", __FUNCTION__, __LINE__, start, current_start); eLIBs_fseek( thiz->fd, start, ELIBS_SEEK_SET); len = eLIBs_fread(thiz->bufferTxt, sizeof(char), BufferLenght, thiz->fd); __inf(" %s %d len = %d \n", __FUNCTION__, __LINE__, len); if (len != BufferLenght) //已读到了文章的尾部 { thiz->eof = EPDK_TRUE; //置文件尾部标志位 } thiz->bufferTxtlen = len; }
size_t fread(void *ptr,size_t size, size_t nmemb, FILE *fp) { #if 0 ES_FILE * edebug; edebug = eLIBs_fopen("e:\\fp_fread_output.txt", "w+"); eLIBs_fseek(edebug, 0, 2); fprintf(fp, "%x, %x, %x, %x, %x, %x, %x", ptr, size, nmemb, fp, &__stdin, &__stdout, &__stderr); eLIBs_fclose(edebug); #endif if (fp == (FILE *)&__stdin || fp == (FILE *)&__stdout || fp == (FILE *)&__stderr) return size; // 待实现 return eLIBs_fread(ptr,size,nmemb, (ES_FILE *)fp); }
FILE *fopen(const char *name, const char *mode) { char ptbuf[FSYS_DIRNAME_MAX]; #if 0 ES_FILE * edebug; edebug = eLIBs_fopen("e:\\fp_output.txt", "w+"); eLIBs_fseek(edebug, 0, 2); eLIBs_fputs(name, edebug); eLIBs_fputc('\n', edebug); eLIBs_fclose(edebug); #endif _fcrt_name(ptbuf, name); return (FILE *)eLIBs_fopen(ptbuf, mode); }
static H_LYR StandyWndCreate(const char *file_path) { H_LYR hLyr; int rotation; FB frameBuf; ES_FILE *file = NULL; void *file_data = NULL; bmp_file_head_t *f_head= NULL; __layerwincreate_para_t layerWinCreate; __disp_layer_para_t lyrPara; __u32 lenth; file = eLIBs_fopen(file_path,"rb"); if(file == NULL){ __msg("file open fail\n"); //return NULL; goto end; } f_head = eLIBs_malloc(sizeof(bmp_file_head_t)); if(f_head==NULL){ __msg("file malloc fail\n"); goto end; } eLIBs_fread(f_head,1,sizeof(bmp_file_head_t),file); if(f_head->bfType[0]!='B'||f_head->bfType[1]!='M'){ __msg("file isnot bmp\n"); goto end; } file_data = eLIBs_malloc(f_head->bfSize); eLIBs_fseek(file,0,SEEK_SET); lenth = eLIBs_fread(file_data,1,f_head->bfSize,file); __msg("lenth==%d\n",lenth); rotation = GUI_GetScnDir(); MwLayerParaInit(&layerWinCreate, &frameBuf, &lyrPara, "Layer", rotation, 1, 320, 240); MwFillSize(&frameBuf.size, 320 , 240); MwFillRect(&lyrPara.src_win, 0, 0, 320, 240); hLyr = GUI_LyrWinCreate(&layerWinCreate); if (NULL == hLyr) { __msg("Create layer (%s) failed", layerWinCreate.name); goto end; } GUI_LyrWinSel(hLyr); GUI_BMP_Draw(file_data, 0, 0); GUI_LyrWinSetSta(hLyr,GUI_LYRWIN_STA_ON); eLIBs_fclose(file); eLIBs_free(f_head); eLIBs_free(file_data); return hLyr; end: if(file){ eLIBs_fclose(file); } if(f_head){ eLIBs_free(f_head); } if(file_data){ eLIBs_free(file_data); } return NULL; }
int fseek(FILE * fp, long offset, int whence) { if (fp == (FILE *)&__stdin || fp == (FILE *)&__stdout || fp == (FILE *)&__stderr) return 0; // 待实现 return eLIBs_fseek((ES_FILE *)fp, offset, whence); }