This file is indexed.

/usr/share/httrack/libtest/example-main.c is in libhttrack-dev 3.48.20-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
    HTTrack library example
    .c file

    Prerequisites:
      - install winhttrack
      - set the proper path in the project settings (especially for the httrack lib and dll)

    How to build: (callback.so or callback.dll)
      With GNU-GCC:
        gcc -I/usr/include/httrack -O -g3 -Wall -D_REENTRANT -o example example.c -lhttrack2
      With MS-Visual C++:
        cl -nologo -W3 -Zi -Zp4 -DWIN32 -Fe"mycallback.exe" callbacks-example.c wsock32.lib libhttrack.lib
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#endif

/* Standard httrack module includes */
#include "httrack-library.h"
#include "htsopt.h"
#include "htsdefines.h"

/* Local definitions */
#include "example-main.h"

/*
 * Name:           main
 * Description:    main() function
 * Parameters:     None
 * Should return:  error status
*/
int main(void) {
  /* 
     First, ask for an URL 
     Note: For the test, option r2 (mirror max depth=1) and --testscan (no index, no cache, do not store, no log files)
   */
  char _argv[][256] = { "httrack_test", "<URL>", "-r3", "--testscan", "" };
  char *argv[] = { NULL, NULL, NULL, NULL, NULL };
  int argc = 0;
  httrackp *opt;
  int ret;

  while(strlen(_argv[argc])) {
    argv[argc] = _argv[argc];
    argc++;
  }
  argv[argc] = NULL;
  printf("HTTrackLib test program\n");
  printf("Enter URL (example: www.foobar.com/index.html) :");
  scanf("%s", argv[1]);
  printf("Test: 1 depth\n");

  /* Initialize the library */
#ifdef _WIN32
  {
    WORD wVersionRequested;     // requested version WinSock API
    WSADATA wsadata;            // Windows Sockets API data
    int stat;

    wVersionRequested = 0x0101;
    stat = WSAStartup(wVersionRequested, &wsadata);
    if (stat != 0) {
      printf("Winsock not found!\n");
      return;
    } else if (LOBYTE(wsadata.wVersion) != 1 && HIBYTE(wsadata.wVersion) != 1) {
      printf("WINSOCK.DLL does not support version 1.1\n");
      WSACleanup();
      return;
    }
  }
#endif
  hts_init();

  /* Create option settings and set callbacks (wrappers) */
  opt = hts_create_opt();

  CHAIN_FUNCTION(opt, init, httrack_wrapper_init, NULL);
  CHAIN_FUNCTION(opt, uninit, httrack_wrapper_uninit, NULL);
  CHAIN_FUNCTION(opt, start, httrack_wrapper_start, NULL);
  CHAIN_FUNCTION(opt, end, httrack_wrapper_end, NULL);
  CHAIN_FUNCTION(opt, chopt, httrack_wrapper_chopt, NULL);
  CHAIN_FUNCTION(opt, preprocess, httrack_wrapper_preprocesshtml, NULL);
  CHAIN_FUNCTION(opt, postprocess, httrack_wrapper_postprocesshtml, NULL);
  CHAIN_FUNCTION(opt, check_html, httrack_wrapper_checkhtml, NULL);
  CHAIN_FUNCTION(opt, query, httrack_wrapper_query, NULL);
  CHAIN_FUNCTION(opt, query2, httrack_wrapper_query2, NULL);
  CHAIN_FUNCTION(opt, query3, httrack_wrapper_query3, NULL);
  CHAIN_FUNCTION(opt, loop, httrack_wrapper_loop, NULL);
  CHAIN_FUNCTION(opt, check_link, httrack_wrapper_check, NULL);
  CHAIN_FUNCTION(opt, check_mime, httrack_wrapper_check_mime, NULL);
  CHAIN_FUNCTION(opt, pause, httrack_wrapper_pause, NULL);
  CHAIN_FUNCTION(opt, filesave, httrack_wrapper_filesave, NULL);
  CHAIN_FUNCTION(opt, filesave2, httrack_wrapper_filesave2, NULL);
  CHAIN_FUNCTION(opt, linkdetected, httrack_wrapper_linkdetected, NULL);
  CHAIN_FUNCTION(opt, linkdetected2, httrack_wrapper_linkdetected2, NULL);
  CHAIN_FUNCTION(opt, xfrstatus, httrack_wrapper_xfrstatus, NULL);
  CHAIN_FUNCTION(opt, savename, httrack_wrapper_savename, NULL);
  CHAIN_FUNCTION(opt, sendhead, httrack_wrapper_sendheader, NULL);
  CHAIN_FUNCTION(opt, receivehead, httrack_wrapper_receiveheader, NULL);

  /* Then, launch the mirror */
  ret = hts_main2(argc, argv, opt);

  /* Wait for a key */
  printf("\nPress ENTER key to exit\n");
  scanf("%s", argv[1]);

  /* Clear option state */
  hts_free_opt(opt);
  hts_uninit();
#ifdef _WIN32
  WSACleanup();
#endif

  /* That's all! */
  return 0;
}

/* CALLBACK FUNCTIONS */

/* Initialize the Winsock */
static void CDECL httrack_wrapper_init(t_hts_callbackarg * carg) {
  printf("Engine started\n");
}
static void CDECL httrack_wrapper_uninit(t_hts_callbackarg * carg) {
  printf("Engine exited\n");
}
static int CDECL httrack_wrapper_start(t_hts_callbackarg * carg, httrackp * opt) {
  printf("Start of mirror\n");
  return 1;
}
static int CDECL httrack_wrapper_chopt(t_hts_callbackarg * carg, httrackp * opt) {
  return 1;
}
static int CDECL httrack_wrapper_end(t_hts_callbackarg * carg, httrackp * opt) {
  printf("End of mirror\n");
  return 1;
}
static int CDECL httrack_wrapper_checkhtml(t_hts_callbackarg * carg,
                                           httrackp * opt, char *html, int len,
                                           const char *url_address,
                                           const char *url_file) {
  printf("Parsing html file: http://%s%s\n", url_address, url_file);
  return 1;
}
static int CDECL httrack_wrapper_loop(t_hts_callbackarg * carg, httrackp * opt,
                                      void *_back, int back_max, int back_index,
                                      int lien_n, int lien_tot, int stat_time,
                                      hts_stat_struct * stats) {
  /* printf("..httrack_wrapper_loop called\n"); */
  return 1;
}
static const char *CDECL httrack_wrapper_query(t_hts_callbackarg * carg,
                                               httrackp * opt,
                                               const char *question) {
  /* Answer is No */
  return "N";
}
static const char *CDECL httrack_wrapper_query2(t_hts_callbackarg * carg,
                                                httrackp * opt,
                                                const char *question) {
  /* Answer is No */
  return "N";
}
static const char *CDECL httrack_wrapper_query3(t_hts_callbackarg * carg,
                                                httrackp * opt,
                                                const char *question) {
  /* Answer is "" */
  return "";
}
static int CDECL httrack_wrapper_check(t_hts_callbackarg * carg, httrackp * opt,
                                       const char *adr, const char *fil,
                                       int status) {
  printf("Link status tested: http://%s%s\n", adr, fil);
  return -1;
}
static void CDECL httrack_wrapper_pause(t_hts_callbackarg * carg,
                                        httrackp * opt, const char *lockfile) {
  /* Wait until lockfile is removed.. */
}
static void CDECL httrack_wrapper_filesave(t_hts_callbackarg * carg,
                                           httrackp * opt, const char *file) {
}
static int CDECL httrack_wrapper_linkdetected(t_hts_callbackarg * carg,
                                              httrackp * opt, char *link) {
  printf("Link detected: %s\n", link);
  return 1;
}
static int CDECL httrack_wrapper_xfrstatus(t_hts_callbackarg * carg,
                                           httrackp * opt, void *back) {
  return 1;
}
static int CDECL httrack_wrapper_preprocesshtml(t_hts_callbackarg * carg,
                                                httrackp * opt, char **html,
                                                int *len,
                                                const char *url_address,
                                                const char *url_file) {
  return 1;
}
static int CDECL httrack_wrapper_postprocesshtml(t_hts_callbackarg * carg,
                                                 httrackp * opt, char **html,
                                                 int *len,
                                                 const char *url_address,
                                                 const char *url_file) {
  return 1;
}
static int CDECL httrack_wrapper_check_mime(t_hts_callbackarg * carg,
                                            httrackp * opt, const char *adr,
                                            const char *fil, const char *mime,
                                            int status) {
  return -1;
}
static void CDECL httrack_wrapper_filesave2(t_hts_callbackarg * carg,
                                            httrackp * opt, const char *adr,
                                            const char *fil, const char *save,
                                            int is_new, int is_modified,
                                            int not_updated) {
}
static int CDECL httrack_wrapper_linkdetected2(t_hts_callbackarg * carg,
                                               httrackp * opt, char *link,
                                               const char *start_tag) {
  return 1;
}
static int CDECL httrack_wrapper_savename(t_hts_callbackarg * carg,
                                          httrackp * opt,
                                          const char *adr_complete,
                                          const char *fil_complete,
                                          const char *referer_adr,
                                          const char *referer_fil, char *save) {
  return 1;
}
static int CDECL httrack_wrapper_sendheader(t_hts_callbackarg * carg,
                                            httrackp * opt, char *buff,
                                            const char *adr, const char *fil,
                                            const char *referer_adr,
                                            const char *referer_fil,
                                            htsblk * outgoing) {
  return 1;
}
static int CDECL httrack_wrapper_receiveheader(t_hts_callbackarg * carg,
                                               httrackp * opt, char *buff,
                                               const char *adr, const char *fil,
                                               const char *referer_adr,
                                               const char *referer_fil,
                                               htsblk * incoming) {
  return 1;
}