-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkstore.h
92 lines (83 loc) · 1.66 KB
/
linkstore.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* File: linkstore.h
* Author: ashish
*
* Created on 6 July, 2011, 5:20 PM
*/
#ifndef _LINKSTORE_H
#define _LINKSTORE_H
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
struct linkqueue
{
char addr[500];
struct linkqueue *link;
};
struct linkqueue *start = NULL;
struct linkqueue *next = NULL;
struct linkqueue *end = NULL;
void insert(struct linkqueue **s, struct linkqueue **e, char addr[])
{
struct linkqueue *start;
struct linkqueue *end;
struct linkqueue *temp;
string strtoins = (string)addr;
string strtocom;
start = *s;
end = *e;
temp = (struct linkqueue *) malloc (sizeof(struct linkqueue));
strcpy(temp->addr, addr);
temp->link = NULL;
if(*s == NULL)
{
*s = temp;
*e = temp;
}
else
{
while(start != NULL)
{
strtocom = (string)start->addr;
if(strtoins.compare(strtocom) == 0)
{
return;
}
start = start->link;
}
end->link = temp;
*e = temp;
}
}
void linkstore (char addr[])
{
/*
string check = (string)addr;
if(check == "http://ssl.gstatic.com" || check == "http://maps.gstatic.com")
{
return;
}*/
insert(&start, &end, addr);
}
void displaylinks()
{
struct linkqueue *s;
s = start;
int count = 1;
while (s != NULL)
{
cout<<"\n"<<count<<" ";
++count;
int i = 0;
while(s->addr[i] != '\0')
{
cout<<s->addr[i];
++i;
}
s = s->link;
}
}
#endif /* _LINKSTORE_H */