/src/httrack/src/htsname.h
Line | Count | Source |
1 | | /* ------------------------------------------------------------ */ |
2 | | /* |
3 | | HTTrack Website Copier, Offline Browser for Windows and Unix |
4 | | Copyright (C) 1998 Xavier Roche and other contributors |
5 | | |
6 | | SPDX-License-Identifier: GPL-3.0-or-later |
7 | | |
8 | | This program is free software: you can redistribute it and/or modify |
9 | | it under the terms of the GNU General Public License as published by |
10 | | the Free Software Foundation, either version 3 of the License, or |
11 | | (at your option) any later version. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | | |
21 | | Ethical use: we kindly ask that you NOT use this software to harvest email |
22 | | addresses or to collect any other private information about people. Doing so |
23 | | would dishonor our work and waste the many hours we have spent on it. |
24 | | |
25 | | Please visit our Website: http://www.httrack.com |
26 | | */ |
27 | | |
28 | | /* ------------------------------------------------------------ */ |
29 | | /* File: httrack.c subroutines: */ |
30 | | /* savename routine (compute output filename) */ |
31 | | /* Author: Xavier Roche */ |
32 | | /* ------------------------------------------------------------ */ |
33 | | |
34 | | #ifndef HTSNAME_DEFH |
35 | | #define HTSNAME_DEFH |
36 | | |
37 | | #include "htsglobal.h" |
38 | | |
39 | 0 | #define DELAYED_EXT "delayed" |
40 | 0 | #define IS_DELAYED_EXT(a) ( ((a) != NULL) && ((a)[0] != 0) && strendwith_(a, "." DELAYED_EXT) ) |
41 | 0 | HTS_STATIC int strendwith_(const char *a, const char *b) { |
42 | 0 | int i, j; |
43 | |
|
44 | 0 | for(i = 0; a[i] != 0; i++) ; |
45 | 0 | for(j = 0; b[j] != 0; j++) ; |
46 | 0 | while(i >= 0 && j >= 0 && a[i] == b[j]) { |
47 | 0 | i--; |
48 | 0 | j--; |
49 | 0 | } |
50 | 0 | return (j == -1); |
51 | 0 | } Unexecuted instantiation: fuzz-url.c:strendwith_ Unexecuted instantiation: htslib.c:strendwith_ Unexecuted instantiation: htsfetch.c:strendwith_ Unexecuted instantiation: htspsl.c:strendwith_ Unexecuted instantiation: htscore.c:strendwith_ Unexecuted instantiation: htshash.c:strendwith_ Unexecuted instantiation: htscache.c:strendwith_ Unexecuted instantiation: htsback.c:strendwith_ Unexecuted instantiation: htsftp.c:strendwith_ Unexecuted instantiation: htsparse.c:strendwith_ Unexecuted instantiation: htsname.c:strendwith_ Unexecuted instantiation: htsrobots.c:strendwith_ Unexecuted instantiation: htstools.c:strendwith_ Unexecuted instantiation: htswizard.c:strendwith_ Unexecuted instantiation: htsbauth.c:strendwith_ Unexecuted instantiation: htscodec.c:strendwith_ Unexecuted instantiation: htswarc.c:strendwith_ Unexecuted instantiation: htschanges.c:strendwith_ Unexecuted instantiation: htssinglefile.c:strendwith_ Unexecuted instantiation: htssitemap.c:strendwith_ Unexecuted instantiation: htsproxy.c:strendwith_ Unexecuted instantiation: htszlib.c:strendwith_ Unexecuted instantiation: htsconcat.c:strendwith_ |
52 | | |
53 | | #define CACHE_REFNAME "hts-cache/ref" |
54 | | |
55 | | /* Library internal definictions */ |
56 | | #ifdef HTS_INTERNAL_BYTECODE |
57 | | |
58 | | /* Forward definitions */ |
59 | | #ifndef HTS_DEF_FWSTRUCT_httrackp |
60 | | #define HTS_DEF_FWSTRUCT_httrackp |
61 | | typedef struct httrackp httrackp; |
62 | | #endif |
63 | | #ifndef HTS_DEF_FWSTRUCT_lien_url |
64 | | #define HTS_DEF_FWSTRUCT_lien_url |
65 | | typedef struct lien_url lien_url; |
66 | | #endif |
67 | | #ifndef HTS_DEF_FWSTRUCT_struct_back |
68 | | #define HTS_DEF_FWSTRUCT_struct_back |
69 | | typedef struct struct_back struct_back; |
70 | | #endif |
71 | | #ifndef HTS_DEF_FWSTRUCT_cache_back |
72 | | #define HTS_DEF_FWSTRUCT_cache_back |
73 | | typedef struct cache_back cache_back; |
74 | | #endif |
75 | | #ifndef HTS_DEF_FWSTRUCT_hash_struct |
76 | | #define HTS_DEF_FWSTRUCT_hash_struct |
77 | | typedef struct hash_struct hash_struct; |
78 | | #endif |
79 | | #ifndef HTS_DEF_FWSTRUCT_lien_back |
80 | | #define HTS_DEF_FWSTRUCT_lien_back |
81 | | typedef struct lien_back lien_back; |
82 | | #endif |
83 | | #ifndef HTS_DEF_FWSTRUCT_lien_adrfil |
84 | | #define HTS_DEF_FWSTRUCT_lien_adrfil |
85 | | typedef struct lien_adrfil lien_adrfil; |
86 | | #endif |
87 | | #ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave |
88 | | #define HTS_DEF_FWSTRUCT_lien_adrfilsave |
89 | | typedef struct lien_adrfilsave lien_adrfilsave; |
90 | | #endif |
91 | | |
92 | | // note: 'headers' can either be null, or incomplete (only r member filled) |
93 | | // note: 'sback' can be null: the type-probing request is then skipped |
94 | | int url_savename(lien_adrfilsave *const afs, |
95 | | lien_adrfil *const former, |
96 | | const char *referer_adr, const char *referer_fil, |
97 | | httrackp * opt, struct_back * sback, cache_back * cache, |
98 | | hash_struct * hash, int ptr, int numero_passe, |
99 | | const lien_back * headers); |
100 | | void standard_name(char *b, size_t bsize, const char *dot_pos, |
101 | | const char *nom_pos, const char *fil_complete, |
102 | | int short_ver); |
103 | | /* Does url's query have a field with an '=' whose key is exactly name? Its |
104 | | value, clipped to size - 1 bytes, goes to dst, of size >= 1. */ |
105 | | hts_boolean url_query_value(const char *url, const char *name, char *dst, |
106 | | size_t size); |
107 | | /* Append s to d (mapping '\' to '/'), clipped to dsize bytes including the NUL. |
108 | | Clips rather than aborts: s is a crawled link, hostile by construction. */ |
109 | | void url_savename_addstr(char *d, size_t dsize, const char *s); |
110 | | /* Append sep+s to d whole, cutting d's tail (never inside a UTF-8 character) |
111 | | for room, so the suffix always survives; nothing happens if it alone fills |
112 | | dsize. */ |
113 | | void url_savename_addtail(char *d, size_t dsize, const char *sep, |
114 | | const char *s); |
115 | | /* Leading len bytes of path into buf; returns how many were read (0 on any |
116 | | failure), so a caller reading nothing decides for itself what that means. */ |
117 | | size_t hts_read_file_head(const char *path, void *buf, size_t len); |
118 | | |
119 | | /* Contested wire-vs-ext verdict that a body sniff could settle (htssniff.h). */ |
120 | | int hts_ext_sniff_wanted(httrackp *opt, const char *wiremime, const char *file); |
121 | | char *url_md5(char *digest_buffer, const char *fil_complete); |
122 | | void url_savename_refname(const char *adr, const char *fil, char *filename); |
123 | | char *url_savename_refname_fullpath(httrackp * opt, const char *adr, |
124 | | const char *fil); |
125 | | /* Remove the temp-ref for (adr,fil); HTS_TRUE if it was removed. */ |
126 | | hts_boolean url_savename_refname_remove(httrackp *opt, const char *adr, |
127 | | const char *fil); |
128 | | #endif |
129 | | |
130 | | #endif |