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

52 lines
1.2 KiB
C
Raw Normal View History

#include <stdlib.h>
#include <stdio.h>
#include "rpc.h"
#include "configm.h"
#include "ipconfig.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);
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)
{
printf("configure: %s\n", config_linebuf);
code = web_config_exec_sync(CM_CONFIG_GET, config_id,
config_linebuf, strlen(config_linebuf) + 1, &output, &output_len);
printf("call config type retturn:%s,result:%s\n", rpc_code_format(code), output);
memset(config_linebuf, 0, sizeof(config_linebuf));
}
fclose(f);
return EXIT_SUCCESS;
}