int main(int argc, char *argv[]) { int iError; struct PageIdetify tPageIdetify; struct PageOpr *ptMainPageOpr; iError = PrintDeviceInit(); if(iError){ DebugPrint("Print device init error\n"); goto error_exit; } DebugPrint("\nSupported print device\n"); ShowPrintOpr(); if(argc != 2){ DebugPrint(DEBUG_ERR"exe <fontfile>\n"); return -1; } iError = EncodingInit(); if(iError){ DebugPrint("Encoding init error\n"); goto error_exit; } DebugPrint("\nSupported encoding\n"); ShowEncodingOpr(); iError = FontInit(); if(iError){ DebugPrint("Font init error\n"); goto error_exit; } DebugPrint("\nSupported font\n"); ShowFontOpr(); iError = SetFontsDetail("freetype", argv[1], 20); if(iError){ DebugPrint("This font can't be support. check the file format or file size\n"); goto error_exit; } iError = DisplayInit(); if(iError){ DebugPrint("Display init error\n"); goto error_exit; } DebugPrint("\nSupported display device\n"); ShowDisOpr(); SelectAndInitDefaultDisOpr("fb"); if(iError){ DebugPrint("Init default display opration error\n"); goto error_exit; } iError = InputDeviceInit(); AllInputFdInit(); if(iError){ DebugPrint("Input device init error\n"); goto error_exit; } DebugPrint("\nSupported input device\n"); ShowInputOpr(); iError = PicFmtInit(); if(iError){ DebugPrint("Picture format init error\n"); goto error_exit; } DebugPrint("\nSupported picture format\n"); ShowPicFmtParser(); iError = AllocVideoMem(5); if(iError){ DebugPrint("Alloc video memory error\n"); goto error_exit; } iError = MusicParserInit(); if(iError){ DebugPrint("MusicParser init error\n"); goto error_exit; } DebugPrint("\nSupported music\n"); ShowMusicParser(); iError = PagesInit(); if(iError){ DebugPrint("Page init error\n"); goto error_exit; } DebugPrint("\nCreated pages\n"); ShowPageOpr(); ptMainPageOpr = GetPageOpr("main"); if(NULL == ptMainPageOpr){ DebugPrint("GetPageOpr error\n"); goto error_exit; } ptMainPageOpr->RunPage(&tPageIdetify); FreeAllVideoMem(); FreeDirAndFileIcons(); PrintDeviceExit(); exit: return 0; error_exit: return -1; }
/* ./show_file [-s Size] [-f freetype_font_file] [-h HZK] <text_file> */ int main(int argc, char **argv) { int iError; unsigned int dwFontSize = 16; char acHzkFile[128]; char acFreetypeFile[128]; char acTextFile[128]; char acDisplay[128]; char cOpr; int bList = 0; acHzkFile[0] = '\0'; acFreetypeFile[0] = '\0'; acTextFile[0] = '\0'; strcpy(acDisplay, "fb"); while ((iError = getopt(argc, argv, "ls:f:h:d:")) != -1) { /* СЎПо : ./show_file -l */ switch(iError) { case 'l': { bList = 1; break; } case 's': { dwFontSize = strtoul(optarg, NULL, 0); break; } case 'f': { strncpy(acFreetypeFile, optarg, 128); acFreetypeFile[127] = '\0'; break; } case 'h': { strncpy(acHzkFile, optarg, 128); acHzkFile[127] = '\0'; break; } case 'd': { strncpy(acDisplay, optarg, 128); acDisplay[127] = '\0'; break; } default: { printf("Usage: %s [-s Size] [-d display] [-f font_file] [-h HZK] <text_file>\n", argv[0]); printf("Usage: %s -l\n", argv[0]); return -1; break; } } } if (!bList && (optind >= argc)) { printf("Usage: %s [-s Size] [-d display] [-f font_file] [-h HZK] <text_file>\n", argv[0]); printf("Usage: %s -l\n", argv[0]); return -1; } iError = DrawInit(); if (iError) { printf("DrawInit error!\n"); return -1; } if (bList) { printf("supported display:\n"); ShowDispOpr(); printf("supported font:\n"); ShowFontOpr(); printf("supported encoding:\n"); ShowEncodingOpr(); return 0; } strncpy(acTextFile, argv[optind], 128); acTextFile[127] = '\0'; iError = OpenTextFile(acTextFile); if (iError) { printf("OpenTextFile error!\n"); return -1; } iError = SetFontsDetail(acHzkFile, acFreetypeFile, dwFontSize); if (iError) { printf("SetFontsDetail error!\n"); return -1; } DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); iError = SelectAndInitDisplay(acDisplay); if (iError) { printf("SelectAndInitDisplay error!\n"); return -1; } DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); iError = ShowNextPage(); DBG_PRINTF("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); if (iError) { printf("Error to show first page\n"); return -1; } while (1) { printf("Enter 'n' to show next page, 'u' to show previous page, 'q' to exit: "); do { cOpr = getchar(); } while ((cOpr != 'n') && (cOpr != 'u') && (cOpr != 'q')); if (cOpr == 'n') { ShowNextPage(); } else if (cOpr == 'u') { ShowPrePage(); } else { ExitDisplay(); return 0; } } return 0; }