Ejemplo n.º 1
0
// See if DOpus is already running
void startup_check_duplicate()
{
    Forbid();
    if (FindPort(dopus_name))
    {
        struct MsgPort *port;

        // Ask if we want to run another copy
        Permit();
        if (SimpleRequest(0,
                          dopus_name,
                          GetString(&locale,MSG_ALREADY_RUNNING_BUTTONS),
                          GetString(&locale,MSG_ALREADY_RUNNING),0,0,0,0))
        {
            // Find port again (under Forbid)
            Forbid();
            if ((port=FindPort(dopus_name)))
            {
                // Signal program to wake up
                Signal((struct Task *)port->mp_SigTask,IPCSIG_SHOW);
            }
            Permit();

            // Quit this copy
            quit(0);
        }
    }
    Permit();
}
Ejemplo n.º 2
0
int dllKillLibrary(char *portname)
{
    dll_tMessage msg,*reply;
    struct MsgPort *myport;
    struct MsgPort *dllport;

    bug("[DynLink] %s('%s')\n", __PRETTY_FUNCTION__, portname);

    if(!(myport=CreateMsgPort()))
        exit(0L);       //Arghh
    
    bzero(&msg, sizeof(msg));

    msg.dllMessageType=DLLMTYPE_Kill;

    msg.Message.mn_ReplyPort = myport;

    if((dllport=FindPort(portname)))
    {
        PutMsg(dllport, (struct Message *)&msg);
        /*WaitPort(myport);*/
        while(!(reply=(dll_tMessage *)GetMsg(myport)))
        {
            Delay(2);
            if(FindPort(portname)!=dllport)
                break;
        }
    }

    DeleteMsgPort(myport);

    return (dllport?1:0);
}
Ejemplo n.º 3
0
void *
traffic_newconn(
    tcp_pair *ptp)
{
    struct conn_info *pci;

    pci = MakeConnRec();
    pci->pti1 = FindPort(ptp->addr_pair.a_port);
    pci->pti2 = FindPort(ptp->addr_pair.b_port);

    return(pci);
}
Ejemplo n.º 4
0
int msgio_init(void)
{
    /* already initialized */
    if(msgio_ready > 0) {
        msgio_ready++;
        return 0;
    }
    
    /* try to find port */
    D(bug("finding port\n"));    
    port = FindPort(SRV_PORT_NAME);
    if(!port) {
        return -1;
    }
    D(bug("found port\n"));
    
    /* create a reply port */
    reply_port = CreatePort(0L, 0L);
    if(!reply_port) {
        return -2;
    }
    D(bug("created port\n"));
    
    /* alloc a message */
    msg = (msg_t *)AllocMem(sizeof(msg_t), MEMF_CLEAR);
    if(!msg) {
        return -3;
    }
    D(bug("got mem\n"));
    msg->m_msg.mn_ReplyPort = reply_port;
    
    msgio_ready++;
    return 0;
}
Ejemplo n.º 5
0
VOID __saveds PingFunc( VOID )
{
    struct MsgPort *ClientPort, *ReplyPort;
	struct Library *SysBase;
    BlankMsg PingMsg;

	SysBase = *( struct Library ** )4L;

	if( ReplyPort = CreateMsgPort())
	{
		PingMsg.bm_Mess.mn_ReplyPort = ReplyPort;
		PingMsg.bm_Mess.mn_Length = sizeof( BlankMsg );
		PingMsg.bm_Type = BM_PING;
		/* Stealthimania, to alleviate processing at the blanker */
		PingMsg.bm_Mess.mn_Node.ln_Name = ( UBYTE * )( &Blanking );

		for( ;; )
		{
			if( SetSignal( 0L, SIGBREAKF_CTRL_C ) & SIGBREAKF_CTRL_C )
				break;

			if( ClientPort = FindPort( "GarshneClient" ))
			{
				PingMsg.bm_Flags = 0L;
				PutMsg( ClientPort, ( struct Message * )( &PingMsg ));
				WaitPort( ReplyPort );
				GetMsg( ReplyPort );
			}
		}
		DeletePort( ReplyPort );
	}
}
Ejemplo n.º 6
0
int rexx_init (void)
{
    RexxSysBase = (REXXBASE *) OpenLibrary ("rexxsyslib.library", 0L);
    if (!RexxSysBase) {
	write_log ("Can't find rexxsyslib.library!\n");
	return 0;
    }
#ifdef __amigaos4__
    IRexxSys = (struct RexxSysIFace *) GetInterface (RexxSysBase, "main", 1, NULL);
    if (!IRexxSys) {
	CloseLibrary (RexxSysBase);
	RexxSysBase = 0;
	return 0;
    }
#endif

    if (FindPort(UAE_PORTNAME)) {
	write_log ("Port \"%s\" already exists!\n", UAE_PORTNAME);
	return 0;
    }
    ARexxPort = CreatePort (UAE_PORTNAME, 0);
    if (!ARexxPort) {
	write_log ("Failed to open AREXX port \"%s\"!\n", UAE_PORTNAME);
	return 0;
    }
    write_log ("Rexx port \"%s\" installed.\n", UAE_PORTNAME);
    rexx_handle_events ();
    return 1;
}
Ejemplo n.º 7
0
int main(int argc, char *argv)
{
    struct tracked_resource_kind *port_kind;
    struct tracked_pool *main_pool;
    struct tracked_resource *my_port_resource;
    struct MsgPort *my_port;

    make_resource_tracking();
    assert(!IoErr());

    port_kind = make_resource_kind("message port", (void(*)(void *)) DeletePort);
    assert(port_kind != NULL);

    main_pool = make_tracked_pool();
    assert(main_pool != NULL);

    my_port = CreatePort(PORTNAME,0);
    if (my_port != NULL) {
        my_port_resource = make_tracked_resource(main_pool, (void *) my_port, port_kind);
    } else {
        printf("cannot create port \"" PORTNAME "\"\n");
    }

    dispose_tracked_pool(main_pool);

    assert(FindPort(PORTNAME) == NULL);
    return 0;
}
Ejemplo n.º 8
0
void RegisterARexxFunctionHost(int add) {
  struct RexxMsg *mess;
  struct MsgPort *rexxmastport;
  if(!(mess=(struct RexxMsg *)AllocMem(sizeof(struct RexxMsg),
                                       MEMF_CLEAR | MEMF_PUBLIC))) {
    cleanup(EXIT_ERROR, "Out of memory.");
  }
  mess->rm_Node.mn_Node.ln_Type = NT_MESSAGE;
  mess->rm_Node.mn_Length = sizeof(struct RexxMsg);
  mess->rm_Node.mn_ReplyPort=rexxport;
  mess->rm_Action = add ? RXADDFH : RXREMLIB;
  mess->rm_Args[0] = "NIKOMREXXHOST";
  mess->rm_Args[1] = 0L;
  Forbid();
  rexxmastport = (struct MsgPort *)FindPort("REXX");
  if(rexxmastport) {
    PutMsg((struct MsgPort *)rexxmastport,(struct Message *)mess);
  }
  Permit();
  if(rexxmastport == NULL) {
    FreeMem(mess, sizeof(struct RexxMsg));
    if(add) {
      cleanup(EXIT_ERROR, "Can't find port 'REXX' (ARexx master server)");
    }
    return;
  }
  WaitPort(rexxport);
  GetMsg(rexxport);
  FreeMem(mess, sizeof(struct RexxMsg));
}
Ejemplo n.º 9
0
static void entry(void)
{
    struct MsgPort *port1,*port2;
    struct Message *msg;

    Forbid();
    port1=FindPort("message test port");
    Permit();

    port2=CreateMsgPort();
    if(port2!=NULL)
    {
	msg=(struct Message *)CreateIORequest(port2,sizeof(struct Message));
	if(msg!=NULL)
	{
	    int i;
	    for(i=0;i<10;i++)
	    {
		msg->mn_Node.ln_Name=(char *)i;
		PutMsg(port1,msg);
		WaitPort(port2);
		GetMsg(port2);
	    }
	    DeleteIORequest((struct IORequest *)msg);
	}
	DeleteMsgPort(port2);
    }

    Signal(port1->mp_SigTask,1<<port1->mp_SigBit);

    Wait(0);/* Let the parent remove me */
}
Ejemplo n.º 10
0
  /** 
   * Start a unique XRootd server and return it's access URL 
   * 
   * @param url On return, the access url 
   * 
   * @return true if successful, false otherwise 
   */
  static Bool_t StartXrootd(TString& url)
  {
    url = "";
    Int_t port = FindPort();
    if (port < 0) return false;

    // Get host, current directory, and user name for unique name
    TString host(gSystem->HostName());
    TString dir(gSystem->WorkingDirectory());
    TString name(gSystem->GetUserInfo()->fUser.Data());

    // Form the command line.  Note, we put the PID file one level up,
    // so we know where to look for it. Otherwise it would be put in a
    // sub-directory based on the name of the server.  Since we later
    // on don't know the name of the server we wouldn't now where to
    // look for the PID file
    TString exec;
    exec.Form("xrootd -p %d -l xrd.log -s ../xrd.pid -b -n %s %s",
	      port, name.Data(), dir.Data());
    Info("StartXrootd", "Starting XRootD to serve %s on port %d",
	 dir.Data(), port);
    Info("StartXrootd", "%s", exec.Data());
    int ret = gSystem->Exec(exec);
    if (ret != 0) {
      Warning("StartXrootd", "Failed to start XRootd server");
      return false;
    }
    
    // Form the access URL
    url = Form("root://%s@%s:%d/%s",
	       name.Data(), host.Data(), port, dir.Data());
    Info("StartXrootd", "Access URL is \"%s\"", url.Data());

    return true;
  }
Ejemplo n.º 11
0
/*(up to 2View.99)*/
void determinePortName(char *portName)
{
   ULONG c=1;
   UBYTE len;

   strcpy(portName,"2View.");

   do
   {
      len=stcu_d(&portName[6],c++);
      portName[6+len]='\0';
   }
   while(FindPort(portName)!=NULL && c<100);
   if(FindPort(portName)!=NULL)
      exit(50);
   return;
}
Ejemplo n.º 12
0
BOOL Setup(void)
{
  if (!(GfxBase = OpenLibrary("graphics.library", 0))) return FALSE;
  if (!(IntuitionBase = OpenLibrary("intuition.library", 0))) return FALSE;
  if (!(MUIMasterBase = OpenLibrary("muimaster.library", 0))) return FALSE;
  if (!(LocaleBase = OpenLibrary("locale.library", 0))) return FALSE;
  if (!(ColorList = CreateColorListClass())) return FALSE;
  Locale = OpenLocale(NULL);
  if (FindPort("SysLog")) return FALSE;
  return TRUE;
}
Ejemplo n.º 13
0
//
// 排序增加SPI端口,由XFILTER.DLL通过DeviceIoControl调用
//
int AddPort(USHORT Port)
{
	static int Index, MoveCount;
	if(Port == 0 || FindPort(Port, &Index) || Index >= MAX_SPI_PORT)
		return -1;
	MoveCount = m_SpiPortCount - Index;
	if(MoveCount > 0)
		memcpy(m_SpiPort + Index + 1, m_SpiPort + Index, MoveCount * PORT_LENGTH);
	m_SpiPort[Index] = Port;
	m_SpiPortCount++;
	return Index;
}
Ejemplo n.º 14
0
void dllInternalFreeLibrary(int i)
{
    dll_tMessage msg,*reply;
    struct MsgPort *myport;
    struct dll_sInstance *inst=(struct dll_sInstance *) dllOpenedDLLs[i].inst;

    bug("[DynLink] %s(%u)\n", __PRETTY_FUNCTION__, i);

    if(!inst)
        return;

    if(!(myport=CreateMsgPort()))
    {
        exit(0L);       //Arghh
    }

    bzero(&msg, sizeof(msg));

    msg.dllMessageType=DLLMTYPE_Close;

    msg.Message.mn_ReplyPort = myport;

    if(FindPort(dllOpenedDLLs[i].name)==inst->dllPort)
    {
        PutMsg(inst->dllPort, (struct Message *)&msg);
        /*WaitPort(myport);*/
        while(!(reply=(dll_tMessage *)GetMsg(myport)))
        {
            Delay(2);
            if(FindPort(dllOpenedDLLs[i].name)!=inst->dllPort)
                break;
        }
    }

    DeleteMsgPort(myport);
    free(inst);

    bzero(&dllOpenedDLLs[i],sizeof(dllOpenedDLLs[i]));
    return;
}
Ejemplo n.º 15
0
//
// 删除SPI端口,由XFILTER.DLL通过DeviceIoControl调用
//
int DeletePort(USHORT Port)
{
	static int Index, MoveCount;
	if(Port == 0 || !FindPort(Port, &Index))
		return -1;
	MoveCount = m_SpiPortCount - Index - 1;
	if(MoveCount > 0)
		memcpy(m_SpiPort + Index, m_SpiPort + Index + 1, MoveCount * PORT_LENGTH);
	else
		m_SpiPort[Index] = 0;
	m_SpiPortCount--;
	return 0;
}
Ejemplo n.º 16
0
/* 
   This procedure should be called after every digitalWrite 
*/
void ShiftRegister::Update ()
{
  Pin * clkPin = FindPort ( "SRCLK");
  int SRCLK = clkPin->value.value; 
  Pin * serPin = FindPort ("SER");
  int SER = serPin->value.value;
  Pin * Qh = FindPort ("Qh");
  int QhValue;
   
  if ((SRCLK==1) && !lastSRCLK) // Transition to high so shift
  {
  	shiftValue *= 2;              // shift
  	QhValue = shiftValue & 0x100; // Get the shifted out value
  	shiftValue &= 0xFF;           // zero out Qh
  	shiftValue += SER;            // Shift in the new value
  	WriteOutValue (shiftValue);
  	if (QhValue)
      SimUtilities::Instance()->WriteValue (Qh,1,0);  
	else
	  SimUtilities::Instance()->WriteValue (Qh,0,0);  	
  }   
  lastSRCLK = SRCLK;
}
Ejemplo n.º 17
0
/*
 * This function will send a string to ARexx...
 *
 * The default host port will be that of your task...
 *
 * If you set StringFile to TRUE, it will set that bit for the message...
 *
 * Returns TRUE if it send the message, FALSE if it did not...
 */
short SendARexxMsg(AREXXCONTEXT RexxContext,char *RString,
			short StringFile)
{
    register	struct	MsgPort	*RexxPort;
    register	struct	RexxMsg	*rmsg;
    register		short	flag=FALSE;

    if (RexxContext) if (RString)
    {
	if (rmsg=CreateRexxMsg(RexxContext->ARexxPort,
			       RexxContext->Extension,
			       RexxContext->PortName))
	{
	    rmsg->rm_Action=RXCOMM | (StringFile ?
				      (1L << RXFB_STRING):0);
	    if (rmsg->rm_Args[0]=CreateArgstring(RString,
						 (LONG)strlen(RString)))
	    {
				/*
				 * We need to find the RexxPort and this needs
				 * to be done in a Forbid()
				 */
		Forbid();
		if (RexxPort=FindPort(RXSDIR))
		{
					/*
					 * We found the port, so put the
					 * message to ARexx...
					 */
		    PutMsg(RexxPort,(struct Message *)rmsg);
		    RexxContext->Outstanding+=1;
		    flag=TRUE;
		}
		else
		{
					/*
					 * No port, so clean up...
					 */
		    DeleteArgstring(rmsg->rm_Args[0]);
		    DeleteRexxMsg(rmsg);
		}
		Permit();
	    }
	    else DeleteRexxMsg(rmsg);
	}
    }
    return(flag);
}
Ejemplo n.º 18
0
static void
DoplotIOpen(int port, Bool fopen)
{
    struct traffic_info *pti;

    /* just for this port */
    if ((pti = FindPort(port)) == NULL)
	return;

    if (fopen)
	++pti->n_i_open;
    else
	--pti->n_i_open;

    extend_line(pti->line_niopen, current_time, pti->n_i_open);
}
Ejemplo n.º 19
0
DWORD
CheckPrinterPortToken(
    LPCWSTR string,
    LPCWSTR pSecondPart,
    PDWORD pTypeofHandle,
    PINIPRINTER* ppIniPrinter,
    PINIPORT* ppIniPort,
    PINIJOB* ppIniJob,
    const LPPRINTER_DEFAULTS pDefaults,
    const PINISPOOLER pIniSpooler
    )
{
    if( wcsncmp( pSecondPart, L"Port", 4 ) != STRINGS_ARE_EQUAL ||
        !( *ppIniPort = FindPort( string ))){

        return ROUTER_UNKNOWN;
    }

    //
    // The name is the name of a port:
    //
    if( pDefaults            &&
        pDefaults->pDatatype &&
        !ValidRawDatatype( pDefaults->pDatatype )) {

        SetLastError( ERROR_INVALID_DATATYPE );
        return ROUTER_STOP_ROUTING;
    }

    if ( *ppIniJob = (*ppIniPort)->pIniJob ) {

        *ppIniPrinter = (*ppIniJob)->pIniPrinter;
        *pTypeofHandle |= PRINTER_HANDLE_PORT;

    } else if( (*ppIniPort)->cPrinters ){

        //
        // There is no current job assigned to the port
        // So Open the First Printer Associated with
        // this port.
        //
        *ppIniPrinter = (*ppIniPort)->ppIniPrinter[0];
        *pTypeofHandle |= PRINTER_HANDLE_PRINTER;
    }
    return ROUTER_SUCCESS;
}
Ejemplo n.º 20
0
void ShiftRegister::WriteOutValue (int value)
{
  char port[] = " ";
  Pin * pin;
  int val = 1;
  
  for (int i=0; i<8; i++)
  {
  	port [0] = 'A' + i;
  	pin = FindPort (port);
  	if (value & val)
      SimUtilities::Instance()->WriteValue (pin,1,0);    
    else
      SimUtilities::Instance()->WriteValue (pin,0,0);
    val *= 2; // shift to next value  
  }
}
Ejemplo n.º 21
0
/*************
 * FUNCTION:		CreateRexxHost
 * VERSION:			0.1 08.03.1995
 * DESCRIPTION:	Creates a RexxHost (special MsgPort) with a given name.
 *						Returns NULL if port already exists.
 * INPUT:			HostName
 * OUTPUT:			RexxHost
 * HISTORY:       DATE		NAME		COMMENT
 *						08.03.95	ah			first release
 *************/
struct MsgPort *CreateRexxHost(STRPTR HostName)
{
	struct MsgPort *RexxHost;

	/* Valid name given? */
	if(HostName && HostName[0])
	{
		/* Already present? */
		if(!FindPort((char *)HostName))
		{
			/* Allocate the port body. */
			RexxHost = (struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC | MEMF_CLEAR);
			if(RexxHost)
			{
				/* Allocate a signal bit. */
				if((RexxHost->mp_SigBit = AllocSignal(-1)) != -1)
				{
					/* Initialize the MsgPort node head. */
					RexxHost->mp_Node.ln_Type	= NT_MSGPORT;
					RexxHost->mp_Node.ln_Pri	= 0;

					/* Allocate memory for MsgPort name. */
					RexxHost->mp_Node.ln_Name = (char *)AllocMem(strlen((char *)HostName)+1,MEMF_PUBLIC);
					if(RexxHost->mp_Node.ln_Name)
					{
						/* Copy the name. */
						strcpy(RexxHost->mp_Node.ln_Name,(char *)HostName);

						/* Deal with the rest of the flags. */
						RexxHost->mp_Flags	= PA_SIGNAL;
						RexxHost->mp_SigTask	= FindTask(NULL);

						/* Finally add it to the public port list. */
						AddPort(RexxHost);

						/* And return it to the caller. */
						return(RexxHost);
					}
					FreeSignal(RexxHost->mp_SigBit);
				}
				FreeMem(RexxHost,sizeof(struct MsgPort));
			}
		}
	}
	return(NULL);
}
Ejemplo n.º 22
0
void startupNiKom(void) {
  struct MsgPort *port;

  Forbid();
  port = (struct MsgPort *)FindPort("NiKomPort");
  if(port == NULL) {
    NiKPort = (struct MsgPort *)CreatePort("NiKomPort",0);
  }
  Permit();
  if(port != NULL) {
    printf("NiKServer is already running.\n");
    exit(10);
  }
  if(NiKPort == NULL) {
    printf("Can't create message port 'NiKomPort'\n");
    exit(10);
  }
  openLibrariesAndPorts();
  setupServermem();
  initLanguages();
  
  readSysInfo();
  readTextInfo();
  readGroupData();
  ReadCommandConfig();
  ReadSystemConfig();
  readConferenceData();
  readConferenceTexts();
  readUserData();
  ReadFidoConfig();
  ReadNodeTypesConfig();
  readLastLogins();
  ReadFileKeyConfig();
  ReadStatusConfig();
  readFileAreas();
  readFileAreaFiles();
  GetServerversion();
  scanFidoConferences();
  InitLegacyConversionData();
  initNodes();
  openWindow();
}
Ejemplo n.º 23
0
LONG MessageServer( LONG Type )
{
	struct MsgPort *ServerPort;
	BlankMsg *ClientMsg;
	
	if( ServerPort = FindPort( "GarshneServer" ))
	{
		if( ClientMsg = AllocVec( sizeof( BlankMsg ), MEMF_PUBLIC|MEMF_CLEAR ))
		{
			ClientMsg->bm_Mess.mn_ReplyPort = ClientPort;
			ClientMsg->bm_Mess.mn_Length = sizeof( BlankMsg );
			ClientMsg->bm_Type = Type;
			PutMsg( ServerPort, ( struct Message * )ClientMsg );
			
			return OK;
		}
	}
	
	return QUIT;
}
Ejemplo n.º 24
0
BOOL
OpenPort(
    LPWSTR   pName,
    PHANDLE pHandle
)
{
    PINIPORT    pIniPort;

   EnterSplSem();
    pIniPort = FindPort(pName);
   LeaveSplSem();

    if (pIniPort) {
        *pHandle = pIniPort;
        return TRUE;
    } else {
//     DbgPrint("localmon!OpenPort %s : Failed\n", pName);
        return FALSE;
    }
}
Ejemplo n.º 25
0
int arexx_execute_script(char *command)
{
	struct RexxMsg *rxmsg;
	BPTR lock;

	if (!(lock = Lock(command,ACCESS_READ))) return 0;
	if (!(command = NameOfLock(lock)))
	{
		UnLock(lock);
		return 0;
	}

	UnLock(lock);

	if ((rxmsg = CreateRexxMsg(arexx_execute_port, "SMRX", "SIMPLEMAIL.1")))
	{
		rxmsg->rm_Args[0] = command;

		if (FillRexxMsg(rxmsg,1,0))
		{
			struct MsgPort *ap; /* Port of ARexx resident process */

			/* Init Rexx message */
			rxmsg->rm_Action = RXCOMM;/*|RXFF_NOIO;*/

			/* Find port and send message */
			Forbid();
			ap = FindPort("REXX");
			if (ap)
			{
				PutMsg(ap,(struct Message *)rxmsg);
				arexx_execute_out++;
			}
			Permit();

			return 1;
		}
		DeleteRexxMsg(rxmsg);
	}
	return 0;
}
Ejemplo n.º 26
0
VOID MessageModule( STRPTR PortName, LONG Type )
{
    struct MsgPort *ClientPort;
    BlankMsg *ClientMsg;
    
    if( ClientPort = FindPort( PortName ))
    {
        if( ClientMsg = AllocVec( sizeof( BlankMsg ), MEMF_CLEAR|MEMF_PUBLIC ))
        {
            ClientMsg->bm_Mess.mn_ReplyPort = ServerPort;
            ClientMsg->bm_Mess.mn_Length = sizeof( BlankMsg );
            /* Stealthimania */
            ClientMsg->bm_Mess.mn_Node.ln_Name = ( UBYTE * )( &Blanking );
            ClientMsg->bm_Type = Type;
            PutMsg( ClientPort, ( struct Message * )ClientMsg );
            return;
        }
    }
    
    if( Type == BM_DOBLANK )
        InternalBlank();
}
Ejemplo n.º 27
0
Archivo: debug.c Proyecto: vidarh/FPL
void REGARGS
DebugMail(struct Data *scr, MailSubj flag, long data2, void *data)
{
  struct ExecBase *SysBase = *(struct ExecBase **)4;
  struct Messy mess;
  struct MsgPort *port;
  if(scr->flags&FPLDATA_DEBUG) {
    Forbid();
    port=FindPort(MSGPORT_NAME);
    if (port) {
      struct MsgPort *answerport;
      answerport=CreateMsgPort();
      if (answerport) {
        mess.mess.mn_Length=sizeof(struct Messy);
        mess.mess.mn_ReplyPort=answerport;
        mess.scr = scr; /* give them the world of FPL! */
        mess.flag = flag;
        switch(flag) {
        case MAIL_START:
        case MAIL_EXIT:
          mess.data = NULL;
          break;
        default:
          mess.data = data;
        }
        mess.data2 = (void *)data2;
        PutMsg(port, (struct Message *)&mess);
        Permit();
        WaitPort(answerport);
        DeleteMsgPort(answerport);
        /* Message sent */
      } else {
        Permit();
      }
    } else {
      Permit();
    }
  }
}
Ejemplo n.º 28
0
/*************
 * FUNCTION:		SendRexxCommand
 * VERSION:			0.1 08.03.1995
 * DESCRIPTION:	Sends a command to the rexx server, requires pointers
 *						to the MsgPort of the calling Host and the command string.
 *						File extension and host name are optional and may be
 *						NULL
 * INPUT:			HostPort
 *						CommandString
 *						FileExtension
 *						HostName
 * OUTPUT:			TRUE: sucessfull, else false
 * HISTORY:       DATE		NAME		COMMENT
 *						08.03.95	ah			first release
 *************/
LONG SendRexxCommand(struct MsgPort *HostPort,STRPTR CommandString,STRPTR FileExtension,STRPTR HostName)
{
	struct MsgPort	*RexxPort = (struct MsgPort *)FindPort(RXSDIR);
	struct RexxMsg	*HostMessage;

	/* Valid pointers given? */
	if(CommandString && HostPort && RexxPort)
	{
		/* No special host name given? Take the MsgPort name. */
		if(!HostName)
			HostName = (STRPTR)HostPort->mp_Node.ln_Name;

		/* No file name extension? Take the default. */
		if(!FileExtension)
			FileExtension = (STRPTR)"rexx";

		/* Create the message. */
		HostMessage = CreateRexxMsg((struct MsgPort *)HostPort,(char *)FileExtension,(char *)HostName);
		if(HostMessage)
		{
			/* Add the command. */
			HostMessage->rm_Args[0] = CreateArgstring((char *)CommandString,strlen((char *)CommandString));
			if(HostMessage->rm_Args[0])
			{
				/* This is a command, not a function. */
				HostMessage->rm_Action = RXCOMM;

				/* Release it... */
				PutMsg(RexxPort,(struct Message*)HostMessage);

				/* Successful action. */
				return(TRUE);
			}
			DeleteRexxMsg(HostMessage);
		}
	}
	return(FALSE);
}
Ejemplo n.º 29
0
static BOOL localSendRexxMsg(struct MsgPort *reply, STRPTR rxport, STRPTR rxcmd)
{
  BOOL success = FALSE;
  struct RexxMsg *rxmsg;

  ENTER();

  if((rxmsg = CreateRexxMsg(reply, NULL, NULL)) != NULL)
  {
    rxmsg->rm_Action = RXCOMM|RXFF_STRING|RXFF_NOIO;

     if((rxmsg->rm_Args[0] = (IPTR)CreateArgstring(rxcmd,strlen(rxcmd))) != 0)
     {
       struct MsgPort *port;

       Forbid();

       if((port = FindPort(rxport)) != NULL)
       {
         PutMsg(port, (struct Message *)rxmsg);

         success = TRUE;
       }

       Permit();

       if(success == FALSE)
         DeleteArgstring((APTR)rxmsg->rm_Args[0]);
     }

     if(success == FALSE)
       DeleteRexxMsg(rxmsg);
  }

  RETURN(success);
  return success;
}
Ejemplo n.º 30
0
/* send a message to an AREXX port.
 */
static int ADDRESS (const char *hostname, const char *cmd)
{
    struct MsgPort *RexxPort,
		   *ReplyPort;
    struct RexxMsg *HostMsg,
		   *answer;
    int result = RC_WARN;

    if (!stricmp (hostname, "COMMAND"))
	return SystemTagList(cmd,NULL);

    if ((RexxPort = (void *)FindPort (hostname))) {
	if ((ReplyPort = (void *)CreateMsgPort ())) {
	    if ((HostMsg = CreateRexxMsg (ReplyPort, NULL, hostname))) {
		unsigned int len = strlen (cmd); /* holger: trick for powerup */
		if ((HostMsg->rm_Args[0] = CreateArgstring ((char *)cmd, len))) {
		    HostMsg->rm_Action = RXCOMM | RXFF_RESULT;
		    PutMsg (RexxPort, (void*)HostMsg);
		    WaitPort (ReplyPort);
		    while (!(answer = (void *)GetMsg (ReplyPort)));
		    result = answer->rm_Result1;
		    if (result == RC_OK) {
			if (answer->rm_Result2) {
			    strncpy (RESULT,(char *)answer->rm_Result2, RESULT_LEN);
			    DeleteArgstring ((char *)answer->rm_Result2);
			} else RESULT[0] = '\0';
		    }
		    DeleteArgstring (HostMsg->rm_Args[0]);
		} else strcpy (RESULT, "Can't create argstring!");
		DeleteRexxMsg (HostMsg);
	    } else strcpy (RESULT, "Can't create rexx message!");
	    DeleteMsgPort (ReplyPort);
	} else strcpy (RESULT, "Can't alloc reply port!");
    } else sprintf (RESULT, "Port \"%s\" not found!", hostname);
    return result;
}