summaryrefslogtreecommitdiff
path: root/src/proxy/proxystrings.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/proxy/proxystrings.h')
-rwxr-xr-xsrc/proxy/proxystrings.h81
1 files changed, 42 insertions, 39 deletions
diff --git a/src/proxy/proxystrings.h b/src/proxy/proxystrings.h
index 23456a7..09d0f9f 100755
--- a/src/proxy/proxystrings.h
+++ b/src/proxy/proxystrings.h
@@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Please visit our Website: http://www.httrack.com
*/
-
/* ------------------------------------------------------------ */
/* File: Strings */
/* Author: Xavier Roche */
@@ -29,89 +28,93 @@ Please visit our Website: http://www.httrack.com
// Strings a bit safer than static buffers
#ifndef HTS_PROXYSTRINGS_DEFSTATIC
-#define HTS_PROXYSTRINGS_DEFSTATIC
+#define HTS_PROXYSTRINGS_DEFSTATIC
#include "htsstrings.h"
-
/* Tools */
static int ehexh(char c) {
- if ((c>='0') && (c<='9')) return c-'0';
- if ((c>='a') && (c<='f')) c-=('a'-'A');
- if ((c>='A') && (c<='F')) return (c-'A'+10);
+ if ((c >= '0') && (c <= '9'))
+ return c - '0';
+ if ((c >= 'a') && (c <= 'f'))
+ c -= ('a' - 'A');
+ if ((c >= 'A') && (c <= 'F'))
+ return (c - 'A' + 10);
return 0;
}
-static int ehex(const char* s) {
- return 16*ehexh(*s)+ehexh(*(s+1));
+static int ehex(const char *s) {
+ return 16 * ehexh(*s) + ehexh(*(s + 1));
}
-static void unescapehttp(const char* s, String* tempo) {
+static void unescapehttp(const char *s, String * tempo) {
int i;
- for (i = 0; s[i] != '\0' ; i++) {
- if (s[i]=='%' && s[i+1]=='%') {
+
+ for(i = 0; s[i] != '\0'; i++) {
+ if (s[i] == '%' && s[i + 1] == '%') {
i++;
StringAddchar(*tempo, '%');
- } else if (s[i]=='%') {
+ } else if (s[i] == '%') {
char hc;
+
i++;
- hc = (char) ehex(s+i);
+ hc = (char) ehex(s + i);
StringAddchar(*tempo, (char) hc);
- i++; // sauter 2 caractères finalement
- }
- else if (s[i]=='+') {
+ i++; // sauter 2 caractères finalement
+ } else if (s[i] == '+') {
StringAddchar(*tempo, ' ');
- }
- else
+ } else
StringAddchar(*tempo, s[i]);
}
}
-static void escapexml(const char* s, String* tempo) {
+static void escapexml(const char *s, String * tempo) {
int i;
- for (i=0 ; s[i] != '\0' ; i++) {
+
+ for(i = 0; s[i] != '\0'; i++) {
if (s[i] == '&')
StringCat(*tempo, "&amp;");
- else if (s[i] == '<')
+ else if (s[i] == '<')
StringCat(*tempo, "&lt;");
- else if (s[i] == '>')
+ else if (s[i] == '>')
StringCat(*tempo, "&gt;");
- else if (s[i] == '\"')
+ else if (s[i] == '\"')
StringCat(*tempo, "&quot;");
else
StringAddchar(*tempo, s[i]);
}
}
-static char* concat(char *catbuff,const char* a,const char* b) {
- if (a != NULL && a[0] != '\0') {
- strcpy(catbuff, a);
- } else {
- catbuff[0] = '\0';
- }
- if (b != NULL && b[0] != '\0') {
- strcat(catbuff, b);
- }
+static char *concat(char *catbuff, const char *a, const char *b) {
+ if (a != NULL && a[0] != '\0') {
+ strcpy(catbuff, a);
+ } else {
+ catbuff[0] = '\0';
+ }
+ if (b != NULL && b[0] != '\0') {
+ strcat(catbuff, b);
+ }
return catbuff;
}
-static char* __fconv(char* a) {
+static char *__fconv(char *a) {
#ifdef WIN32
int i;
- for(i = 0 ; a[i] != 0 ; i++)
- if (a[i] == '/') // Unix-to-DOS style
+
+ for(i = 0; a[i] != 0; i++)
+ if (a[i] == '/') // Unix-to-DOS style
a[i] = '\\';
#endif
return a;
}
-static char* fconcat(char *catbuff, const char* a, const char* b) {
- return __fconv(concat(catbuff,a,b));
+static char *fconcat(char *catbuff, const char *a, const char *b) {
+ return __fconv(concat(catbuff, a, b));
}
-static char* fconv(char *catbuff, const char* a) {
- return __fconv(concat(catbuff,a,""));
+static char *fconv(char *catbuff, const char *a) {
+ return __fconv(concat(catbuff, a, ""));
}
#endif