All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fwd: libsemanage API]
@ 2007-07-06 16:52 Daniel J Walsh
  2007-07-07 18:01 ` Joe Nall
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel J Walsh @ 2007-07-06 16:52 UTC (permalink / raw)
  To: SE Linux; +Cc: joe.rocklin

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]



-------- Original Message --------
Subject: 	libsemanage API
Date: 	Fri, 06 Jul 2007 10:59:23 -0400
From: 	Joe Rocklin <joe.rocklin@ngc.com>
To: 	dwalsh@redhat.com



Hi Dan,

I'm trying to use the API to libsemanage from C++, and I'm running into 
some difficulties finding relevant documentation on the subject.  If you 
could point me in the right direction, I'd really appreciate it!

The issue I'm having is with trying to work with the return results from 
semanage_user_list.  The struct defines for semanage_user_t (as well as 
semanage_user_base_t  and semanage_user_extra_t) are in the .c files, 
not the header files, which causes a compile to fail with the following 
error:


    setest.cpp:19: error: request for member ‘name’ in
    ‘*(((semanage_user_t**)(((unsigned int)i) * 4u)) + list)’, which is
    of non-class type ‘semanage_user_t*’

I've attached the small program used to test this.  If I run this in ddd 
and display the variable list[0].name it correctly displays the 
contents.  I believe the issue is that the compiler isn't aware of the 
struct definition, which isn't presented until the link phase.

Is there another way of accessing this data?  Or is the correct answer 
to move the struct definitions into the header files?

--Joe

[-- Attachment #2: setest.cpp --]
[-- Type: text/x-c++src, Size: 386 bytes --]

extern "C" {
	#include <semanage/semanage.h>
}
#include <iostream>

using namespace std;

int main (int argc, char **argv) {
	semanage_handle_t *sh = semanage_handle_create();

	semanage_user_t **list;
	unsigned int count;

	semanage_connect(sh);

	semanage_user_list(sh, &list, &count);

	for (int i = 0; i < count; i++) {
		cout << i << ": " << list[i].name << endl;
	}

	return 0;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-07 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-06 16:52 [Fwd: libsemanage API] Daniel J Walsh
2007-07-07 18:01 ` Joe Nall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.