From: Daniel J Walsh <dwalsh@redhat.com>
To: SE Linux <selinux@tycho.nsa.gov>
Cc: joe.rocklin@ngc.com
Subject: [Fwd: libsemanage API]
Date: Fri, 06 Jul 2007 12:52:38 -0400 [thread overview]
Message-ID: <468E7356.5080207@redhat.com> (raw)
[-- 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;
}
next reply other threads:[~2007-07-06 16:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-06 16:52 Daniel J Walsh [this message]
2007-07-07 18:01 ` [Fwd: libsemanage API] Joe Nall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=468E7356.5080207@redhat.com \
--to=dwalsh@redhat.com \
--cc=joe.rocklin@ngc.com \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.