home *** CD-ROM | disk | FTP | other *** search
-
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/rexxsyslib.h>
- #include <rexx/errors.h>
- #include <string.h>
- #include <stdlib.h>
-
- struct Library *RexxSysBase;
-
- /*****
- *
- * FUNZIONE: ULONG *SendRexxCommand(char *port,char *cmd,struct MsgPort *replyPort,char *buffer)
- *
- * SCOPO: Manda un messaggio "cmd" AREXX alla porta "port" utilizzando una
- * porta di reply "replyport".Al termine in "buffer" (se !=NULL)
- * viene copiato il Result2 del messaggio.
- *
- * RESTITUISCE: NULL=host non trovato, altrimenti puntatore a LONG indicante il Result1 del mess.
- *
- ****/
-
- ULONG *SendRexxCommand(char *port,char *cmd,struct MsgPort *replyPort,char *buffer)
- {
- struct MsgPort *rexxport;
-
-
-
- Forbid();
-
- if (rexxport=FindPort(port))
- {
- struct RexxMsg *rexxMsg,
- *answer;
-
- if (rexxMsg=CreateRexxMsg(replyPort,NULL,NULL))
- {
- if (rexxMsg->rm_Args[0]=CreateArgstring(cmd,strlen(cmd)))
- {
- static ULONG result;
-
- rexxMsg->rm_Action=RXCOMM|RXFF_RESULT;
-
- PutMsg(rexxport,&rexxMsg->rm_Node);
-
- do
- {
- WaitPort(replyPort);
- if (answer=(struct RexxMsg *)GetMsg(replyPort)) result=answer->rm_Result1;
-
- }
- while(!answer);
-
- Permit();
-
- if (answer->rm_Result1==RC_OK)
- {
- if (answer->rm_Result2)
- {
- if (buffer) strcpy(buffer,(char *)answer->rm_Result2);
- DeleteArgstring((char *)answer->rm_Result2);
- }
- }
-
- DeleteArgstring((char *)ARG0(answer));
-
- DeleteRexxMsg(answer);
-
- return(&result);
- }
- }
- }
-
- Permit();
-
- return(NULL);
- }
-
-
-
- /*****
- *
- * FUNZIONE: void Split(char *str1,char *str2)
- *
- * SCOPO: Splitta il nome file in str1 in directory (restituito in str1)
- * e file (restituito in str2).
- *
- * RESTITUISCE: -
- *
- ****/
-
- void Split(char *str1,char *str2)
- {
- int l=strlen(str1);
- do l--;
- while((l>=0)&&(str1[l]!='/')&&(str1[l]!=':'));
- if (l<0) *str2=0;
- else
- {
- strcpy(str2,str1);
- str2[l+1]=0;
- strcpy(str1,str1+l+1);
- }
- }
-
-
-
- /*********
- *
- * MAIN
- *
- *********/
-
- void main(int argc,char *argv[])
- {
- struct MsgPort *ReplyPort;
- int num;
- char **vet,
- file[200],
- buffer[200];
-
-
- SetVar("PROJDIR","",-1,GVF_LOCAL_ONLY);
-
- if (!(RexxSysBase=OpenLibrary("rexxsyslib.library",0))) exit(5);
-
- if (!(ReplyPort=CreateMsgPort()))
- {
- CloseLibrary(RexxSysBase);
- exit(5);
- }
-
- SendRexxCommand("PED_AREXX","GUI LOCK",ReplyPort,buffer);
-
- SendRexxCommand("PED_AREXX","QUERY NUMPROJECTFILES",ReplyPort,buffer);
-
- num=atol(buffer);
-
- SendRexxCommand("PED_AREXX","QUERY ADDPROJECTFILES",ReplyPort,buffer);
-
- vet=(char **)atol(buffer);
-
- if (num>0) strcpy(file,vet[0]);
-
- SendRexxCommand("PED_AREXX","GUI UNLOCK",ReplyPort,buffer);
-
- DeleteMsgPort(ReplyPort);
-
- CloseLibrary(RexxSysBase);
-
- if (num<=0) exit(5);
-
- Split(file,buffer);
-
- SetVar("PROJDIR",buffer,-1,GVF_LOCAL_ONLY);
-
- exit(0);
- }
-