将配置文件纳入版本管理。
This commit is contained in:
55
plugin/business/pangu-http/src/replace_tool.cpp
Normal file
55
plugin/business/pangu-http/src/replace_tool.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#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);
|
||||
printf("Subject: %s\n", input);
|
||||
printf("Subsitute: %s\n", output);
|
||||
free(output);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user