This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/plugin/business/tsg-http/test/replace_tool.cpp
fengweihao b321486e3f TSG-11849 tfe增加从环境变量中读入处理机ip
TSG-11742 IP Libraries统一使用.分隔地理层级
TSG-10722 日志中开始时间从解析层获取
2022-09-09 10:44:11 +08:00

56 lines
986 B
C++

#include "pattern_replace.h"
#include <sys/types.h>//fstat
#include <sys/ioctl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
void print_help(void)
{
printf("Escape $ with \\$\n");
printf("-i Input Text");
printf("-f Find What\n");
printf("-r Replace With\n");
}
int main(int argc, char ** argv)
{
const char* find=NULL, *replacement=NULL, *input=NULL;
int oc=0;
if(argc<6)
{
print_help();
return -1;
}
while((oc=getopt(argc,argv,"f:r:i:"))!=-1)
{
switch(oc)
{
case 'f':
find=strdup(optarg);
break;
case 'r':
replacement=strdup(optarg);
break;
case 'i':
input=strdup(optarg);
break;
default:
printf("Invalid parameter.\n");
print_help();
return -1;
}
}
char* output=NULL;
size_t output_sz=0;
simple_replace(find, replacement, input, strlen(input),&output, &output_sz, 1);
printf("Subject: %s\n", input);
printf("Subsitute: %s\n", output);
free(output);
return 0;
}