Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6057 → Rev 6058

/programs/cmm/lib/debug.h
0,0 → 1,68
#ifndef INCLUDE_DEBUG_H
#define INCLUDE_DEBUG_H
#print "[include <debug.h>]\n"
 
#ifndef INCLUDE_STRING_H
#include "../lib/strings.h"
#endif
 
inline fastcall void debugch( ECX)
{
$push eax
$push ebx
$mov eax,63
$mov ebx,1
$int 0x40
$pop ebx
$pop eax
}
 
inline fastcall void debug( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$pop ecx
$pop ebx
$pop eax
}
 
inline fastcall void debugln( EDX)
{
debug( EDX);
debugch('\n');
}
 
inline void debugi(dword d_int)
{
char tmpch[12];
itoa_(#tmpch, d_int);
debugln(#tmpch);
}
 
:void assert(dword _type, _actual, _expected)
{
char r[4096];
if (_type=='s') {
if (streq(_actual, _expected)) return;
sprintf(#r, "==========nok{\nactual: %s\nexpected: %s", _actual, _expected);
debugln(#r);
}
if (_type=='i') {
if (_actual == _expected)) return;
sprintf(#r, "==========nok{\nactual: %i\nexpected: %i", _actual, _expected);
debugln(#r);
}
}
 
#endif
/programs/cmm/lib/kolibri.h
437,61 → 437,6
$int 0x40
}
 
inline fastcall void debugln( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$mov cl, 13
$int 0x40
$mov cl, 10
$int 0x40
$pop ecx
$pop ebx
$pop eax
}
 
inline fastcall void debug( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$pop ecx
$pop ebx
$pop eax
}
 
 
inline fastcall void debugch( ECX)
{
$push eax
$push ebx
$mov eax,63
$mov ebx,1
$int 0x40
$pop ebx
$pop eax
}
//------------------------------------------------------------------------------
 
void DefineAndDrawWindow(dword x, y, size_w, size_h, byte WindowType,dword WindowAreaColor, EDI, ESI)
812,3 → 757,7
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif
 
#ifndef INCLUDE_DEBUG_H
#include "../lib/debug.h"
#endif
/programs/cmm/lib/obj/iconv.h
7,10 → 7,6
#include "../lib/kolibri.h"
#endif
 
#ifndef INCLUDE_DLL_H
#include "../lib/dll.h"
#endif
 
dword iconv_lib = #a_iconv_lib;
char a_iconv_lib[19]="/sys/lib/iconv.obj\0";
 
/programs/cmm/lib/patterns/http_downloader.h
0,0 → 1,163
 
enum {
STATE_NOT_STARTED,
STATE_IN_PROGRESS,
STATE_COMPLETED
};
 
struct DOWNLOADER {
unsigned data_downloaded_size, data_full_size;
dword bufpointer, bufsize, url;
byte state;
dword http_transfer;
int http_status_code;
dword Start();
void Stop();
void Completed();
int MonitorProgress();
} downloader;
 
dword DOWNLOADER::Start(dword _url)
{
url = _url;
state = STATE_IN_PROGRESS;
http_get stdcall (url, 0, 0, #accept_language);
http_transfer = EAX;
return http_transfer;
}
 
void DOWNLOADER::Stop()
{
state = STATE_NOT_STARTED;
if (http_transfer!=0)
{
EAX = http_transfer;
EAX = EAX.http_msg.content_ptr; // get pointer to data
$push EAX // save it on the stack
http_free stdcall (http_transfer); // abort connection
$pop EAX
mem_Free(EAX); // free data
http_transfer=0;
bufsize = 0;
bufpointer = mem_Free(bufpointer);
}
data_downloaded_size = data_full_size = 0;
}
 
void DOWNLOADER::Completed()
{
state = STATE_COMPLETED;
ESI = http_transfer;
bufpointer = ESI.http_msg.content_ptr;
bufsize = ESI.http_msg.content_received;
http_free stdcall (http_transfer);
http_transfer=0;
}
 
int DOWNLOADER::MonitorProgress()
{
dword receive_result;
char redirect_url[4096*3], finaladress[4096*3];
if (http_transfer <= 0) return false;
http_receive stdcall (http_transfer);
receive_result = EAX;
EDI = http_transfer;
http_status_code = EDI.http_msg.status;
data_full_size = EDI.http_msg.content_length;
data_downloaded_size = EDI.http_msg.content_received;
if (!data_full_size) data_full_size = data_downloaded_size * 6 + 1;
 
if (receive_result == 0) {
if (http_status_code >= 300) && (http_status_code < 400)
{
http_find_header_field stdcall (http_transfer, "location\0");
if (EAX!=0) {
ESI = EAX;
EDI = #redirect_url;
do {
$lodsb;
$stosb;
} while (AL != 0) && (AL != 13) && (AL != 10));
DSBYTE[EDI-1]='\0';
}
get_absolute_url(#finaladress, url, #redirect_url);
Stop();
Start(#finaladress);
url = #finaladress;
return false;
}
Completed();
}
return true;
}
 
 
/*=====================================
== ==
== CHECK URL TYPE ==
== ==
=====================================*/
 
 
int check_is_the_adress_local(dword _in)
{
if (ESBYTE[_in]!='/') return false;
_in++;
if(!strncmp(_in,"rd/",3)) return true;
if(!strncmp(_in,"fd/",3)) return true;
if(!strncmp(_in,"hd/",3)) return true;
if(!strncmp(_in,"bd/",3)) return true;
if(!strncmp(_in,"cd/",3)) return true;
if(!strncmp(_in,"sys/",4)) return true;
if(!strncmp(_in,"tmp/",4)) return true;
if(!strncmp(_in,"usbhd",6)) return true;
if(!strncmp(_in,"kolibrios",10)) return true;
return false;
}
 
int check_is_the_url_absolute(dword _in)
{
if(!strncmp(_in,"ftp:",4)) return true;
if(!strncmp(_in,"http:",5)) return true;
if(!strncmp(_in,"https:",6)) return true;
if(!strncmp(_in,"mailto:",7)) return true;
if(check_is_the_adress_local(_in)) return true;
return false;
}
 
void get_absolute_url(dword _rez, _base, _new)
{
int i;
debug("_base:");debugln(_base);
debug("_new:");debugln(_new);
//case: ./valera.html
if (!strncmp(_new,"./", 2)) _new+=2;
//case: http://site.name
if (check_is_the_url_absolute(_new)) {
strcpy(_rez, _new);
goto _GET_ABSOLUTE_URL_END;
}
//case: /valera.html
if (ESBYTE[_new] == '/') //remove everything after site domain name
{
strcpy(_rez, _base);
i = strchr(_rez+8,'/');
if (i<1) i=strlen(_rez)+_rez;
strcpy(i, _new);
goto _GET_ABSOLUTE_URL_END;
}
//case: ../../valera.html
strcpy(_rez, _base);
ESBYTE[ strrchr(_rez,'/') + _rez -1 ] = '\0'; //remove name
while (!strncmp(_new,"../",3))
{
_new += 3;
ESBYTE[ strrchr(_rez,'/') + _rez -1 ] = '\0';
}
//case: valera.html
chrcat(_rez, '/');
strcat(_rez, _new);
_GET_ABSOLUTE_URL_END:
while (i=strstr(_rez, "&amp;")) strcpy(i+1, i+5);
debug("_rez:");debugln(_rez);
}
/programs/cmm/lib/strings.h
181,6 → 181,10
return 0;
}
 
inline signed int streq(dword text1, text2) {
if (!strcmp(text1,text2)) return true; else return false;
}
 
/*
signed int strncmp(dword s1, s2, signed n)
unsigned char _s1,_s2;
385,18 → 389,6
ESBYTE[ESI+EDI+1] = 0;
}
 
 
inline fastcall signed int old_strchr( ESI,BL)
{
int jj=0;
do{
jj++;
$lodsb
IF(AL==BL) return jj;
} while(AL!=0);
return 0;
}
 
inline dword strchr(dword shb;char s)
{
char ss;
897,14 → 889,6
return 0;
}
 
inline void debugi(dword d_int)
{
char tmpch[12];
itoa_(#tmpch, d_int);
debugln(#tmpch);
}
 
 
#define strnmov strmovn
#define stricmp strcmpi
#define strcmpn strncmp