- Timestamp:
- Oct 26, 1999, 1:17:20 AM (26 years ago)
- Location:
- trunk/src/wsock32
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/async.cpp
r1450 r1451 1 /* $Id: async.cpp,v 1. 7 1999-10-25 22:48:27phaller Exp $ */1 /* $Id: async.cpp,v 1.8 1999-10-25 23:17:18 phaller Exp $ */ 2 2 3 3 /* … … 605 605 { 606 606 struct hostent* pHostent; 607 USHORT usLength ;607 USHORT usLength = sizeof(struct Whostent); 608 608 USHORT rc; 609 struct Whostent* pwhostent = (struct Whostent*)pRequest->pBuffer; 609 610 610 611 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetHostByAddr (%08xh, %08xh)\n", … … 613 614 614 615 // result buffer length 615 usLength = min(pRequest->ulBufferLength, sizeof(struct hostent)); 616 617 // call API 618 pHostent = gethostbyaddr((char*)pRequest->ul1, 619 (int) pRequest->ul2, 620 (int) pRequest->ul3); 621 if (pHostent == NULL) // error ? 622 { 623 rc = sock_errno(); // assuming OS/2 return codes are 616 if (pRequest->ulBufferLength < sizeof(struct Whostent)) 617 { 618 rc = WSAEINVAL; 624 619 WSASetLastError(rc); // same as Winsock return codes 625 620 } 626 621 else 627 622 { 628 // build result buffer 629 memcpy (pRequest->pBuffer, 630 pHostent, 631 usLength); 632 rc = 0; 623 // call API 624 pHostent = gethostbyaddr((char*)pRequest->ul1, 625 (int) pRequest->ul2, 626 (int) pRequest->ul3); 627 if (pHostent == NULL) // error ? 628 { 629 rc = sock_errno(); // assuming OS/2 return codes are 630 WSASetLastError(rc); // same as Winsock return codes 631 } 632 else 633 { 634 // translate result to Wsock32-style structure 635 pwhostent->h_name = pHostent->h_name; 636 pwhostent->h_aliases = pHostent->h_aliases; 637 pwhostent->h_addrtype = pHostent->h_addrtype; 638 pwhostent->h_length = pHostent->h_length; 639 pwhostent->h_addr_list = pHostent->h_addr_list; 640 rc = 0; 641 } 633 642 } 634 643 … … 657 666 void WSAAsyncWorker::asyncGetHostByName (PASYNCREQUEST pRequest) 658 667 { 659 struct hostent* pHostent; 660 USHORT usLength; 661 USHORT rc; 668 struct hostent* pHostent; 669 USHORT usLength = sizeof(struct Whostent); 670 USHORT rc; 671 struct Whostent* pwhostent = (struct Whostent*)pRequest->pBuffer; 662 672 663 673 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetHostByName (%08xh, %08xh)\n", … … 666 676 667 677 // result buffer length 668 usLength = min(pRequest->ulBufferLength, sizeof(struct hostent)); 669 670 // call API 671 pHostent = gethostbyname((char*)pRequest->ul1); 672 if (pHostent == NULL) // error ? 673 { 674 rc = sock_errno(); // assuming OS/2 return codes are 678 if (pRequest->ulBufferLength < sizeof(struct Whostent)) 679 { 680 rc = WSAEINVAL; 675 681 WSASetLastError(rc); // same as Winsock return codes 676 682 } 677 683 else 678 684 { 679 // build result buffer 680 memcpy (pRequest->pBuffer, 681 pHostent, 682 usLength); 683 rc = 0; 685 // call API 686 pHostent = gethostbyname((char*)pRequest->ul1); 687 if (pHostent == NULL) // error ? 688 { 689 rc = sock_errno(); // assuming OS/2 return codes are 690 WSASetLastError(rc); // same as Winsock return codes 691 692 dprintf ((" pHostent==NULL -> rc=%d\n", rc)); 693 } 694 else 695 { 696 // translate result to Wsock32-style structure 697 pwhostent->h_name = pHostent->h_name; 698 pwhostent->h_aliases = pHostent->h_aliases; 699 pwhostent->h_addrtype = pHostent->h_addrtype; 700 pwhostent->h_length = pHostent->h_length; 701 pwhostent->h_addr_list = pHostent->h_addr_list; 702 rc = 0; 703 } 684 704 } 685 705 … … 709 729 { 710 730 struct protoent* pProtoent; 711 USHORT usLength ;731 USHORT usLength = sizeof(struct Wprotoent); 712 732 USHORT rc; 733 struct Wprotoent* pwprotoent= (struct Wprotoent*)pRequest->pBuffer; 713 734 714 735 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetProtoByName (%08xh, %08xh)\n", … … 717 738 718 739 // result buffer length 719 usLength = min(pRequest->ulBufferLength, sizeof(struct protoent)); 720 721 // call API 722 pProtoent = getprotobyname((char*)pRequest->ul1); 723 if (pProtoent == NULL) // error ? 724 { 725 rc = sock_errno(); // assuming OS/2 return codes are 740 if (pRequest->ulBufferLength < sizeof(struct Wprotoent)) 741 { 742 rc = WSAEINVAL; 726 743 WSASetLastError(rc); // same as Winsock return codes 727 744 } 728 745 else 729 746 { 730 // build result buffer 731 memcpy (pRequest->pBuffer, 732 pProtoent, 733 usLength); 734 rc = 0; 747 // call API 748 pProtoent = getprotobyname((char*)pRequest->ul1); 749 if (pProtoent == NULL) // error ? 750 { 751 rc = sock_errno(); // assuming OS/2 return codes are 752 WSASetLastError(rc); // same as Winsock return codes 753 } 754 else 755 { 756 // build result buffer 757 pwprotoent->p_name = pProtoent->p_name; 758 pwprotoent->p_aliases = pProtoent->p_aliases; 759 pwprotoent->p_proto = pProtoent->p_proto; 760 rc = 0; 761 } 735 762 } 736 763 … … 760 787 { 761 788 struct protoent* pProtoent; 762 USHORT usLength ;789 USHORT usLength = sizeof(struct Wprotoent); 763 790 USHORT rc; 791 struct Wprotoent* pwprotoent= (struct Wprotoent*)pRequest->pBuffer; 764 792 765 793 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetProtoByNumber (%08xh, %08xh)\n", … … 768 796 769 797 // result buffer length 770 usLength = min(pRequest->ulBufferLength, sizeof(struct protoent)); 771 772 // call API 773 pProtoent = getprotobyname(( char*)pRequest->ul1); 774 if (pProtoent == NULL) // error ? 775 { 776 rc = sock_errno(); // assuming OS/2 return codes are 798 if (pRequest->ulBufferLength < sizeof(struct Wprotoent)) 799 { 800 rc = WSAEINVAL; 777 801 WSASetLastError(rc); // same as Winsock return codes 778 802 } 779 803 else 780 804 { 781 // build result buffer 782 memcpy (pRequest->pBuffer, 783 pProtoent, 784 usLength); 785 rc = 0; 805 // call API 806 pProtoent = getprotobyname(( char*)pRequest->ul1); 807 if (pProtoent == NULL) // error ? 808 { 809 rc = sock_errno(); // assuming OS/2 return codes are 810 WSASetLastError(rc); // same as Winsock return codes 811 } 812 else 813 { 814 // build result buffer 815 pwprotoent->p_name = pProtoent->p_name; 816 pwprotoent->p_aliases = pProtoent->p_aliases; 817 pwprotoent->p_proto = pProtoent->p_proto; 818 rc = 0; 819 } 786 820 } 787 821 … … 811 845 { 812 846 struct servent* pServent; 813 USHORT usLength ;847 USHORT usLength = sizeof(struct Wservent); 814 848 USHORT rc; 849 struct Wservent* pwservent= (struct Wservent*)pRequest->pBuffer; 815 850 816 851 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetServByName (%08xh, %08xh)\n", … … 819 854 820 855 // result buffer length 821 usLength = min(pRequest->ulBufferLength, sizeof(struct servent)); 822 823 // call API 824 pServent = getservbyname((char*)pRequest->ul1, 825 (char*)pRequest->ul2); 826 if (pServent == NULL) // error ? 827 { 828 rc = sock_errno(); // assuming OS/2 return codes are 856 if (pRequest->ulBufferLength < sizeof(struct Wservent)) 857 { 858 rc = WSAEINVAL; 829 859 WSASetLastError(rc); // same as Winsock return codes 830 860 } 831 861 else 832 862 { 833 // build result buffer 834 memcpy (pRequest->pBuffer, 835 pServent, 836 usLength); 837 rc = 0; 863 // call API 864 pServent = getservbyname((char*)pRequest->ul1, 865 (char*)pRequest->ul2); 866 if (pServent == NULL) // error ? 867 { 868 rc = sock_errno(); // assuming OS/2 return codes are 869 WSASetLastError(rc); // same as Winsock return codes 870 } 871 else 872 { 873 // build result buffer 874 pwservent->s_name = pServent->s_name; 875 pwservent->s_aliases = pServent->s_aliases; 876 pwservent->s_port = pServent->s_port; 877 pwservent->s_proto = pServent->s_proto; 878 rc = 0; 879 } 838 880 } 839 881 … … 863 905 { 864 906 struct servent* pServent; 865 USHORT usLength ;907 USHORT usLength = sizeof(struct Wservent); 866 908 USHORT rc; 909 struct Wservent* pwservent= (struct Wservent*)pRequest->pBuffer; 867 910 868 911 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetServByPort (%08xh, %08xh)\n", … … 871 914 872 915 // result buffer length 873 usLength = min(pRequest->ulBufferLength, sizeof(struct servent)); 874 875 // call API 876 pServent = getservbyport((int )pRequest->ul1, 877 (char*)pRequest->ul2); 878 if (pServent == NULL) // error ? 879 { 880 rc = sock_errno(); // assuming OS/2 return codes are 916 if (pRequest->ulBufferLength < sizeof(struct Whostent)) 917 { 918 rc = WSAEINVAL; 881 919 WSASetLastError(rc); // same as Winsock return codes 882 920 } 883 921 else 884 922 { 885 // build result buffer 886 memcpy (pRequest->pBuffer, 887 pServent, 888 usLength); 889 rc = 0; 923 // call API 924 pServent = getservbyport((int )pRequest->ul1, 925 (char*)pRequest->ul2); 926 if (pServent == NULL) // error ? 927 { 928 rc = sock_errno(); // assuming OS/2 return codes are 929 WSASetLastError(rc); // same as Winsock return codes 930 } 931 else 932 { 933 // build result buffer 934 pwservent->s_name = pServent->s_name; 935 pwservent->s_aliases = pServent->s_aliases; 936 pwservent->s_port = pServent->s_port; 937 pwservent->s_proto = pServent->s_proto; 938 939 rc = 0; 940 } 890 941 } 891 942 -
trunk/src/wsock32/makefile
r1393 r1451 1 # $Id: makefile,v 1.1 1 1999-10-21 14:58:54phaller Exp $1 # $Id: makefile,v 1.12 1999-10-25 23:17:19 phaller Exp $ 2 2 3 3 # … … 21 21 TARGET = wsock32 22 22 23 OBJS = wsock32.obj notify.objinitterm.obj unknown.obj async.obj23 OBJS = wsock32.obj initterm.obj unknown.obj async.obj 24 24 25 25 all: $(TARGET).dll $(TARGET).lib … … 41 41 42 42 wsock32.obj: wsock32.cpp wsock32.h wsock32const.h 43 notify.obj: notify.cpp wsock32.h44 43 unknown.obj: unknown.cpp wsock32.h 45 44 async.obj: async.cpp wsock32const.h -
trunk/src/wsock32/wsock32.h
r1372 r1451 1 /* $Id: wsock32.h,v 1. 5 1999-10-20 10:03:54phaller Exp $ */1 /* $Id: wsock32.h,v 1.6 1999-10-25 23:17:19 phaller Exp $ */ 2 2 3 3 /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll. … … 73 73 */ 74 74 typedef u_int SOCKET; 75 76 77 78 79 typedef struct AsyncStatus {80 HWND hwnd; // owner's hwindow81 u_int msg; // message to send when event occurs82 ULONG event; // event that may occur83 SOCKET socket; // the socket84 int status; // blocking yes/no85 TID threadID; // Thread ID for async86 int MsgStat; // has message been sent yet?87 struct AsyncStatus *Next; // pointer to next AsyncStatus in the list88 struct AsyncStatus *Prev; // pointer to previous AsyncStatus in the list89 } AsyncStatus;90 91 92 93 75 94 76 … … 201 183 #define WSIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */ 202 184 #define WSIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */ 203 204 /*205 * Structures returned by network data base library, taken from the206 * BSD file netdb.h. All addresses are supplied in host order, and207 * returned in network order (suitable for use in system calls).208 */209 210 struct Whostent {211 char * h_name; /* official name of host */212 char * * h_aliases; /* alias list */213 short h_addrtype; /* host address type */214 short h_length; /* length of address */215 char * * h_addr_list; /* list of addresses */216 #define h_addr h_addr_list[0] /* address, for backward compat */217 };218 219 /*220 * It is assumed here that a network number221 * fits in 32 bits.222 */223 struct Wnetent {224 char * n_name; /* official name of net */225 char * * n_aliases; /* alias list */226 short n_addrtype; /* net address type */227 u_long n_net; /* network # */228 };229 230 struct Wservent {231 char * s_name; /* official service name */232 char * * s_aliases; /* alias list */233 short s_port; /* port # */234 char * s_proto; /* protocol to use */235 };236 237 struct Wprotoent {238 char * p_name; /* official protocol name */239 char * * p_aliases; /* alias list */240 short p_proto; /* protocol # */241 };242 185 243 186 /* -
trunk/src/wsock32/wsock32const.h
r1384 r1451 1 /* $Id: wsock32const.h,v 1. 2 1999-10-20 20:11:03phaller Exp $ */1 /* $Id: wsock32const.h,v 1.3 1999-10-25 23:17:20 phaller Exp $ */ 2 2 3 3 /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll. … … 174 174 #define OS2WSAGETSELECTERROR(lParam) HIWORD(lParam) 175 175 176 177 /* 178 * Structures returned by network data base library, taken from the 179 * BSD file netdb.h. All addresses are supplied in host order, and 180 * returned in network order (suitable for use in system calls). 181 */ 182 183 struct Whostent { 184 char * h_name; /* official name of host */ 185 char * * h_aliases; /* alias list */ 186 short h_addrtype; /* host address type */ 187 short h_length; /* length of address */ 188 char * * h_addr_list; /* list of addresses */ 189 #define h_addr h_addr_list[0] /* address, for backward compat */ 190 }; 191 192 /* 193 * It is assumed here that a network number 194 * fits in 32 bits. 195 */ 196 struct Wnetent { 197 char * n_name; /* official name of net */ 198 char * * n_aliases; /* alias list */ 199 short n_addrtype; /* net address type */ 200 u_long n_net; /* network # */ 201 }; 202 203 struct Wservent { 204 char * s_name; /* official service name */ 205 char * * s_aliases; /* alias list */ 206 short s_port; /* port # */ 207 char * s_proto; /* protocol to use */ 208 }; 209 210 struct Wprotoent { 211 char * p_name; /* official protocol name */ 212 char * * p_aliases; /* alias list */ 213 short p_proto; /* protocol # */ 214 }; 215 216 176 217 #endif /* _WINSOCK32CONST_ */ 177 218
Note:
See TracChangeset
for help on using the changeset viewer.