Paolo Dovera | 2 Nov 21:43 2003
Picon

problem to access /proc/acpi/battery/BAT1/* files

Hi all,
on my RH9 2.6.0-test6 I noticed a strange log in /var/log/messages:

Oct 17 18:15:16 localhost kernel:  dswload-0269: *** Error: Looking up 
[PBST] in namespace, AE_ALREADY_EXISTS
Oct 17 18:15:16 localhost kernel:  psparse-0589 [293932] 
ps_parse_loop         : During name lookup/catalog, AE_ALREADY_EXISTS
Oct 17 18:15:16 localhost kernel:  psparse-1121: *** Error: Method 
execution failed [\_SB_.PCI0.LPC0.BAT1._BST](Nodec12ab328), 
AE_ALREADY_EXISTS
Oct 17 18:15:25 localhost kernel:  dswload-0269: *** Error: Looking up 
[PBST] in namespace, AE_ALREADY_EXISTS
Oct 17 18:15:25 localhost kernel:  psparse-0589 [294043] 
ps_parse_loop         : During name lookup/catalog, AE_ALREADY_EXISTS
Oct 17 18:15:25 localhost kernel:  psparse-1121: *** Error: Method 
execution failed [\_SB_.PCI0.LPC0.BAT1._BST] (Node c12ab328), 
AE_ALREADY_EXISTS

the problem arises when on my system two programs access concurrently 
the files into /proc/acpi/battery/BAT1/*

for example I run the cpufrequency, a daemon to switch CPU frequency on 
my P4 laptop http://sourceforge.net/projects/cpufrequency/
(this program checks every some seconds the status of battery)
and I use
       watch -n 8 "cat /proc/acpi/battery/BAT1/*"
to see the battery state in another xterm.

Is there any kind of lock to access the status of battery?

(Continue reading)

nanakos | 3 Nov 17:12 2003
Picon

Re: Sizes of stack variables

Hi the stack size depends on the optimization of the compiler ( gcc )
.Just read the stack frame that is used from the compiler.You can find
such info in http://gcc.gnu.org or sth similar.

Best regards,
Chris.

> Hey All,
>   I was just trying to minimize the size of a program the other day,
> and I noticed that the size of the varibles created on the stack is
> not necessarily the size they should be.  So, for instance, the
> following code:
>
> void main()
> {
>   char buffer[8];
>
>   printf("%s\n", buffer);
> }
>
> produces the following assembly:
>    ...
> 8  main:
> 9    pushl %ebp
> 10   movl  %esp, %ebp
> 11   subl  $24, %esp
> 12   andl  $-16, %esp
> 13   movl  $0, %eax
>      ...
>
(Continue reading)

Rivalino M. Jr. | 4 Nov 14:19 2003
Picon

Re: Is it possible to trace back from where a user comes

If your program is based on TCP/IP, I think you could use something like
tcpd. You could make yourself "tcpd", a kind of wrapper that will receive
the connection and log the source IP before spawn the target service.

----- Original Message ----- 
From: "Jeff Woods" <kazrak+kernel <at> cesmail.net>
To: "Holger Kiehl" <Holger.Kiehl <at> dwd.de>
Cc: <linux-c-programming <at> vger.kernel.org>
Sent: Wednesday, October 29, 2003 6:50 AM
Subject: Re: Is it possible to trace back from where a user comes

> At 10/29/2003 08:29 AM +0000, Holger Kiehl wrote:
> >I have written a small program that allows a user to do some
> >configuration. Now everytime the user does configure something it gets
> >logged to a log file. Usually when someone comes from a remote machine I
> >took the environment variable DISPLAY and if that is not there the output
> >from "who am i", to determine from where the user comes. However this
does
> >not work reliably since DISPLAY is set to localhost when the user is
using
> >ssh, also "who am i" does not always tell me from where a user comes.
> >Another problem is when the user first logs in on say host1 then to host2
> >and then to host3. Is there a way to determine that the user comes from
> >host1? The SSH_CLIENT environment variable is always set to the last
host,
> >so this can not be used. SSH_CONNECTION is not set so this can also not
be
> >used. I also looked at struct utmp it to does not provide the
information,
> >it is also not very portable since the structure differs a lot from
(Continue reading)

Elias Athanasopoulos | 8 Nov 10:30 2003
Picon

mixing C/C++

Hello!

I want to create Ruby bindings for a C++ project, so my first
step is to call C++ code from C, since Ruby has a plain C API.

Consider I have a Foo class which its implementation is compiled
in a shared lib (libtest.so). I have a second wrapper lib:

#include "libtest.h"

extern "C" class Foo *  wrap_foo_ctor() { return new Foo(); }
extern "C" void wrap_foo_set_food(Foo *f, int i) { f->set_food(i); }
extern "C" int  wrap_foo_hello(Foo *f) { return f->hello();  }

Using the above my C program is:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  struct Foo *m = (struct Foo*) wrap_foo_ctor();

  wrap_foo_set_food(m, 10);
  wrap_foo_hello(m);

  free(m);

  return 1;
}
(Continue reading)

James Stevenson | 8 Nov 14:36 2003

Re: mixing C/C++


Hi

this is because you program doesnt know what the functions
are called so you need to add protypes.

Either create a  header and put a prototype of the
function name in there and include the header file

or

add the prototypes to the top of the C file.

	James

On Sat, 8 Nov 2003, Elias Athanasopoulos wrote:

> Hello!
> 
> I want to create Ruby bindings for a C++ project, so my first
> step is to call C++ code from C, since Ruby has a plain C API.
> 
> Consider I have a Foo class which its implementation is compiled
> in a shared lib (libtest.so). I have a second wrapper lib:
> 
> #include "libtest.h"
> 
> extern "C" class Foo *  wrap_foo_ctor() { return new Foo(); }
> extern "C" void wrap_foo_set_food(Foo *f, int i) { f->set_food(i); }
> extern "C" int  wrap_foo_hello(Foo *f) { return f->hello();  }
(Continue reading)

Matthew Studley | 10 Nov 16:00 2003
Picon

Re: mixing C/C++

Have you considered using SWIG to automatically generate your wrappers?

... SWIG is a software development tool that connects programs written in C
and C++ with a variety of high-level programming languages. SWIG is
primarily used with common scripting languages such as Perl, Python, Tcl/Tk,
and Ruby...

http://www.swig.org/

May be a useful resource.  I've used it with C and Python.

regards

Matt

----- Original Message -----
From: Elias Athanasopoulos <elathan <at> phys.uoa.gr>
To: <linux-c-programming <at> vger.kernel.org>
Sent: Saturday, November 08, 2003 9:30 AM
Subject: mixing C/C++

> Hello!
>
> I want to create Ruby bindings for a C++ project, so my first
> step is to call C++ code from C, since Ruby has a plain C API.
>
> Consider I have a Foo class which its implementation is compiled
> in a shared lib (libtest.so). I have a second wrapper lib:
>
> #include "libtest.h"
(Continue reading)

Elias Athanasopoulos | 10 Nov 18:37 2003
Picon

Re: mixing C/C++

On Mon, Nov 10, 2003 at 03:00:31PM -0000, Matthew Studley wrote:
> Have you considered using SWIG to automatically generate your wrappers?
> 
> ... SWIG is a software development tool that connects programs written in C
> and C++ with a variety of high-level programming languages. SWIG is
> primarily used with common scripting languages such as Perl, Python, Tcl/Tk,
> and Ruby...

Yes, I have tried it. I found it quite complicated in the sense 
that I can't control stuff; it's difficult to hack the auto-generated
swig files. Also, it lacks compatibility with Ruby 1.8.

Thanks for your reply.

Regards,
--

-- 
University of Athens			I bet the human brain 
Physics Department				is a kludge --Marvin Minsky 

	
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

J. | 12 Nov 05:35 2003
Picon
Picon

convert INT to CHAR but print's BEEP...

Wednesday, November 12 05:19:21

Hello, I have kind of a problem with converting an int to a char.
The get_rand_str() function returns an string build of random 
charaters with a max length of int `MAX'.

This seems to work at first glance: 
~: ./program 
qqxfrd

However if I examen the output closer:
~: ./program | od -a
0000000   q   q soh   x stx   f etx   r eot   d enq  nl
0000014

Now I know why my computer keeps beeping everytime it
outputs a string :-)

What is the correct way of changing the int value to a
char value so that I can append it to the return string ?

char *get_rand_str(int max) {
 int i = 0;
 char value;
 char *retval = NULL;

 for(; i < max; i++) {
  value = get_ascii_code(97, 122);
  retval = (char *)realloc(retval, sizeof(char));
  strcat(retval, &value);
(Continue reading)

Mikael Aronsson | 12 Nov 08:11 2003
Picon

Re: convert INT to CHAR but print's BEEP...

Hi !

The problem with strcat is that you cannot just use a pointer to the
character because all C string functions require that you end the string
with a zero (0) byte.

You could do something like this for eample:
char temp[ 2];
temp[ 0] = my_character;
temp[ 1] = '\0';
strcat( org_string, temp);

Mikael

----- Original Message ----- 
From: "J." <mailing-lists <at> xs4all.nl>
To: <linux-c-programming <at> vger.kernel.org>
Sent: Wednesday, November 12, 2003 5:35 AM
Subject: convert INT to CHAR but print's BEEP...

> Wednesday, November 12 05:19:21
>
> Hello, I have kind of a problem with converting an int to a char.
> The get_rand_str() function returns an string build of random
> charaters with a max length of int `MAX'.
>
> This seems to work at first glance:
> ~: ./program
> qqxfrd
>
(Continue reading)

J. | 13 Nov 02:26 2003
Picon
Picon

Re: convert INT to CHAR - SOLVED....

On Wed, 12 Nov 2003, Mikael Aronsson wrote:
> Hi !
> 
> The problem with strcat is that you cannot just use a pointer to the
> character because all C string functions require that you end the string
> with a zero (0) byte.
> 
> You could do something like this for eample:
> char temp[ 2];
> temp[ 0] = my_character;
> temp[ 1] = '\0';
> strcat( org_string, temp);
> 
> Mikael

THnkx.. I fixed that, and I allocated the return value with calloc, this 
works ... :)

I learnend something again....

Thnkx

J.

--
FOnkTong

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo <at> vger.kernel.org
(Continue reading)


Gmane