Rev 4983 | Rev 5537 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4983 | Rev 4996 | ||
---|---|---|---|
Line 119... | Line 119... | ||
119 | xor eax, eax |
119 | xor eax, eax |
120 | inc eax |
120 | inc eax |
121 | ret |
121 | ret |
Line -... | Line 122... | ||
- | 122 | ||
- | 123 | ||
- | 124 | ;;================================================================================================;; |
|
- | 125 | proc HTTP_disconnect identifier ;/////////////////////////////////////////////////////////////////;; |
|
- | 126 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 127 | ;? Stops the open connection ;; |
|
- | 128 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 129 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
|
- | 130 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 131 | ;< none ;; |
|
- | 132 | ;;================================================================================================;; |
|
- | 133 | ||
- | 134 | pusha |
|
- | 135 | mov ebp, [identifier] |
|
- | 136 | ||
- | 137 | test [ebp + http_msg.flags], FLAG_CONNECTED |
|
- | 138 | jz .error |
|
- | 139 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
|
- | 140 | mcall close, [ebp + http_msg.socket] |
|
- | 141 | ||
- | 142 | popa |
|
- | 143 | ret |
|
- | 144 | ||
- | 145 | .error: |
|
- | 146 | DEBUGF 1, "Cant close already closed connection!\n" |
|
- | 147 | popa |
|
- | 148 | ret |
|
Line 122... | Line 149... | ||
122 | 149 | ||
- | 150 | endp |
|
- | 151 | ||
- | 152 | ||
- | 153 | ;;================================================================================================;; |
|
- | 154 | proc HTTP_free identifier ;///////////////////////////////////////////////////////////////////////;; |
|
- | 155 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 156 | ;? Free the http_msg structure ;; |
|
- | 157 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 158 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
|
- | 159 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 160 | ;< none ;; |
|
- | 161 | ;;================================================================================================;; |
|
- | 162 | DEBUGF 1, "HTTP_free: 0x%x\n", [identifier] |
|
- | 163 | pusha |
|
- | 164 | mov ebp, [identifier] |
|
- | 165 | ||
- | 166 | test [ebp + http_msg.flags], FLAG_CONNECTED |
|
- | 167 | jz .not_connected |
|
- | 168 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
|
- | 169 | mcall close, [ebp + http_msg.socket] |
|
- | 170 | ||
- | 171 | .not_connected: |
|
- | 172 | invoke mem.free, ebp |
|
- | 173 | ||
- | 174 | popa |
|
- | 175 | ret |
|
123 | 176 | ||
124 | 177 | endp |
|
125 | 178 | ||
126 | ;;================================================================================================;; |
179 | ;;================================================================================================;; |
127 | proc HTTP_get URL, add_header ;///////////////////////////////////////////////////////////////////;; |
180 | proc HTTP_get URL, add_header ;///////////////////////////////////////////////////////////////////;; |
Line 483... | Line 536... | ||
483 | endp |
536 | endp |
Line 484... | Line 537... | ||
484 | 537 | ||
485 | 538 | ||
486 | 539 | ||
487 | ;;================================================================================================;; |
540 | ;;================================================================================================;; |
488 | proc HTTP_process identifier ;////////////////////////////////////////////////////////////////////;; |
541 | proc HTTP_receive identifier ;////////////////////////////////////////////////////////////////////;; |
489 | ;;------------------------------------------------------------------------------------------------;; |
542 | ;;------------------------------------------------------------------------------------------------;; |
490 | ;? Receive data from the server, parse headers and put data in receive buffer. ;; |
543 | ;? Receive data from the server, parse headers and put data in receive buffer(s). ;; |
491 | ;? To complete a transfer, this procedure must be called over and over again untill it returns 0. ;; |
544 | ;? To complete a transfer, this procedure must be called over and over again untill it returns 0. ;; |
492 | ;;------------------------------------------------------------------------------------------------;; |
545 | ;;------------------------------------------------------------------------------------------------;; |
Line 989... | Line 1042... | ||
989 | .done: |
1042 | .done: |
990 | ret |
1043 | ret |
Line 991... | Line -... | ||
991 | - | ||
992 | 1044 | ||
993 | 1045 | ||
994 | 1046 | ||
995 | ;;================================================================================================;; |
1047 | ;;================================================================================================;; |
996 | proc HTTP_free identifier ;///////////////////////////////////////////////////////////////////////;; |
1048 | proc HTTP_send identifier, dataptr, datalength ;//////////////////////////////////////////////////;; |
997 | ;;------------------------------------------------------------------------------------------------;; |
1049 | ;;------------------------------------------------------------------------------------------------;; |
- | 1050 | ;? Send data to the server ;; |
|
- | 1051 | ;;------------------------------------------------------------------------------------------------;; |
|
998 | ;? Free the http_msg structure ;; |
1052 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
999 | ;;------------------------------------------------------------------------------------------------;; |
1053 | ;> dataptr = pointer to data to be sent. ;; |
1000 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
1054 | ;> datalength = length of data (in bytes) to be sent ;; |
1001 | ;;------------------------------------------------------------------------------------------------;; |
- | |
1002 | ;< none ;; |
- | |
1003 | ;;================================================================================================;; |
- | |
1004 | DEBUGF 1, "HTTP_free: 0x%x\n", [identifier] |
- | |
1005 | pusha |
- | |
1006 | mov ebp, [identifier] |
- | |
Line 1007... | Line 1055... | ||
1007 | 1055 | ;;------------------------------------------------------------------------------------------------;; |
|
- | 1056 | ;< eax = number of bytes sent, -1 on error ;; |
|
1008 | test [ebp + http_msg.flags], FLAG_CONNECTED |
1057 | ;;================================================================================================;; |
1009 | jz .not_connected |
- | |
1010 | 1058 | ||
1011 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
1059 | push ebx ecx edx esi edi |
1012 | mcall close, [ebp + http_msg.socket] |
- | |
1013 | 1060 | mov edx, [identifier] |
|
1014 | .not_connected: |
1061 | test [edx + http_msg.flags], FLAG_CONNECTED |
Line 1015... | Line -... | ||
1015 | invoke mem.free, ebp |
- | |
1016 | - | ||
1017 | popa |
- | |
1018 | ret |
- | |
1019 | - | ||
1020 | endp |
- | |
1021 | - | ||
1022 | - | ||
1023 | - | ||
1024 | ;;================================================================================================;; |
- | |
1025 | proc HTTP_stop identifier ;///////////////////////////////////////////////////////////////////////;; |
- | |
1026 | ;;------------------------------------------------------------------------------------------------;; |
- | |
1027 | ;? Stops the open connection ;; |
- | |
1028 | ;;------------------------------------------------------------------------------------------------;; |
- | |
1029 | ;> identifier = pointer to buffer containing http_msg struct. ;; |
1062 | jz .fail |
1030 | ;;------------------------------------------------------------------------------------------------;; |
1063 | mcall send, [edx + http_msg.socket], [dataptr], [datalength], 0 |
1031 | ;< none ;; |
- | |
1032 | ;;================================================================================================;; |
- | |
1033 | 1064 | pop edi esi edx ecx ebx |
|
1034 | pusha |
- | |
1035 | mov ebp, [identifier] |
1065 | ret |
1036 | 1066 | ||
Line 1037... | Line 1067... | ||
1037 | and [ebp + http_msg.flags], not FLAG_CONNECTED |
1067 | .fail: |
Line 1038... | Line -... | ||
1038 | mcall close, [ebp + http_msg.socket] |
- | |
1039 | 1068 | pop edi esi edx ecx ebx |
|
1040 | popa |
1069 | xor eax, eax |
1041 | ret |
1070 | dec eax |
1042 | 1071 | ret |
|
- | 1072 | ||
- | 1073 | endp |
|
- | 1074 | ||
- | 1075 | ||
1043 | endp |
1076 | ;;================================================================================================;; |
1044 | 1077 | proc HTTP_find_header_field identifier, headername ;//////////////////////////////////////////////;; |
|
1045 | 1078 | ;;------------------------------------------------------------------------------------------------;; |
|
1046 | 1079 | ;? Find a header field in the received HTTP header ;; |
|
1047 | ;;================================================================================================;; |
1080 | ;? ;; |
1048 | proc HTTP_find_header_field identifier, headername ;//////////////////////////////////////////////;; |
1081 | ;? NOTE: this function returns a pointer which points into the original header data. ;; |
1049 | ;;------------------------------------------------------------------------------------------------;; |
1082 | ;? The header field is terminated by a CR, LF, space or maybe even tab. ;; |
Line 1688... | Line 1721... | ||
1688 | ;;===========================================================================;; |
1721 | ;;===========================================================================;; |
1689 | ;;///////////////////////////////////////////////////////////////////////////;; |
1722 | ;;///////////////////////////////////////////////////////////////////////////;; |
1690 | ;;===========================================================================;; |
1723 | ;;===========================================================================;; |
Line -... | Line 1724... | ||
- | 1724 | ||
- | 1725 | ||
- | 1726 | HTTP_stop = HTTP_disconnect |
|
1691 | 1727 | HTTP_process = HTTP_receive |
|
1692 | 1728 | ||
1693 | align 4 |
1729 | align 4 |
1694 | @EXPORT: |
1730 | @EXPORT: |
1695 | export \ |
1731 | export \ |
1696 | lib_init , 'lib_init' , \ |
1732 | lib_init , 'lib_init' , \ |
1697 | 0x00010001 , 'version' , \ |
1733 | 0x00010001 , 'version' , \ |
1698 | HTTP_get , 'get' , \ |
1734 | HTTP_get , 'get' , \ |
1699 | HTTP_head , 'head' , \ |
1735 | HTTP_head , 'head' , \ |
- | 1736 | HTTP_post , 'post' , \ |
|
- | 1737 | HTTP_find_header_field , 'find_header_field' , \ |
|
1700 | HTTP_post , 'post' , \ |
1738 | HTTP_process , 'process' , \ ; To be removed |
- | 1739 | HTTP_send , 'send' , \ |
|
1701 | HTTP_find_header_field , 'find_header_field' , \ |
1740 | HTTP_receive , 'receive' , \ |
1702 | HTTP_process , 'process' , \ |
1741 | HTTP_disconnect , 'disconnect' , \ |
1703 | HTTP_free , 'free' , \ |
1742 | HTTP_free , 'free' , \ |
1704 | HTTP_stop , 'stop' , \ |
1743 | HTTP_stop , 'stop' , \ ; To be removed |
1705 | HTTP_escape , 'escape' , \ |
- | |
1706 | HTTP_unescape , 'unescape' |
1744 | HTTP_escape , 'escape' , \ |
1707 | 1745 | HTTP_unescape , 'unescape' |
|
1708 | ; HTTP_put , 'put' , \ |
1746 | ; HTTP_put , 'put' , \ |
1709 | ; HTTP_delete , 'delete' , \ |
1747 | ; HTTP_delete , 'delete' , \ |