What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Sunil Kumar Sodanapal » Wed, 11 Jun 2003 02:18:58



Hello guys,
I wanted know If any one tried to convert some Windows Win32 function
calls like GetLastError(),GetFileAttributes(),GetCurrentDirectory(),CreateFile()....for
the Unix comatible.i.e to make them work the same way on Unix systems
also.I have a program with those Win32 functions need to be run on
Unix system.I don't want to go for any other Porting tools ...rather I
wanted to find the Win32 Equavalent functions that can be used on Unix
that do the same things, Win32 function does on Windows.
Any function on Unix same as GetLasterror()...Any function on Unix
same as CreateFile()....
Please reply
Sunil Kumar Sodanapalli


 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Martin Blum » Wed, 11 Jun 2003 02:38:39




Quote:> Hello guys,
> I wanted know If any one tried to convert some Windows Win32 function
> calls like

GetLastError(),GetFileAttributes(),GetCurrentDirectory(),CreateFile()....for
Quote:> the Unix comatible.i.e to make them work the same way on Unix systems
> also.I have a program with those Win32 functions need to be run on
> Unix system.I don't want to go for any other Porting tools ...rather I
> wanted to find the Win32 Equavalent functions that can be used on Unix
> that do the same things, Win32 function does on Windows.
> Any function on Unix same as GetLasterror()...Any function on Unix
> same as CreateFile()....

man -k error gives you (among others)
errno (3)            - number of last error
strerror (3)         - return string describing error code

A CreateFile "equivalent" would be, I guess, open or fopen.

In order to port your program, you can write a wrapper function that
emulates the Win function under UNIX.

Have a look at all the entries in the man page section 3. This is the
programmer's part.

HTH
Martin

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Grant Edwar » Wed, 11 Jun 2003 02:41:44



> calls like GetLastError()

errno
strerror(errno)

Quote:> GetFileAttributes()

stat()
fstat()
lstat()

Quote:> GetCurrentDirectory()

getcwd()
getwd()
get_current_dir_name()

Quote:> CreateFile()

open()

--
Grant Edwards                   grante             Yow!  ... If I had heart
                                  at               failure right now,
                               visi.com            I couldn't be a more
                                                   fortunate man!!

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Lew Pitch » Wed, 11 Jun 2003 02:40:04




Quote:>Hello guys,
>I wanted know If any one tried to convert some Windows Win32 function
>calls like
>GetLastError(),

 use global variable errno

Quote:>GetFileAttributes(),

 stat(2) or fstat(2)

Quote:>GetCurrentDirectory(),

 getcwd(3)

Quote:>CreateFile().

 creat(2) or fopen(3)

Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Robert Grizzar » Wed, 11 Jun 2003 10:40:54



Quote:> Hello guys,
> I wanted know If any one tried to convert some Windows Win32 function
> calls like GetLastError(),GetFileAttributes(),GetCurrentDirectory(),CreateFile()....for

Hello Sunil.

One neat thing about Linuxish OSs is that the manual is furnished.  If
you read of a system call or a utility you can read the manual page for
that function or utility and see for yourself how it's prototyped, what
it returns, and what it says when it errs out.  If that's not enough
information, you can actually read the code for the library functions
yourself and see what's going on.

Once you get back to your Linux box, type "man perror" and see if that's
what you're looking for as far as a GetLastError() equivalent.  If it's
not, "man -k foo" will give you a list of all the manual pages -- or, in
Linuxish parlance, "man pages" -- that deal with foo.  Since you're
looking for error messages, try "man -k error".  If that's a little more
about errors than you wanted to know, typing "man -k error | grep foo"
will tell you all the man pages that talk about errors *and* foo.  You
can learn more about grep by typing "man grep".

fstat() will tell you lots of things about the target file.  To find out
how to call it, type "man fstat" and read the man page that appears.

getpwd() will tell you your Present Working Directory.  man getpwd

There's two different ways to create a file.  If all you care about is
getting it opened, you can use the bog standard ANSI C fopen(), fead(),
fwrite(), fseek(), ftell(), and fclose().  If you need more control over
how you open your files, open() and its compatriots are what you want to
be using rather than fopen().

[...]

> same as CreateFile()....
> Please reply
> Sunil Kumar Sodanapalli



Ask in Usenet; answers in Usenet.  

HTH
--
The appearance of my E-mail address in any venue does not in and of itself
constitute a solicitation of bulk or commercial E-mail.

I don't want unsolicited commercial E-mail.

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Robert Grizzar » Wed, 11 Jun 2003 21:22:26


[...]

Quote:> getting it opened, you can use the bog standard ANSI C fopen(), fead(),

s/fead/fread/
--
The appearance of my E-mail address in any venue does not in and of itself
constitute a solicitation of bulk or commercial E-mail.

I don't want unsolicited commercial E-mail.

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Sunil Kumar Sodanapal » Thu, 12 Jun 2003 01:52:56


Thank You for all of You.Ok I decided to go through these Unix
compatriots.Can anyone tell me which is the best source to get good
documentation of these side by side like GetLastError() does what?? ||
compared to errno does what??
All the Win32 functions documentation can be got from MSDN help...But
for Unix functions errno,stat,fstat,getpwd...Which is the correct
source and is there any good site that has documentation for these??



> > Hello guys,
> > I wanted know If any one tried to convert some Windows Win32 function
> > calls like GetLastError(),GetFileAttributes(),GetCurrentDirectory(),CreateFile()....for

> Hello Sunil.

> One neat thing about Linuxish OSs is that the manual is furnished.  If
> you read of a system call or a utility you can read the manual page for
> that function or utility and see for yourself how it's prototyped, what
> it returns, and what it says when it errs out.  If that's not enough
> information, you can actually read the code for the library functions
> yourself and see what's going on.

> Once you get back to your Linux box, type "man perror" and see if that's
> what you're looking for as far as a GetLastError() equivalent.  If it's
> not, "man -k foo" will give you a list of all the manual pages -- or, in
> Linuxish parlance, "man pages" -- that deal with foo.  Since you're
> looking for error messages, try "man -k error".  If that's a little more
> about errors than you wanted to know, typing "man -k error | grep foo"
> will tell you all the man pages that talk about errors *and* foo.  You
> can learn more about grep by typing "man grep".

> fstat() will tell you lots of things about the target file.  To find out
> how to call it, type "man fstat" and read the man page that appears.

> getpwd() will tell you your Present Working Directory.  man getpwd

> There's two different ways to create a file.  If all you care about is
> getting it opened, you can use the bog standard ANSI C fopen(), fead(),
> fwrite(), fseek(), ftell(), and fclose().  If you need more control over
> how you open your files, open() and its compatriots are what you want to
> be using rather than fopen().

> [...]

> > same as CreateFile()....
> > Please reply
> > Sunil Kumar Sodanapalli


> Ask in Usenet; answers in Usenet.  

> HTH

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Andrew Taylo » Thu, 12 Jun 2003 03:40:21



> All the Win32 functions documentation can be got from MSDN help...But
> for Unix functions errno,stat,fstat,getpwd...Which is the correct
> source and is there any good site that has documentation for these??

There are two sources of information for these functions on most Linux
systems.

First, man pages.  They usually explain the what the function does, how
the function should be called, which header files should be included and
what return values it has.  Man pages are most useful when you know what
function you want to call, but need specifics on the parameters or
return values.

Second, the GNU libc manual.  This is usually provided in GNU info
format, which can be read with emacs ("M-x info") or the standalone info
program.  It can also be found online in HTML format here:
http://www.gnu.org/manual/.  The glibc manual groups the various
functions into functional groups and provides a better overview of how
the they are related.  For example, the section
http://www.gnu.org/manual/glibc-2.2.5/html_node/I-O-Overview.html#I%2...
explains how files are accessed, in answer to your original question on
CreateFile().

--
Andrew

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Robert Grizzar » Thu, 12 Jun 2003 11:47:29



Quote:> Thank You for all of You.Ok I decided to go through these Unix
> compatriots.Can anyone tell me which is the best source to get good
> documentation of these side by side like GetLastError() does what?? ||
> compared to errno does what??
> All the Win32 functions documentation can be got from MSDN help...But
> for Unix functions errno,stat,fstat,getpwd...Which is the correct
> source and is there any good site that has documentation for these??

There is lots of general Linux information at http://www.tldp.org;
unfortunately, I did not see the exact source to answer your questions.
There is a Linux programmer's guide, but it's from the last century.

I would hazard a guess that GetLastError() retreives the last error.
errno() is the specific error number of that last error.  You can save
it -- lastError = errno, as an example, -- then feed it to strerror for
a printout of what that last error was.  "printf ("%s", strerror
(lastError))" is probably close enough to do Something Interesting.

As far as a Windows => Linux glossary, I am unaware of any such beast.
If you know what the extant Windows function deals with -- like
GetLastError() would presumably deal with the last error that the
running program had -- you can type "man -k error | grep last" and see
the answer "errno  (3) - number of last error" pop up.  From there, type
"man errno" to find out that it's the number of the last error, that you
need to include <errno.h> to use it, that it's an int (which BTW is 32
bits on a Linux system; if you need 16-bit numbers you'll have to change
them to shorts), and that you can read the man pages for perror() and
strerror() to learn a little more about error reporting.

stat() takes a file name and a pointer to the stat struct; fstat() takes
a file descriptor and a pointer.  To use fstat() you'll need to use
open() first.  man stat  man fstat  man open  man fopen

getpwd -- oops; looks like I lied to you.  Try "getcwd" instead.  You'll
definitely want to read the man page for that; there are some
interesting things the POSIX flavor does.

HTH
--
The appearance of my E-mail address in any venue does not in and of itself
constitute a solicitation of bulk or commercial E-mail.

I don't want unsolicited commercial E-mail.

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Christopher Brown » Thu, 12 Jun 2003 14:52:37



Quote:> Thank You for all of You.Ok I decided to go through these Unix
> compatriots.Can anyone tell me which is the best source to get good
> documentation of these side by side like GetLastError() does what?? ||
> compared to errno does what??
> All the Win32 functions documentation can be got from MSDN help...But
> for Unix functions errno,stat,fstat,getpwd...Which is the correct
> source and is there any good site that has documentation for these??

The two typical sources of comprehensive information are:
 a) Manual pages for the library functions, and
 b) The GLIBC Info documents.

There's no "side by side" information; that would presumably be
something that Microsoft would be responsible for providing, seeing as
how it is they that have made up function sets that deviate so
dramatically from the POSIX and ANSI standards.
--

http://cbbrowne.com/info/x.html
Signs of a Klingon Programmer #11: "This machine is a piece of GAGH! I
need dual Pentium processors if I am to do battle with this code!"

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by David M. Coo » Fri, 13 Jun 2003 15:02:58




> wanted to find the Win32 Equavalent functions that can be used on Unix
> that do the same things, Win32 function does on Windows.

info libc

should get you started.  There's also a good book on the web:

http://www.advancedlinuxprogramming.com

And a whole bunch of other good books on the subject

Beginning Linux Programming
Linux Application Development
Advanced Programming in the Unix Environment (the classic and still a model
of clarity)

Dave Cook

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Sunil Kumar Sodanapal » Sun, 15 Jun 2003 01:58:12


Hey guys Thanks Lot.I decided to write wrapper functions for all those
Win32 guys.i.e I will declare my own GetCurrentDirecory() wrapper
function for Unix and I will return whatever my program expects from
such win32 function on Windows.Inside that wrapper function I will
call all the Unix functions to do the work of getting the current
directory.This wrapper functions comes into play only on Unix
platforms but not on Windows.Now I ask you all if anyone has done this
before .....if "Yes" can you supply the code snippets for other Win32
functions like GetFileAttributes,GetLastError,SetFilePointer,CreateFile,CloseHandle,WriteFile,
ReadFile..Or send me links to sites that have them online.That wud be
great
Sunil




> > wanted to find the Win32 Equavalent functions that can be used on Unix
> > that do the same things, Win32 function does on Windows.

> info libc

> should get you started.  There's also a good book on the web:

> http://www.advancedlinuxprogramming.com

> And a whole bunch of other good books on the subject

> Beginning Linux Programming
> Linux Application Development
> Advanced Programming in the Unix Environment (the classic and still a model
> of clarity)

> Dave Cook

 
 
 

What are Unix Equavalents for Windows Platfor SDK calls(Win32 functions)

Post by Venka » Thu, 19 Jun 2003 00:23:56


Sunil,
You can even try this site http://www.lfbs.rwth-aachen.de/nt2unix/

nt2unix is a separate project altogether, the project aims at implementing
all
the win32 API in unix(supports all flavours of unix like solaris, linux).
The files are freely downloadable and you can customize files as per ur
requirements.

Regards
Venkat



Quote:> Hey guys Thanks Lot.I decided to write wrapper functions for all those
> Win32 guys.i.e I will declare my own GetCurrentDirecory() wrapper
> function for Unix and I will return whatever my program expects from
> such win32 function on Windows.Inside that wrapper function I will
> call all the Unix functions to do the work of getting the current
> directory.This wrapper functions comes into play only on Unix
> platforms but not on Windows.Now I ask you all if anyone has done this
> before .....if "Yes" can you supply the code snippets for other Win32
> functions like

GetFileAttributes,GetLastError,SetFilePointer,CreateFile,CloseHandle,WriteFi
le,
> ReadFile..Or send me links to sites that have them online.That wud be
> great
> Sunil






> > > wanted to find the Win32 Equavalent functions that can be used on Unix
> > > that do the same things, Win32 function does on Windows.

> > info libc

> > should get you started.  There's also a good book on the web:

> > http://www.advancedlinuxprogramming.com

> > And a whole bunch of other good books on the subject

> > Beginning Linux Programming
> > Linux Application Development
> > Advanced Programming in the Unix Environment (the classic and still a
model
> > of clarity)

> > Dave Cook

 
 
 

1. how to know the instruction address of calling function within called function?

Suppose function A call B, are there any ways to know the address of last instruction in A just
before calling B from within B? I would like to do some profiling by substituting B by a routine with record
the time spent on B. I also would like to know the time spent on B in different locations of A
where B is called. If I can know the address of last instruction in A just before calling B, from
debuging info of the excutables, I can find its source code address, therefore know the
time spent on B in differnet locations of A.

I don't want to make any changes to A. "-pg" compiler option for profiling is of no use either,
because there is no source code for B, and there is no object code for B with profiling codes in,
so you can't know the total time spent on B, but only the self time spent on B.

Thanks very much.
--



Kingston, Ontario K7L 3N6        Tel: (613) 545-2723 (o)
Canada                           Fax: (613) 545-6463
Home address:
58 1/2 Chatham St.               Tel: (613) 547-1353 (h)
Kingston, ON K7K 4G8

2. pmd problem ?!?!

3. Browser calls CGI C function which sets an env var and call a c function crashes

4. corba script: was "I wish Linux.."

5. linux/Unix System Call vs Win32 API

6. xview

7. Unix equavalent of MVS GDG

8. Large file support in STABLE

9. Call function within a function

10. Tree of Functions calling Functions etc.

11. Main function calling another main function

12. Non-__init functions calling __init functions

13. Name of the function/script that called the actual function?