secgateway/Platform/user/configm/config-test/configtest.c

58 lines
1.4 KiB
C

#include <stdlib.h>
#include <stdio.h>
#include "rpc.h"
#include "configm.h"
#include "ipconfig.h"
#include "ret_errno.h"
int main(int argc, char **argv)
{
FILE *f = NULL;
char config_linebuf[512];
char* output = NULL;
int output_len;
long int config_id;
ret_code code;
char *stop;
if(argc != 2 )
{
printf("input error!\n");
return EXIT_FAILURE;
}
config_id = strtol(argv[1], &stop, 16);
printf("config id:0x%lx\n",config_id);
//while(1)
{
f = fopen(argv[1],"r+");
if(f == NULL)
{
printf("OPEN CONFIG test file FALID\n");
return EXIT_FAILURE;
}
memset(config_linebuf, 0, sizeof(config_linebuf));
while(fgets(config_linebuf, 512, f) != NULL)
{
char code_str[ERR_STR_LEN] = {0};
printf("configure: %s\n", config_linebuf);
code = web_config_exec_sync(CM_CONFIG_SET, config_id,
config_linebuf, strlen(config_linebuf) + 1, &output, &output_len);
ret_code_format(code, code_str);
printf("call config type return:%s,result:%s\n", code_str, output);
memset(config_linebuf, 0, sizeof(config_linebuf));
memset(output, 0, output_len);
}
fclose(f);
rpc_sleep(1000);
}
return EXIT_SUCCESS;
}