-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathnali.c
49 lines (44 loc) · 962 Bytes
/
nali.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "lib17mon/ipip.h"
#include "config.h"
void split(char **arr, char *str, const char *del) {
char *s = strtok(str, del);
while(s != NULL) {
*arr++ = s;
s = strtok(NULL, del);
}
}
void removeDuplicate(char *str[], int len) {
int i, j = 0;
int k = len - 1;
for(i = len - 1; i > 0; i--)
{
--k;
if(strncmp(str[i], "*",1))
{
if (strcmp(str[i],str[k]) == 0) {
str[i] = "*";
}
}
}
}
int main(int argc, char *argv[])
{
init(IPIPDB_PATH);
char *ip;
if (argc != 2) {
ip=(char *)malloc(128);//有可能前面有大段非数字字符,所以申请128
ip=fgets(ip,128,stdin);
} else {
ip=argv[1];
}
char result[128];
find(ip, result);
destroy();
strcat(result,"\n");
puts(result);
return 0;
}