Witam :-)
Interesuje mnie przerobienie ponizszej funkcji na kod php :>
Jest mi to niezbedne do kilku operacyjny z protokolem gadu-gadu .
Moglby ktos pomoc ?
Z gory dziekuje
int gg_http_hash(const char *format, ...)
{
unsigned int a, c, i, j;
va_list ap;
int b = -1;
va_start(ap, format);
for (j = 0; j < strlen(format); j++) {
char *arg, buf[16];
if (format[j] == 'u') {
snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t));
arg = buf;
} else {
if (!(arg = va_arg(ap, char*)))
arg = "";
}
i = 0;
while ((c = (unsigned char) arg[i++]) != 0) {
a = (c ^ b) + (c << 8);
b = (a >> 24) | (a << 8);
}
}
va_end(ap);
return (b < 0 ? -b : b);
}
Jesli to cos da to mam ta funkcje napisana w jezyku delphi
function TGGLite.HTTPHashCode (MultiParam: array of string):integer;
var b,i,j:integer;
var a,c:longword;
begin
result:=-1;
if length(multiparam)=0 then exit;
b:=-1;
for i:=low(multiparam) to high(multiparam) do
begin
for j:=1 to length(multiparam[i]) do
begin
c:=ord(multiparam[i][j]);
a:=(c xor b) + (c shl 8);
b:=(a shr 24) or (a shl 8);
end;
end;
if (b < 0) then result:=-b
else result:=b;
end;