Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4165 → Rev 4166

/programs/cmm/lib/socket.h
File deleted
/programs/cmm/lib/encoding.h
108,10 → 108,6
CASE 0xA9: // (c) --- âûëåò Î_î
{
ESBYTE[EDI] = 'c';
//ESBYTE[EDI] = '(';
//ESBYTE[EDI+1] = 'c';
//ESBYTE[EDI+2] = ')';
//EDI+=2;
ESI++;
BREAK;
}
118,10 → 114,6
CASE 0xAE: // (r)
{
ESBYTE[EDI] = 'r';
//ESBYTE[EDI] = '(';
//ESBYTE[EDI+1] = 'r';
//ESBYTE[EDI+2] = ')';
//EDI+=2;
ESI++;
BREAK;
}
162,7 → 154,7
FOR (;j<2;j++)
{
ch=ESBYTE[htmlcolor+j];
IF (ch==0x0d) || (ch=='\9') RETURN '';
IF (ch==0x0d) || (ch=='\9') RETURN 0;
IF ((ch>='0') && (ch<='9')) ch -= '0';
IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
172,6 → 164,7
AL=symbol;
}
 
 
:dword ConvertMemSize(unsigned int bytes)
{
unsigned char size_prefix[8], size_nm[4];
180,7 → 173,7
else if (bytes>=1024) strcpy(#size_nm, " Kb");
else strcpy(#size_nm, " b ");
while (bytes>1023) bytes/=1024;
strcpy(#size_prefix, itoa(bytes));
itoa_(#size_prefix, bytes);
strcat(#size_prefix, #size_nm);
return #size_prefix;
}
/programs/cmm/lib/kolibri.h
220,8 → 220,8
 
:int CheckActiveProcess(int Form_ID)
{
int id=GetProcessSlot(Form_ID);
if (id==GetActiveProcess()) return 1;
int id9=GetProcessSlot(Form_ID);
if (id9==GetActiveProcess()) return 1;
return 0;
}
 
/programs/cmm/lib/strings.h
265,42 → 265,7
*to = '\0';
}*/
 
dword itoa( ESI)
{
unsigned char buffer[11];
$pusha
 
EDI = #buffer;
ECX = 10;
if (ESI < 0)
{
$mov al, '-'
$stosb
$neg esi
}
 
$mov eax, esi
$push -'0'
F2:
$xor edx, edx
$div ecx
$push edx
$test eax, eax
$jnz F2
F3:
$pop eax
$add al, '0'
$stosb
$jnz F3
$mov al, '\0'
$stosb
 
$popa
return #buffer;
}
 
 
inline fastcall dword atoi( EDI)
{
$push ebx
362,10 → 327,77
}while(AL!=0);
}
 
unsigned char buffer[11];
dword itoa( ESI)
{
$pusha
EDI = #buffer;
ECX = 10;
if (ESI < 0)
{
$mov al, '-'
$stosb
$neg esi
}
 
$mov eax, esi
$push -'0'
F2:
$xor edx, edx
$div ecx
$push edx
$test eax, eax
$jnz F2
F3:
$pop eax
$add al, '0'
$stosb
$jnz F3
$mov al, '\0'
$stosb
 
$popa
return #buffer;
}
 
inline fastcall itoa_(signed int EDI, ESI)
{
$pusha
EBX = EDI;
ECX = 10;
if (ESI > 90073741824)
{
$mov al, '-'
$stosb
$neg esi
}
 
$mov eax, esi
$push -'0'
F2:
$xor edx, edx
$div ecx
$push edx
$test eax, eax
$jnz F2
F3:
$pop eax
$add al, '0'
$stosb
$jnz F3
$mov al, '\0'
$stosb
 
$popa
return EBX;
}
 
void debugi(dword d_int)
{
char tmpch[11];
strcpy(#tmpch, itoa(d_int));
char tmpch[12];
itoa_(#tmpch, d_int);
debug(#tmpch);
}
 
/programs/cmm/liza/letter_attr.c
21,6 → 21,8
letter_attr atr;
dword mails_db;
 
 
 
void letter_attr::CreateArray()
{
free(mails_db);
/programs/cmm/liza/liza.c
45,9 → 45,9
#define WIN_H 440
#define WIN_MIN_W 500
#define WIN_MIN_H 380
#define LOGIN_HEADER "Login - Email client Liza 0.9b"
#define OPTIONS_HEADER "Options - Email client Liza 0.9b"
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9b"
#define LOGIN_HEADER "Login - Email client Liza 0.9e"
#define OPTIONS_HEADER "Options - Email client Liza 0.9e"
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9e"
#define BUFFERSIZE 512
proc_info Form;
system_colors sc;
145,6 → 145,23
ExitProcess();
}
 
int GetRequest(dword command, text)
{
strcpy(#request, command);
if (text)
{
chrcat(#request, ' ');
strcat(#request, text);
}
strcat(#request, "\n");
return strlen(#request);
}
 
void StopConnect(dword message)
{
if (message) notify(message);
aim = STOP;
}
 
stop:
 
/programs/cmm/liza/login.c
12,13 → 12,9
edit_box login_box= {PANEL_W-6,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(email_text)+2,#email_text,#mouse_dd,0b10};
edit_box pass_box= {PANEL_W-6,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(pass_text)+2,#pass_text,#mouse_dd,0b1};
 
void StopConnect(dword message)
{
if (message) notify(message);
aim = STOP;
}
 
 
 
void LoginBoxLoop()
{
int key, id;
227,18 → 223,6
}
 
 
int GetRequest(dword command, text)
{
strcpy(#request, command);
if (text)
{
chrcat(#request, ' ');
strcat(#request, text);
}
strcat(#request, "\n");
return strlen(#request);
}
 
void GetServerPathAndLogin()
{
int i=strchr(#email_text,'@');
/programs/cmm/liza/mail_box.c
11,8 → 11,9
char *listbuffer;
char *listpointer;
 
char *mailbuffer;
char *mailpointer;
char *mailstart;
char *mailend;
int mailsize;
 
 
enum {
32,8 → 33,6
int key, id;
mouse m;
int panels_drag = 0;
char socket_char;
int letter_size;
dword line_col, text_col;
 
mail_list.h = Form.cheight/4;
98,8 → 97,8
if (id==GET_MAIL) aim = SEND_NSTAT;
if (id==SAVE_LETTER)
{
if (!mailbuffer) break;
WriteFile(strlen(mailbuffer), mailbuffer, "mail.txt");
if (!mailstart) break;
WriteFile(strlen(mailstart), mailstart, "mail.txt");
pause(10);
RunProgram("tinypad", "mail.txt");
}
180,8 → 179,6
if (strstr(#immbuffer,"+OK"))
{
mail_list.count = GetMailCount();
debug("Letters:");
debug(itoa(mail_list.count));
free(listbuffer);
listbuffer = mem_Alloc(30*mail_list.count); //24* original
listpointer = listbuffer;
235,44 → 232,45
StopConnect("Error while trying to get letter from server");
break;
}
letter_size = atr.GetSize(mail_list.current+1) + 1024;
free(mailbuffer);
if (!mailbuffer = malloc(letter_size))
mailsize = atr.GetSize(mail_list.current+1) + 1024;
free(mailstart);
if (!mailstart = malloc(mailsize))
{
debug("alloc error!");
aim=NULL;
break;
}
mailpointer = mailbuffer;
mailend = mailstart;
aim = GET_ANSWER_RETR;
}
if (aim == GET_ANSWER_RETR)
{
aim=NULL;
break;
ticks = Receive(socketnum, mailpointer, letter_size + mailbuffer - mailpointer , MSG_DONTWAIT);
ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT);
if (ticks == 0xffffffff) break;
mailpointer = mailpointer + ticks;
mailend = mailend + ticks;
 
if (!aim) break;
 
if (letter_size + mailbuffer - mailpointer - 2 < 0)
if (mailsize + mailstart - mailend - 2 < 0)
{
debug("Resizing buffer");
letter_size += 4096;
mailbuffer = realloc(mailbuffer, letter_size);
if (!mailbuffer) { StopConnect("Realloc error!"); break;}
mailsize += 4096;
mailstart = realloc(mailstart, mailsize);
if (!mailstart) { StopConnect("Realloc error!"); break;}
}
 
if (letter_size>9000)
if (mailsize>9000)
{
id = mailpointer - mailbuffer * 100 ;
id /= letter_size - 1024;
id = mailend - mailstart * 100 ;
id /= mailsize - 1024;
if (id!=cur_st_percent) SetMailBoxStatus( id , NULL);
}
 
//debug(mailstart);
//pause(10);
//debug("======================");
ParseMail();
}
 
368,7 → 366,7
letter_view.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll2.size_x - 1,
Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 60, 12);
 
if (mailbuffer) && (!aim)
if (mailstart) && (!aim)
{
for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line);
 
377,7 → 375,7
next_line = GetNextLine(cur_line);
line_text = CopyBetweenOffsets(cur_line, next_line);
cur_line = next_line;
if (cur_line >= mailpointer) || (cur_line==1) break;
if (cur_line >= mailend) || (cur_line==1) break;
DrawBar(letter_view.x, i*letter_view.line_h + letter_view.y, letter_view.w, letter_view.line_h, 0xFFFfff);
if (line_text) { WriteText(letter_view.x+5, i*letter_view.line_h+letter_view.y+3, 0x80, 0, line_text); free(line_text);}
}
430,8 → 428,7
 
void SetMailBoxStatus(dword percent1, text1)
{
DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, sc.work, 0xC3C3C3, 0x54B1D6, sc.work_text, percent1, text1);
cur_st_percent = percent1;
if (text1) WriteText(3, Form.cheight -status_bar_h + 3, 0x80, sc.work_text, text1);
cur_st_text = text1;
}
 
439,7 → 436,7
void StopLoading()
{
aim = NULL;
mailbuffer = free(mailbuffer);
mailstart = free(mailstart);
to = from = date = subj = cur_charset = NULL;
}
 
449,16 → 446,15
return atoi(#tmpbuf4);
}
 
 
 
int GetLetterSize_(int number){
int GetLetterSize_(int number)
{
char search_num[24];
char letter_size1[24];
char mailsize1[24];
strcpy(#search_num, "\n"); // 0x0d, 0x0a
strcat(#search_num, itoa(number));
strcat(#search_num, " ");
strcpyb(listbuffer, #letter_size1, #search_num, "\x0d");
return atoi(#letter_size1);
itoa_(#search_num+1, number);
chrcat(#search_num, ' ');
strcpyb(listbuffer, #mailsize1, #search_num, "\x0d");
return atoi(#mailsize1);
}
 
 
/programs/cmm/liza/parselist.c
5,44 → 5,39
dword line_off, new_buf;
char tline[256];
 
if ( mailpointer-mailbuffer>9 ) if (strncmp(mailpointer-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
if ( mailend-mailstart > 9) if (strncmp(mailend-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
{
debug("End of mail detected");
mailpointer = mailpointer - 5;
if (strstr(mailbuffer, "+OK")!=mailbuffer)
mailend -= 5;
if (strstr(mailstart, "+OK")!=mailstart)
{
aim = GET_ANSWER_RETR;
mailpointer = mailbuffer;
mailend = mailstart;
debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR");
return;
}
aim=NULL;
DSBYTE[mailpointer] = '\0';
debug("Real letter size:");
debugi(mailpointer - mailbuffer);
DSBYTE[mailend] = '\0';
mailsize = mailend - mailstart;
 
if (strstri(mailbuffer, "quoted-printable")!=0)
if (strstri(mailstart, "quoted-printable")!=0)
{
debug ("getting qp");
new_buf = malloc(mailpointer-mailbuffer);
qp_decode stdcall (mailbuffer, new_buf, mailpointer-mailbuffer);
new_buf = malloc(mailend-mailstart);
qp_decode stdcall (mailstart, new_buf, mailend-mailstart);
if (EAX==-1) debug("Too small buffer to convert QUOTED-PRINTABLE");
else
{
free(mailbuffer);
mailbuffer = new_buf;
mailpointer = strlen(mailbuffer) + mailbuffer;
free(mailstart);
mailstart = new_buf;
mailsize = strlen(mailstart);
mailend = mailsize + mailstart;
}
}
debug ("getting list info");
GetHeader(#from, "\nFrom:");
GetHeader(#to, "\nTo:");
GetHeader(#date, "\nDate:");
GetHeader(#subj, "\nSubject:");
mdata = strstr(mailbuffer, "\n\r") + 3; // 0x0d 0x0a, 0x0a
debug ("converting to dos");
ConvertToDOS(mdata, mailbuffer);
mdata = strstr(mailstart, "\n\r") + 3; // 0x0d 0x0a, 0x0a
ConvertToDOS(mdata, mailstart);
FromHTMLtoTXT();
letter_view.first = letter_view.count = 0;
87,13 → 82,13
{
dword cur_chr, txt_buf_srt, txt_buf_end, is_tag=0;
int i;
if (strstri(mdata, "<html>")==0) && (strstri(mailbuffer, "text/html")==0) {debug("no html tags found"); return;}
if (strstri(mdata, "<html>")==0) && (strstri(mailstart, "text/html")==0) {debug("no html tags found"); return;}
debug ("converting: html -> txt");
cur_chr = mdata;
txt_buf_srt = malloc(mailpointer - mailbuffer);
txt_buf_srt = malloc(mailend - mailstart);
txt_buf_end = txt_buf_srt;
 
while (cur_chr < mailpointer)
while (cur_chr < mailend)
{
if (DSBYTE[cur_chr]=='<') is_tag = 1;
if (!is_tag)
107,7 → 102,7
}
DSBYTE[txt_buf_end] = '\0';
strcpy(mdata, txt_buf_srt);
mailpointer = strlen(mailbuffer) + mailbuffer; //тупо везде это ставить
mailend = strlen(mailstart) + mailstart;
free(txt_buf_srt);
}
 
147,7 → 142,7
char tmpbuf[512];
dword Qoff;
 
strcpyb(mailbuffer, workstr, searchstr, "\n");
strcpyb(mailstart, workstr, searchstr, "\n");
if (strstri(workstr, "?Q?"))
{
qp_decode stdcall (workstr, #tmpbuf, strlen(workstr));