-
Notifications
You must be signed in to change notification settings - Fork 441
/
Ads.h
111 lines (91 loc) · 3.37 KB
/
Ads.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Matt Wells copyright Jan 9, 2002
// ad fetcher and parser
#ifndef _ADS_H_
#define _ADS_H_
#include "Url.h"
#include "SafeBuf.h"
//#include "CollectionRec.h"
#define MAX_BLOB_SIZE 2048
#define MAX_ADS 20
#define MAX_FEEDS 4
#define MAX_AD_QUERY_LEN 1024
#define PI_PRIMARY 0
#define PI_BACKUP 1
#define SS_PRIMARY 2
#define SS_BACKUP 3
class Ads {
public:
Ads(); // constructor
~Ads(); // destructor
bool getAds ( char *q ,
int32_t qlen ,
int32_t pageNum ,
int32_t queryIP ,
char *coll ,
void *state ,
void (*callback)(void *state) );
// . returns false if blocks, true otherwise
// . sets g_errno on error
// . "q" is the NULL terminated query
// . "ip" is the ip of the user performing the query
int32_t getNumPaidInclusionAds ( ) { return m_numAds[m_indexPIAds]; };
int32_t getNumSkyscraperAds ( ) { return m_numAds[m_indexSSAds]; };
bool hasAds ( ) {
return (bool)(m_numAds[m_indexPIAds] || m_numAds[m_indexSSAds]);
};
bool gotAllRequests () {
return (bool)(m_numGotAds >= MAX_FEEDS);
};
void printPaidInclusionAds(SafeBuf *sb, int32_t numCharPerLine );
void printSkyscraperAds (SafeBuf *sb, int32_t numCharPerLine );
// need to keep public so wrapper can call
void gotDoc( class TcpSocket *ts, int32_t index );
void selectDisplayAds( );
void *m_state;
void (*m_callback)(void *state);
//static void initCollAvailAds( );
//static void setAvailableAds ( char *coll );
//static int32_t getAdFeedIndex ( collnum_t cn );
private:
bool getAd ( int32_t index ,
char *cgi ,
int32_t numAds );
void printAd( SafeBuf *sb ,
char *url , int32_t urlLen,
char *title , int32_t titleLen,
char *desc , int32_t descLen,
char *site , int32_t siteLen,
int32_t numCharPerLine );
char *m_coll;
int32_t m_queryIP;
int32_t m_pageAds;
int32_t m_feedIndex;
int32_t m_indexPIAds;
int32_t m_indexSSAds;
int32_t m_numGotAds;
bool m_adSSSameasPI;
bool m_adBSSSameasBPI;
CollectionRec *m_cr;
char m_q [ MAX_AD_QUERY_LEN ];
int32_t m_qlen;
char *m_titles [MAX_FEEDS][ MAX_ADS ];
int32_t m_titlesLen[MAX_FEEDS][ MAX_ADS ];
char *m_desc [MAX_FEEDS][ MAX_ADS ];
int32_t m_descLen [MAX_FEEDS][ MAX_ADS ];
char *m_sites [MAX_FEEDS][ MAX_ADS ];
int32_t m_sitesLen [MAX_FEEDS][ MAX_ADS ];
char *m_urls [MAX_FEEDS][ MAX_ADS ];
int32_t m_urlsLen [MAX_FEEDS][ MAX_ADS ];
int32_t m_numAds [MAX_FEEDS];
char *m_buf [MAX_FEEDS];
int32_t m_bufLen [MAX_FEEDS];
//Url m_url [MAX_FEEDS];
Xml m_xml [MAX_FEEDS];
//static int32_t s_availableAds[16][MAX_AD_FEEDS];
//static int32_t s_numAvailableAds[16];
};
struct AdFeed {
Ads *m_ads;
int32_t m_index;
};
#endif