delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/27/09:34:01

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: swamp-dog AT ntlworld DOT com (Guy Harrison)
To: <cygwin AT cygwin DOT com>
Subject: Re: accessing cygwin functions from non-cygwin app
Date: Wed, 27 Nov 2002 14:33:11 GMT
Message-ID: <3de9a8bd.525989212@smtp.ntlworld.com>
References: <sde35758 DOT 064 AT cpl-emea-mail1 DOT cpl DOT novell DOT com>
In-Reply-To: <sde35758.064@cpl-emea-mail1.cpl.novell.com>
MIME-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id gAREY1h08402

On Tue, 26 Nov 2002 11:13:20 +0100, "Jan Beulich" <JBeulich AT novell DOT com>
wrote:

>Hello,
>
>while I was trying to understand this on my own I'm ready to give up. All
>I intended was translating a coupld of filenames from cygwin to Win32 notation
>in an otherwise Win32-only app. I quickly realized that cygwin1.dll does not
>do all the necessary initialization on its own, i.e. from DllMain. Instead it
>appears that I am expected to explicitly call one or more functions inside the
>DLL to perform thisinitialization. However, whatever I tried (dll_crt0,
>dll_dllcrt0) didn't work (i.e. crashed due to insufficient prior initialization),
>but cygwin_attach_dll is neither exported from the DLL nor would it, from its
>use inside the sources, appear to be meant for the case I'm dealing with
>(where a main executaböle directly attaches to cygwin1.dll). And even if
>this is the function to use, then I have a problem using it as the application
>cannot be expected to have access to the perprocess class (nor is the app a
>C++ app, and neither is it being built with gcc) or other cygwin sources, and
>it also cannot link against libcygwin.a.
>Any advice on what I am missing here in this as I originally thought simple
>scenario would be very welcome - thank you in advance!

You need "cygpath". You have system(). You know the full path to
cygwin1.dll (either you supplied it or via ::GetModuleFileName or
registry mount "/") so can replace the explicit path in the crude
example below with the proper one...

int
main(int argc, char *argv[])
{const char sfx[]   ="j:/cygwin/bin/cygpath -wa ";
 char       cmd     [MAX_PATH + sizeof(sfx) + 1];

 if (argc < 2)
    return EXIT_FAILURE
 ;
 sprintf(cmd,"%s%s",sfx,argv[1]);
 system(cmd);
 return EXIT_SUCCESS; //ahem
}

...you'd probably want to programatically prefix your "j:/cygwin/bin" to
PATH prior to system(). If you go via the '-e' option of bash/sh then
you'd be able to use a wrapper script to convert more than one at once
or call your own cygwin app that invokes the relevent functions
directly.


-- 
swamp-dog AT ntlworld DOT com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019