📄 module_load.c
字号:
#include <stdio.h>#include <string.h>#include <stdlib.h>#include "module_load.h"#ifdef __cplusplus#if __cplusplusextern "C"{#endif#endif /* __cplusplus *///ssize_t getline(char **lineptr, size_t *n, FILE *stream);//#define _GNU_SOURCE#if 1int getloadline(char *s, int n, FILE *f) { register int i=0; while(1) { s[i] = (char)fgetc(f); if(s[i] == 13) s[i] = fgetc(f); if((s[i] == 0x4) || (s[i] == 10) || (i == (n-1))) { s[i] = '\0'; return (feof(f) ? 1 : 0); } ++i; }}#endifint ML_ExeLoad(char* pszParam){ FILE* pstruPopen = NULL; char aszLoad[512] = {0}; //HI_S32 s32I; //strcat(aszLine, " 2>&1 | tee 2>&1"); strcpy(aszLoad, pszParam); strcat(aszLoad, " 2>&1"); pstruPopen = popen(aszLoad, "r"); if(NULL != pstruPopen) { bool s32Rtn = true; while(s32Rtn) { int s32ReadSize; char aBuffer[256] = {0}; char* pszError; memset(aBuffer, 0, 256); s32ReadSize = fread(aBuffer, 255, 1, pstruPopen); if(strlen(aBuffer) > 0) { aBuffer[s32ReadSize] = '\0'; #ifdef LOGQUEUE printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n"); printf("%s", aBuffer); printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n");#endif pszError = strstr(aBuffer, "-1"); if(NULL != pszError) { pclose(pstruPopen); return 1; } } else { s32Rtn = false; } } } pclose(pstruPopen); return 0;}#ifdef __cplusplus#if __cplusplus}#endif#endif /* __cplusplus */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -