1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <stdio.h> 17 #include <stdlib.h> 18 19 #include "hnpsamplelib.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #define HNPSAMPLE_INDEX_2 2 26 #define MAX_DELAY_TIME 60 27 28 // hnpsample软件功能包括:读取cfg文件并打印内容,执行依赖的so函数。通过argv[1]参数控制运行的时间,单位s main(int argc,char * argv[])29int main(int argc, char *argv[]) 30 { 31 int sectime = 0; 32 33 printf("\nstart hnp sample"); 34 35 if (argc == HNPSAMPLE_INDEX_2) { 36 sectime = atoi(argv[1]); 37 if (sectime > MAX_DELAY_TIME) { 38 sectime = 0; 39 } 40 } 41 42 // 读取配置文件内容并打印 43 FILE *file = fopen("../cfg/hnpsample.cfg", "r"); 44 if (file != NULL) { 45 printf("\ncfg file content:\n"); 46 int ch; 47 while ((ch = fgetc(file)) != EOF) { 48 putchar(ch); 49 } 50 printf("\ncfg file end."); 51 fclose(file); 52 } else { 53 printf("\n open cfg=../cfg/hnpsample.cfg failed."); 54 } 55 56 // 调用依赖so的函数并进行相应延时处理 57 HnpSampleLibDelay(sectime); 58 59 printf("\nhnp sample end"); 60 return 0; 61 } 62 63 64 #ifdef __cplusplus 65 } 66 #endif