1 /*
2  *  (C) Copyright 2001-2006 Wojtek Kaniewski <wojtekka@irc.pl>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU Lesser General Public License Version
6  *  2.1 as published by the Free Software Foundation.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU Lesser General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Lesser General Public
14  *  License along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
16  *  USA.
17  */
18 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include "libgadu.h"
23 
main(int argc,char ** argv)24 int main(int argc, char **argv)
25 {
26 	char buf[100];
27 	int i;
28 
29 	if (argc > 2 && !strcmp(argv[1], "-b")) {
30 		int count = argc - 3;
31 		uint32_t val = atoi(argv[2]);
32 
33 		for (i = 0; i < (1 << count); i++) {
34 			char *args[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
35 			uint32_t res;
36 			int c = 0, j;
37 
38 			if (i & 1)
39 				args[c++] = argv[3];
40 			if (i & 2)
41 				args[c++] = argv[4];
42 			if (i & 4)
43 				args[c++] = argv[5];
44 			if (i & 8)
45 				args[c++] = argv[6];
46 			if (i & 16)
47 				args[c++] = argv[7];
48 			if (i & 32)
49 				args[c++] = argv[8];
50 			if (i & 64)
51 				args[c++] = argv[9];
52 			if (i & 128)
53 				args[c++] = argv[10];
54 
55 			strcpy(buf, "");
56 
57 			for (j = 0; j < c; j++)
58 				strcat(buf, "s");
59 
60 			res = gg_http_hash(buf, args[0], args[1], args[2], args[3], args[4], args[5], args[6], NULL);
61 
62 			printf("%s %s %s %s %s %s %s %s", buf, args[0], args[1],
63 				args[2], args[3], args[4], args[5], args[6]);
64 
65 			if (res == val)
66 				printf(" MATCH!\n");
67 			else
68 				printf("\n");
69 		}
70 
71 		return 0;
72 	}
73 
74 	if (argc < 2 || argc > 10) {
75 		fprintf(stderr, "użycie: %s <kolejne> [wyrazy] [do] [hasha]\n", argv[0]);
76 		return 1;
77 	}
78 
79 	strcpy(buf, "");
80 
81 	for (i = 1; i < argc; i++)
82 		strcat(buf, "s");
83 
84 	printf("%s\n", buf);
85 
86 	printf("%u\n", gg_http_hash(buf, argv[1], argv[2], argv[3], argv[4],
87 		argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]));
88 
89 	return 0;
90 }
91