Linux-Development-Apps Digest #348, Volume #7    Fri, 20 Apr 01 11:13:14 EDT

Contents:
  Re: where am i? ("Wong Ka Chun")
  Re: Passing Parameters to a (library) function (Hartmann Schaffer)
  Re: Database client libraries with multi-DB engine support? (Victor Wagner)
  Question about opengatekeeper ("ÀÌÈñÁ¤")
  why some processes are defunct? (Zhen Yao)
  Need very simple GUI (wroot)
  Hello,there. ("somez72")
  Re: printf output dissapears in mid-program (Zhen Yao)
  Re: why some processes are defunct? ("Arthur H. Gold")
  Re: why some processes are defunct? (Zhen Yao)
  Re: Passing Parameters to a (library) function (Markus Hoffmann)
  Modem and DSL (Simonz)
  Re: why some processes are defunct? (Michael Kerrisk)
  Re: Dynamic loading ("Nico")
  Re: Passing Parameters to a (library) function ("Frank V. Castellucci")
  Re: Hello,there. (Rolf Magnus)
  Re: Modem and DSL (Chris)
  RE:Re: vi-how do i limit user input to one character? (Erdos0)
  Re: Porting from Window to Linux ... C++ programming  problem ("Karim A.")

----------------------------------------------------------------------------

From: "Wong Ka Chun" <[EMAIL PROTECTED]>
Subject: Re: where am i?
Date: Fri, 20 Apr 2001 09:39:55 +0800

Hi Lew,

  Your guess is correct, I need to verify some checksum which is burnt at
the end of the executable and also, the program will launch a shell script,
and the shell script will call this program again to request for some values
from the program. That is why I need to know the exact location of the
executable, otherwise, the script does not know where is the program to
call.

- Wong

"Lew Pitcher" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...


>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 4/17/01, 7:33:21 AM, "Wong Ka Chun" <[EMAIL PROTECTED]> wrote
regarding where am i?:


> Hello,

Hello

>   I have a C program that wants to know where itself is located in the
file
> system. Is there any system call can do it?

The other posts to your question discuss _how_ to locate your executing
binary, but I'd like to discus _why_ you want to locate your executing
binary.

Unless you have a specific reason to open the binary (i.e. read the
binary to confirm a checksum), then you probably _don't_ need the path to
the binary. I'll bet that you are trying to do something like locate the
binary so that you can locate it's associated initialization file. If so,
then you are taking the wrong approach to the problem, and need to
rethink.

The usual Linux (Unix) way to do _this_ sort of thing is to use
application-selected files in well-known directories. For example, global
or default initialization parameters are kept in files in the /etc
directory hierarchy while per-user initialization parameters are kept in
files in the user's home directory hierarchy ($HOME/).

Is this the sort of problem you are trying to solve?

--
Lew Pitcher
Master Codewright and JOAT-in-training




------------------------------

From: [EMAIL PROTECTED] (Hartmann Schaffer)
Subject: Re: Passing Parameters to a (library) function
Date: 19 Apr 2001 21:48:31 -0400

In article <[EMAIL PROTECTED]>, Peter T. Breuer wrote:
>Rolf Magnus <[EMAIL PROTECTED]> wrote:
>> Markus Hoffmann wrote:
>
>>> Hi, I want to pass an unknown number of Parameters to a function.
>>> (using the gcc c compiler)
>>> The Problem is, the Number of Parameters is not known at compile time.
>
>> That's not possible, at least not without some ugly tricks that only work 
>
>It certainly is possible. That's the entire point of the ansi stdargs.h
>interface.

it is only possible for functions that are compiled including varargs.h,
and usually even then not for all arguments.  the request was formulated
that markus didn't want to touch the library functions

> ...

-- 

hs

================================================================

"The cheapest pride is national pride.  I demonstrates the lack of
characteristics and achievements you can be proud of.  The worst loser
can have national pride"  - Schopenhauer

------------------------------

From: [EMAIL PROTECTED] (Victor Wagner)
Subject: Re: Database client libraries with multi-DB engine support?
Date: 20 Apr 2001 01:49:14 +0400

 Carlos Moreno <[EMAIL PROTECTED]> wrote:
 
 : Hi there,
 
 : I'm not sure that my subject line was clear enough, but 
 : I don't know what the right terminology would be. 
 
 : In any case, what I'm looking for (wondering if there is) 
 : is a C++ library (preferably open source) that allows me 
 : to develop applications that use databases, being able to 
 : connect to PostgreSQL, mySQL, or other database engines. 

Consider changing a language. Perl has excellent DBI library,
which does exactly what you want. Python has some uniform
DB libraries as well, (as the part of zope project, I suppose).

Python also has leaner and cleaner OOP than C++.

There is also Java which popularity I just cannot understand,
given the monstruosity of available implementations.
It has JDBC.

 : and then, without modifying my code (other than, maybe, 
 : redefining a constant), I simply compile linking with 
 : libpq++ for PostgreSQL, or compile it linking with the 

Runtime. That is it. You just execute your code with
other arguments (or even make it display menu of available
data source) and it dynamically loads neccessary libraries.
That is how DBI works.
 
 : My main two targets are PostgreSQL and mySQL -- I'm not 
 : particularly worried about Oracle, or even ODBC.

You completely misunderstand concept of ODBC. It is not a database,
it is that very library you want.
(something more than library to be honest - specification of
"database driver" standard and implementations thereof)
For instance today I've compilied PostgreSQL 7.1, and it have
produced ODBC drivers among other things. I think MySQL has ones
too. 
 
-- 
I suppose one could claim that an undocumented feature has no
semantics.  :-(
             -- Larry Wall in <[EMAIL PROTECTED]>

------------------------------

From: "ÀÌÈñÁ¤" <[EMAIL PROTECTED]>
Subject: Question about opengatekeeper
Date: Fri, 20 Apr 2001 11:36:07 +0900

Hi there!
I succeeded in compiling and calling under
opengatekeeper.

Now, I want to control the endpoint(ip phone).
I mean, only registered phone is able to call through
the gatekeeper.
How can I do  it?
Should I change the source?

Thanks in advance.



--
  Heejeong Lee
  Multimedia Technology LAB. Kora Telecom
  Phone: 82-2-526-6431
  E-mail: [EMAIL PROTECTED]    Web     : www.ideasale.co.kr



------------------------------

From: Zhen Yao <[EMAIL PROTECTED]>
Subject: why some processes are defunct?
Date: Fri, 20 Apr 2001 05:31:45 +0100


i wrote a server, it forks when meets a connection, but the forked process
does not exit, but left a defunct process, why?

thanks in advance.

regards
nick

/***************************************
 * Nick Yao ---- 1st Year CS           *
 * www.dcs.warwick.ac.uk/~csvhe        *
 ***************************************/


------------------------------

From: wroot <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.c++,comp.unix.programmer,comp.windows.ms.programmer
Subject: Need very simple GUI
Date: Fri, 20 Apr 2001 01:06:17 -0400

Hi,

I'm a C++ programmer and I usually stick with pure ANSI C++, but I need to 
write a simple GUI, where a user could enter a few numbers in the dialog, 
move a couple of scroll bars and click some buttons.

I'm wondering if there were any really simple free (Open Source) tools for 
doing this? I would prefer if they were cross-platform, but I absolutely 
need them to work under Linux.

I was programming an NMR spectrometer once. Its proprietary C-like language 
had functions like GETINTEGER(char*, int&). Doing
        int m = 123;
        GETINTEGER("Enter Integer m: ", m);
resulted in the user being prompted with a box displaying "     123", where 
he could enter any integer instead.

I'm looking for something as simple as that.

Thanks in advance.

Wroot

P.S. Please resist your desire to remind me of "cin" :-)

------------------------------

From: "somez72" <[EMAIL PROTECTED]>
Subject: Hello,there.
Date: Fri, 20 Apr 2001 15:17:39 -0700

Hello,
does Someone knows is there System Monitoring and System Management tools
that is running on Linux for Linux/Unix server , Oracle server , Web server
, and so on.

Where can I find it?
any information is good to me, please tell me.

I don't know where should I wirte down this kind of question.
is there good place to ask this question , please let me know.

Thank you for your time.
-- somez72 --





------------------------------

From: Zhen Yao <[EMAIL PROTECTED]>
Subject: Re: printf output dissapears in mid-program
Date: Fri, 20 Apr 2001 06:16:24 +0100


linux uses line buffering for standard output.  your programs output will
be stored in a 4k buffer first if it is not end by \n. if the buffer is
full, or your program exits normally, the output will appear.
if you want it to be displayed instantly, you should add
fflush(stdout);  immediately after printf. or you can change the
stream buffering mode via function setvbuf.


On Sun, 15 Apr 2001, Ofer E wrote:

> Hi Folks,
> 
> I'm working on a software project where we
> don't have a debugger for the target machine,
> so we use printf's to track what's going on.
> 
> We now have a problem with printf calls.
> It seems after about a dozen previous calls,
> printf commands does not appear in stdout.
> The code itself is still running OK, but no
> printf output.
> We commented the area of code where this
> problem begins, and the problem simply
> moves to the next statement.
> 
> We still have printk calls coming through with
> no problem.
> 
> Does anyone have any idea where to start
> investigating this?
> 
> 
> 
> Thanks in advance,
> 
> 
> Ofer
> 
> 
> 

/***************************************
 * Nick Yao ---- 1st Year CS           *
 * www.dcs.warwick.ac.uk/~csvhe        *
 ***************************************/


------------------------------

Date: Fri, 20 Apr 2001 00:39:19 -0500
From: "Arthur H. Gold" <[EMAIL PROTECTED]>
Subject: Re: why some processes are defunct?

Zhen Yao wrote:
> 
> i wrote a server, it forks when meets a connection, but the forked process
> does not exit, but left a defunct process, why?
> 
Because it was not reaped by its parent (`man wait' `man
waitpid').

HTH,
--ag

-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account
for more info)
mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
--
Clone Bernie!

------------------------------

From: Zhen Yao <[EMAIL PROTECTED]>
Subject: Re: why some processes are defunct?
Date: Fri, 20 Apr 2001 07:45:03 +0100


hi thanks.

Do I have to let the parent wait? 'cause the parent process should go and
handle the next connection.

thanks.


On Fri, 20 Apr 2001, Arthur H. Gold wrote:

> Zhen Yao wrote:
> > 
> > i wrote a server, it forks when meets a connection, but the forked process
> > does not exit, but left a defunct process, why?
> > 
> Because it was not reaped by its parent (`man wait' `man
> waitpid').
> 
> HTH,
> --ag
> 
> -- 
> Artie Gold, Austin, TX  (finger the cs.utexas.edu account
> for more info)
> mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
> --
> Clone Bernie!
> 

/***************************************
 * Nick Yao ---- 1st Year CS           *
 * www.dcs.warwick.ac.uk/~csvhe        *
 ***************************************/


------------------------------

From: Markus Hoffmann <[EMAIL PROTECTED]>
Subject: Re: Passing Parameters to a (library) function
Date: Fri, 20 Apr 2001 09:40:44 +0200

>   But does it always? You're assuming that by passing the args in a struct,
> they'll get laid out on the stack the same way as if they were passed
> individually. On MIPS processors, the first four arguments are expected to be
> in registers, not on the stack. So READLINE will look in register a0 for the
> prompt, not on the stack where you've just forced it to be.

Hm, you are right. There is also another Problem: The word-length for
parameters my be different from sizeof(int) (DEC alpha behaves like that:
sizeof(int)=4, but each Parameter takes 8 Bytes (=sizeof(double))).

Which machines have MIPS processors ? If one could find out (config.guess)
one could disable that feature or write a different routine.

I could write a test-routine which calls itself and analyses the parameter
passed. Then setup some flags. How many different architectures are out
there ?

regards
M.



------------------------------

From: Simonz <[EMAIL PROTECTED]>
Subject: Modem and DSL
Date: Fri, 20 Apr 2001 15:38:11 +0700

Hi there,

I have a Modem (phone line) and DSL. I want to use DSL mainly and Modem
as a connection when DSL fail. How can I do this using C (I want to
place in cron) to check the connection of my DSL (and
Modem)? and how can I start my modem (and DSL) from C program?

----
 ps
----
/* */


------------------------------

From: [EMAIL PROTECTED] (Michael Kerrisk)
Subject: Re: why some processes are defunct?
Date: Fri, 20 Apr 2001 08:45:45 GMT

On Fri, 20 Apr 2001 07:45:03 +0100, Zhen Yao <[EMAIL PROTECTED]>
wrote:

>
>hi thanks.
>
>Do I have to let the parent wait? 'cause the parent process should go and
>handle the next connection.

Do the wait() or waitpid() call from a handler for the SIGCHLD signal
- you'll need to write and establish this handler.  This is almost
certainly in the FAQ, and also in any Unix programming book.

Cheers

Michael

>On Fri, 20 Apr 2001, Arthur H. Gold wrote:
>
>> Zhen Yao wrote:
>> > 
>> > i wrote a server, it forks when meets a connection, but the forked process
>> > does not exit, but left a defunct process, why?
>> > 
>> Because it was not reaped by its parent (`man wait' `man
>> waitpid').
>> 
>> HTH,
>> --ag
>> 
>> -- 
>> Artie Gold, Austin, TX  (finger the cs.utexas.edu account
>> for more info)
>> mailto:[EMAIL PROTECTED] or mailto:[EMAIL PROTECTED]
>> --
>> Clone Bernie!
>> 
>
>/***************************************
> * Nick Yao ---- 1st Year CS           *
> * www.dcs.warwick.ac.uk/~csvhe        *
> ***************************************/
>


------------------------------

From: "Nico" <[EMAIL PROTECTED]>
Subject: Re: Dynamic loading
Date: Fri, 20 Apr 2001 11:26:58 +0200
Reply-To: "Nico" <[EMAIL PROTECTED]>


"Arinté" <[EMAIL PROTECTED]> a écrit dans le message news:
0wBD6.662$[EMAIL PROTECTED]
> Does linux have a way for an app to dynamically load/unload a library?  If
> so how do I go about build the library and how would an app load it?

Yes Linux as this ability, it is done by using ld.


> thanx
>
> windows has dll that are load with LoadLibrary and FreeLibrary, what are
> linux equivalents?


the aquivalents would be dlopen & dlclose,
man dlopen
man dlclose would give you all the important stuff you need.
I use that to load modules for my project :) it is a cool stuff, if your are
doing an app using gtk, there are wrappers to this function that as i
remember are: module_open and module_close, not sure .



------------------------------

Date: Fri, 20 Apr 2001 06:12:05 -0400
From: "Frank V. Castellucci" <[EMAIL PROTECTED]>
Subject: Re: Passing Parameters to a (library) function

Markus Hoffmann wrote:
> 
> >   But does it always? You're assuming that by passing the args in a struct,
> > they'll get laid out on the stack the same way as if they were passed
> > individually. On MIPS processors, the first four arguments are expected to be
> > in registers, not on the stack. So READLINE will look in register a0 for the
> > prompt, not on the stack where you've just forced it to be.
> 
> Hm, you are right. There is also another Problem: The word-length for
> parameters my be different from sizeof(int) (DEC alpha behaves like that:
> sizeof(int)=4, but each Parameter takes 8 Bytes (=sizeof(double))).
> 
> Which machines have MIPS processors ? If one could find out (config.guess)
> one could disable that feature or write a different routine.
> 
> I could write a test-routine which calls itself and analyses the parameter
> passed. Then setup some flags. How many different architectures are out
> there ?
> 
> regards
> M.

I will leave it that you should leverage the tools that are probably
just sitting in your environment. Recreate the wheel at your own peril
:)

Take the hassle out of all this by emitting C code, compile, load, run

-- 
Frank V. Castellucci
http://corelinux.sourceforge.net
OOA/OOD/C++ Standards and Guidelines for Linux

------------------------------

From: Rolf Magnus <[EMAIL PROTECTED]>
Subject: Re: Hello,there.
Date: Fri, 20 Apr 2001 13:42:30 +0200

Please choose a more useful subject the next time.

somez72 wrote:

> Hello,
> does Someone knows is there System Monitoring and System Management tools
> that is running on Linux for Linux/Unix server , Oracle server , Web
> server , and so on.

Try webmin.

> Where can I find it?
> any information is good to me, please tell me.

Search for it on www.freshmeat.net

> I don't know where should I wirte down this kind of question.
> is there good place to ask this question , please let me know.

No. This place is for discussions about developing linux applications, not 
administration. What's wrong with comp.os.linux.admin?

------------------------------

From: Chris <[EMAIL PROTECTED]>
Subject: Re: Modem and DSL
Date: Fri, 20 Apr 2001 12:43:47 +0100

Simonz wrote:
> 
> Hi there,
> 
> I have a Modem (phone line) and DSL. I want to use DSL mainly and Modem
> as a connection when DSL fail. How can I do this using C (I want to
> place in cron) to check the connection of my DSL (and
> Modem)? and how can I start my modem (and DSL) from C program?

This is a close-to-trivial problem to solve with shell scripts.

man ping and man pppd; pay attention to the section on return
codes.

-- 
Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/
 Democracy is... the worship of jackals by jackasses (Mencken)

------------------------------

From: [EMAIL PROTECTED] (Erdos0)
Date: 20 Apr 2001 12:57:34 GMT
Subject: RE:Re: vi-how do i limit user input to one character?

Thank you Thank You Thank You!
Kim


|From: "Marcello Botrugno" [EMAIL PROTECTED] 
|Date: 4/19/01 1:07 PM !!!First Boot!!!
|Message-id: <[EMAIL PROTECTED]>
|
|You can process the value of $input:
|if [ "$input" ]; then
|    input=`echo $input | cut -b 1`
|fi

------------------------------

From: "Karim A." <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system
Subject: Re: Porting from Window to Linux ... C++ programming  problem
Date: Fri, 20 Apr 2001 16:59:36 +0200

Hi Shang,

I've alredy ported an application from Windows to Linux and SGI Irix env.
I think I've encountered every kind of problem regarding cross-platform
devpt.

I can give some tips:

Firstly, separate all the GUI part from your engine "working"' code.


1) Use "standard" components such like std library as most as you can.
My Windows application used a lot of MFC"helper" stuff such like CString,
CTime, etc....
Forget them, don't loose time to search for a CString like class on the web.
I've used the "string" class of the STL. You can derive it so to add some
helper function like Format etc...
But this class is working very well, it's already tested.
According to your compiler and your destination env, check the known bugs
regarding the STL.
As for me, I'm using STL list, vectors, map and string classes.
With Visual C++ I was using CList, CArray, CString..
I didn't have the time to redevelop my own classes and to test them.
I've used the sTL core classes and I didn't get errors or bugs.

2) As for me, my application should work both under Linux and SGI Irix.
Thus, I've to manage the problem of Little Endian / Big Endian.
Because I was using binary image files written on Windows and read on Irix.
So, tyry to write a custom I/O stream class in order to check the endian
status and to reverse the bytes order.

Take care about data structure alignement, it's platform dependant.

Try to not polluate your code with conditionnal instructions like #ifdef
WIN32....#else..#endif.
Otherwise, you source code becomes quickly "unreadable"...Believe me ;o)

3) there is a problem with file handling routine.
Try to use the low level file routines such like read(), open(), close()
instead of fopen(), fclose()....
Because under windows, it's simple to open a file in write mode, but under
linux or Irix, you have to deal
with write permissions (user owner...). Take care about that.

4) I don't know how you're coding under windows. I suppose you're using
Visual C++ .
So, don't forget tha Visual C++ compiler is VERY permissive.
So try to re-compile you whole project with high level warning.
Believe me that a lot of warnings under windows become fuc@#@ing buggous
errors under Irix or Linux

Finally, try as most as possible to port your application component by
component.
Port them on your linux box, test them and integrate them.
Don't wait to have ported 50 objects. Otherwise errors and crash will fall
like rain ;o))

5) If you have to deal with GUI, it could be a good idea to use a
cross-platform library.
For my project, I've used QT library. it's implemented for Irix, Linux
boxes, and even for Windows !
But the Windows version is not free.....

So hope it will help you.

You send me emails if you have other questions.

Regards,

Karim



------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.apps newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-Apps Digest
******************************

Reply via email to