Kylix libraries for ncpfs

ncpfs API programming with Object Pascal under Linux

Purpose:

  • Being a Borland software afficionado since the old Turbo Pascal, I was pleased to discover that Kylix 3, aka Delphi 6 for Linux, was making possible to port to Linux most of the Netware oriented applications I wrote for my students in the past 10 years. The only 'missing part' was some importation units of ncpfs C oriented API to Borland Object Pascal.
  • the usage of external functions in shared libraries is well supported and well documented with Delphi/Kylix... so it was an easy task.
  • I know that it could have been even easier if I was using the C++ version of Kylix3, also freely available , but... I do not know C++ at all and I am getting too old to learn it. Somebody please stand up ;-).

    Requirements:

    Usage:

    Some real life examples:


  • Sample code as in the the password changing application:
    	uses nds5,nw5;
    	...
    	var 	NDS:tNDS;
    		Me:tNWUser;
    
    	NDS:=tNDS.create ;	// create an instance of tNDS against default tree
     	If NDS.Status <>0 then	// trouble ?
     		begin
            		ShowMessage(NDS.LastErrorMsg);
     		       Application.Terminate;
     		end;
     	Me:=tNwUser.Create(NDS,NDS.Me);	// create a tNwUser instance  from whoami on that tree
     	Label1.Caption:=Me.CN;		// display my NDS CN attribute
    	....
    	Button1.Enabled:=Me.CherchePeutChangerPassWord; // can I change my password ?
    	...
    	Me.Free;
    	NDS.Free;
    

  • sample basic API calls (nwwhoami.dpr in tests/nwwhoami directory) {$APPTYPE CONSOLE} uses SysUtils, ncplib, // for strnwerror nwcalls, // NWCallsInit (needed ?) nwnet,nwclient; // NDS API procedure Error (msg:string); begin writeln(msg); halt(1); end; type NDSString= array[0..MAX_DN_CHARS] of Char; var Cx:NWDSContextHandle; rC:NWDSCCODE; me:NDSString; myTree:NDSString; begin rC:=NWCallsInit(nil,nil); if rC <>0 then Error('NWCallInit Failed Err='+ strnwerror(rc)) ; rC :=NWCXGetPreferredDSTree(myTree,sizeof(myTree)); Writeln ('current NDS tree is '+myTree); if rC <>0 then Error('NWCXGetPreferredDSTree Failed Err='+ strnwerror(rc)) ; // reopen one of my permanent connections to that tree rC:=NWDSCreateContextHandleMnt(Cx,myTree); if rC <>0 then Error('NWDSCreateContextHandleMnt Failed Err='+strnwerror(rc)) ; rC:=NWDSWhoAmi(Cx,me); if rC <>0 then Error('NWDSWhoAmi failed Err='+strnwerror(rc)) else Writeln(me); rC:=NWDSFreeContext(Cx); if rC <>0 then Error('NWDSFreeContext failed='+strnwerror(rc)) ; end.

  • sample basic nwcalls API calls (nwconninfo.dpr in tests/nwconninfo directory)
    if Paramcount <1 Then Usage();
      myPermConn:=ParamStr(1);    // expect /path/to/a/permanent/connection
      rC:=ncp_open_mount(pChar(myPermConn),@conn);
      if rC <>0 then
            Error('ncp_open_mount Failed Err='+strnwerror(rc),true) ;
    
      rC:=NWCCGetConnInfo(conn,NWCC_INFO_TREE_NAME,sizeof(buffer),buffer);
      if rC <>0 then
            Error('NWCCGetConnInfo TREE_NAME Failed Err='+strnwerror(rc),false)
      else Writeln ('Tree name=',buffer);
    
      rC:=NWCCGetConnInfo(conn,NWCC_INFO_CONN_NUMBER,sizeof(number),number);
      if rC <>0 then
            Error('NWCCGetConnInfo CONN_NUMBER Failed Err='+strnwerror(rc),false)
      else Writeln ('Conn number=',number);
    
      rC:=NWCCGetConnInfo(conn,NWCC_INFO_USER_ID,sizeof(number),number);
      if rC <>0 then
            Error('NWCCGetConnInfo USER_ID Failed Err='+strnwerror(rc),false)
      else Writeln ('UserID=',format('0x%x',[number]));
    
      rC:=NWCCGetConnInfo(conn,NWCC_INFO_SERVER_NAME,sizeof(buffer),buffer);
      if rC <>0 then
            Error('NWCCGetConnInfo SERVER_NAME Failed Err='+strnwerror(rc),false)
      else Writeln ('Server name=',buffer);
    
        rC:=NWGetFileServerVersion(conn, @u16);
      if rC <>0 then
            Error('NWCCGetFileServerVersion Failed Err='+strnwerror(rc),false)
      else  Writeln ('File server version II=',format('%d.%d',[(u16 and $FF00)shr 8,u16 and $FF]));
    
        rC:=NWCCGetConnInfo(conn,NWCC_INFO_USER_NAME,sizeof(buffer),buffer);
      if rC <>0 then
            Error('NWCCGetConnInfo USER_NAME Failed Err='+strnwerror(rc),false)
      else Writeln ('User Name=',buffer);
    
    
      rC:=NWCCGetConnInfo(conn,NWCC_INFO_MOUNT_POINT,sizeof(buffer),buffer);
      if rC <>0 then
            Error('NWCCGetConnInfo MOUNT_POINT Failed Err='+strnwerror(rc),false)
      else Writeln ('Mount Point =',buffer);
      //place a breakpoint here and evaluate conn^,r
      rC:=NWCCCloseConn (conn);
      if rC <>0 then
         Error('NWCCloseConn Failed Err='+strnwerror(rc),true) ;
    end.
    

    Download:

    History:

    TODO:


    Vous êtes notre Counter (Security) eme visiteur