[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

EXPORT, IMPORT and FTPAPI



Happy weekend, everyone!

I'm working on the task of separating FTPAPI into modules on a V5R3 machine.
(No promises yet; it's still early. ;) )  I got everything to compile and it
looks well but I've run across an unexpected result.

Basically, I had to create a new header file that's exclusive to the
internal operation (so that, for example, wkSession may be shared among its
peers).  When compiling one module, wkSession must be defined; when
compiling any others, it must be imported.  And of course we cannot specify
INZ on an imported field, so basically the definition looks like this:

D wkSessionIdx    S             10I 0                     
 /If DEFINED(FTPAPI_INTERNAL_FUNCTIONS)                   
D                                     Export Inz(INT_NULL)
 /Else                                                    
D                                     Import              
 /EndIF                                                   

< ... >

D wkSession       DS                  occurs(MAX_SESSION)
 /If DEFINED(FTPAPI_INTERNAL_FUNCTIONS)                  
D                                     Export             
 /Else                                                   
D                                     Import             
 /EndIF                                                  
D  wkActive                      1                       
 /If DEFINED(FTPAPI_INTERNAL_FUNCTIONS)                  
D                                     Inz(*OFF)          
 /EndIF                                                  
------------- 8 data records excluded -------------------
D  wkErrNum                     10I 0                    
 /If DEFINED(FTPAPI_INTERNAL_FUNCTIONS)                  
D                                     Inz                
 /EndIF                                                  
D  wkSocket                     10I 0                    
 /If DEFINED(FTPAPI_INTERNAL_FUNCTIONS)                  
D                                     Inz(INT_NULL)      
 /EndIF                                                  

The other thing you need to know for my question is that there's an
FTPAPIINT and an FTPAPIEXT module.  It's not beautiful but it does compile.
If you have other suggestions, I'm wide open.  :)   But the unexpected
effect is that within FTPAPIINT (which is compiled with
FTPAPI_INTERNAL_FUNCTIONS set) everything is fine.  But it appears as though
FTPAPIEXT (which lacks the DEFINE for FTPAPI_INTERNAL_FUNCTIONS) has its own
copy, since changes to (in this case) wkSocket within FTPAPIINT don't seem
to have an effect on wkSocket as referenced in FTPAPIEXT.

So is my thinking off base here?  Shouldn't there be exactly one copy of
wkSession, and shouldn't it be shared?  If there were two copies, then the
CRTSRVPGM command would fail, right?

When this code executes
c                   if        selectSession(peSession) < 0       
c                   callp     SetSessionError                    
c                   return    -1                                 
c                   endif                                        
                                                                 
c                   if        peNewDir = '..'                    
c                   if        SendLine(wkSocket: 'CDUP') < 0     
c                   return    -1                                 
c                   endif                                        
c                   else                                         
c                   if        SendLine(wkSocket: 'CWD '+peNewDir)

In debug mode, I can see that within selectSession(), wkSocket has a value
of 4 upon its return.  But FTP_chdir() disagrees, having a value of -99 for
wkSocket, which we can see above should be an imported variable by virtue of
the DS import.

What might cause this effect?

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"Nature gave man two ends - one to sit on and one to think with. Ever since
then man's success or failure has been dependent on the one he used most."
        -- George R. Kirkpatrick 

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------