- It actually wasn't a very good idea to authenticate against the MD5 password hash...
[reactos.git] / rostests / rosautotest / tools.c
1 /*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Various helper functions
5 * COPYRIGHT: Copyright 2008-2009 Colin Finck <colin@reactos.org>
6 */
7
8 #include "precomp.h"
9
10 /**
11 * Escapes a string according to RFC 1738.
12 * Required for passing parameters to the web service.
13 *
14 * @param Output
15 * Pointer to a CHAR array, which will receive the escaped string.
16 * The output buffer must be large enough to hold the full escaped string. You're on the safe side
17 * if you make the output buffer three times as large as the input buffer.
18 *
19 * @param Input
20 * Pointer to a CHAR array, which contains the input buffer to escape.
21 */
22 VOID
23 EscapeString(PCHAR Output, PCHAR Input)
24 {
25 const CHAR HexCharacters[] = "0123456789ABCDEF";
26
27 do
28 {
29 if(strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~", *Input) )
30 {
31 /* It's a character we don't need to escape, just add it to the output string */
32 *Output++ = *Input;
33 }
34 else
35 {
36 /* We need to escape this character */
37 *Output++ = '%';
38 *Output++ = HexCharacters[((UCHAR)*Input >> 4) % 16];
39 *Output++ = HexCharacters[(UCHAR)*Input % 16];
40 }
41 } while(*++Input);
42
43 *Output = 0;
44 }
45
46 /**
47 * Outputs a string through the standard output and the debug output.
48 *
49 * @param String
50 * The string to output
51 */
52 VOID
53 StringOut(PCHAR String)
54 {
55 printf(String);
56 OutputDebugStringA(String);
57 }