C / REXX problem



Help for C/C++ for MVS, OS/390 C/C++, z/OS C/C++ and C/C++ Productivity Tools for OS/390

C / REXX problem

Postby jibbly » Fri Feb 25, 2011 12:06 pm

Hi,

i have mostly finished a script/program in which i made a small rexx script that checks its OS if its in TSO it does one thing if its in linux it does another.
which works fine however the code to run when its in linux is a call to a c function. i had this element working in a windows environment compiling the c code with TCC.
however when i move it over to linux the c code will compile fine with gcc( -pedantic -Wall -std-C99 e.t.c) but wont with TCC
the main problem is that the REXX script no longer communicates with the c function it says it can't find testfunc. testfunc.c
if anyone could tell me why this could be happening that would be greatly appreciated. is there something i should be doing that windows has gone and done automatically ?


example code.

/**REXX**/                                                   
SAY ' PLEASE ENTER A CONSOLE NAME '                                   
PULL INPUT                                                   
                                                                                     
   ostype = address()
   say ostype                                                         
                                                             
IF ostype = 'TSO' THEN DO                                           
  /*STUFF*/                                                                                         
END                                                           
ELSE IF ostype = 'COMMAND'| ostype = 'SYSTEM' THEN DO   
                                   
   /*call testfunc "testfunc"*/
   pull INPUT
   out=testfunc(filename)
   say out  /* output from c code */
   say rc   /* return value from c code */
END                                                   

this works on windows with tcc
and this is the c code it calls

#define MAX_SIZE 80
int check();//char input);

void exec_it(char* execname);


APIRET APIENTRY RexxRegisterFunctionExe(testfunc,testfunc);


/*APIRET APIENTRY RexxPullQueue(

PSZ QueueName,

PRXSTRING DataBuf,

PDATETIME TimeStamp,

ULONG WaitFlag

) ;
*/


int main(int argc, char *argv[])
{


    printf("argc is %d\n",argc);

    //printf("the first argument is %s \nthe second is |%s|\n", argv[0],argv[1]);   
    char input[100];

        check(argv[1]);
   
    exec_it(argv[1]);

    return 59;
}



int check ()//char input)
{

  //read file into array and search it
}

/*  Function to start rdesktop application */

void exec_it(char* execname)
{

//check if process running
//run process

}



the error i get is
sh: TESTFUNC: not found


any help very much appreciated :)
jibbly
 
Posts: 8
Joined: Mon Feb 14, 2011 1:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: C / REXX problem

Postby enrico-sorichetti » Sat Feb 26, 2011 12:59 am

the issue is not yet c related!
did You read the rexx docs on how to use external functions?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: C / REXX problem

Postby jibbly » Mon Feb 28, 2011 10:14 am

your right haha cant believe i over looked case sensitivity i even thought about it.

ok it can see it now but once it calls it i get these random errors

Image

i am sure i have no "/*" or mis matched double quotes anywhere in either files
(i went and deleted all my comments in both files to make sure
jibbly
 
Posts: 8
Joined: Mon Feb 14, 2011 1:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: C / REXX problem

Postby dick scherrer » Mon Feb 28, 2011 11:31 am

Hello,

i am sure i have no "/*" or mis matched double quotes anywhere in either files
If the system has problems with them, they are there somewhere. . . The system will not "make them up".

Any chance the code being executed is not the code intended?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: C / REXX problem

Postby jibbly » Mon Feb 28, 2011 1:09 pm

finally got it thanks for the help it wanted two sets of quotes around the function being called :)

e.g. CALL "' function '" input
jibbly
 
Posts: 8
Joined: Mon Feb 14, 2011 1:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: C / REXX problem

Postby enrico-sorichetti » Mon Feb 28, 2011 1:47 pm

the issue is the wrong understanding of rexx workings...
and the TS not reading the REXX docs

when using ...
someresult = somefunction(arg1,arg2,...,argn)

REXX expects/pretends to follow the rules of REXX external functions

call RxFuncAdd 'SysLoadFuncs', 'userDLL(*)', 'LoadUserFuncs'
call LoadUserfuncs
... code using the functions previously loaded
call DropUserFuncs

where LoadUserfuncs will make available to the rexx script the function inside the userDLL
and they can be called using the above said sequence

now ...
without following the above rule
someresult = somefunction(arg1,arg2,...,argn)
will return ... an error

but
someresult = "somefunction"(arg1,arg2,...,argn)
the function invoked will be treated as a shell command completely unrelated to rexx
and unaware of the rexx environment
and if somefunction is properly written whatever it writes to stdout will be returned in someresult
like in
filelist = "ls"("*")
where filelist will contain what will be displayed by a plain ls *

but the last way of proceeding is supported or better tolerated only by
regina rexx and brexx
and it is not rexx standard compliant


(*) DLL generic for Dynamic Load Library...
.DLL for windows
.so for linux alike
.dylib for mac osx
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: C / REXX problem

Postby jibbly » Tue Mar 01, 2011 6:50 am

that explains allot!! thanks
jibbly
 
Posts: 8
Joined: Mon Feb 14, 2011 1:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: C / REXX problem

Postby dick scherrer » Tue Mar 01, 2011 9:01 am

Good to hear it is working - thank you for letting us know :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to C, C++

 


  • Related topics
    Replies
    Views
    Last post