home *** CD-ROM | disk | FTP | other *** search
- /* $Id: mymsg.c,v 1.2 1994/04/17 11:53:44 too Exp $
- *
- * Copyright (c) 1993 AmiTCP/IP Group <amitcp-group@hut.fi>
- *
- * Created: Wed Nov 10 13:29:00 1993 too
- * Last modified: Wed Apr 13 16:01:36 1994 too
- */
- {
- struct Message * msg;
-
- while ((msg = GetMsg(mymsgport)) != NULL) {
- struct DosPacket * packet = msgToPkt(msg);
- struct ApplPort * applport;
- char * name;
- UBYTE namelen;
- LONG flags = 0;
- LONG ioErr;
-
- switch (packet->dp_Type) {
-
- case ACTION_FINDINPUT:
- case ACTION_FINDOUTPUT:
- case ACTION_FINDUPDATE:
- /*
- * get given handler name. Reopen packets doesn't come here.
- */
-
- /* Get given handler name. can be real name or *, or 'CONSOLE:'
- * 2 last mentioned in reopen case. First byte in argument 3
- * in received packet is namelen and rest bytes are the name.
- */
- name = (UBYTE *)BADDR(packet->dp_Arg3);
- namelen = *name++;
-
- /*
- * getting new connection object.
- */
- if ((applport = getBuffer((struct List *)&freeappllist,
- sizeof (struct ApplPort))) == NULL) {
- ReplyPkt(packet, DOSFALSE, ERROR_NO_FREE_STORE);
- break;
- }
-
- if ((ioErr = handleArgs(SocketBase, &flags,
- &applport->ap_Sd, name, namelen)) != 0) {
- AddTail((struct List *)&freeappllist, (struct Node *)applport);
- ReplyPkt(packet, DOSFALSE, ioErr);
- }
- else {
- /*
- * Initialize some fields in applstruct.
- */
- applarray[applport->ap_Sd] = applport;
- applport->ap_AS = &AS;
- applport->ap_Pw = NULL;
- applport->ap_Disb = FALSE;
- applport->ap_OpenCnt = 1;
- /*
- * Set new socket to active read sockets.
- */
- nfds++;
-
- FD_SET(applport->ap_Sd, &readfds);
-
- initApplMsgPort(&applport->ap_AMP);
- /*
- * Copy timer.device information to IORequest part
- * of applport's timerequest field.
- */
- CopyMem(itr, &applport->ap_Tr, sizeof *itr);
- /* (struct IORequest)applport->ap_Tr = *itr; */
-
- /*
- * Reply 'Open' packet only if connection already made.
- */
- if (flags & APF_LISTENING)
- applport->ap_Packet = packet; /* values set after accept() */
- else {
- struct FileHandle * fh =
- (struct FileHandle *)BADDR(packet->dp_Arg1);
- /*
- * Set MsgPort ptr of Open() FileHandle to point the
- * messageport allocated for this connection.
- */
- fh->fh_Port = (struct MsgPort *)DOSTRUE; /* IsInteractive() */
- fh->fh_Type = &applport->ap_AMP.amp_Msgport;
- IoctlSocket(applport->ap_Sd, FIONBIO, (char *)&one);
- setsockopt(applport->ap_Sd,
- SOL_SOCKET, SO_OOBINLINE, (char *)&one, sizeof one);
- applport->ap_Packet = NULL;
- ReplyPkt(packet, DOSTRUE, packet->dp_Res2);
- }
- }
- break;
- case ACTION_IS_FILESYSTEM:
- ReplyPkt(packet, DOSFALSE, 0);
- break;
- default:
- /*
- * Other messages comes to separate messageport.
- * each 'channel' has their own for identification reasons.
- * (this is good reply for ACTION_LOCATE_OBJECT)
- */
- ReplyPkt(packet, DOSFALSE, ERROR_ACTION_NOT_KNOWN);
- break;
- }
- }
- }
-