public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: src/
Date: Wed,  5 Oct 2011 20:56:49 +0000 (UTC)	[thread overview]
Message-ID: <1fa0da3323562b7bfc74501d4b20a12bdfe5d094.dol-sen@gentoo> (raw)

commit:     1fa0da3323562b7bfc74501d4b20a12bdfe5d094
Author:     Detlev Casanova <detlev.casanova <AT> gmail <DOT> com>
AuthorDate: Mon Jul  5 10:19:47 2010 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jul  5 10:19:47 2010 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=1fa0da33

Add interpreter version : shorter, more reliable

---
 src/interpreter.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/src/interpreter.c b/src/interpreter.c
new file mode 100644
index 0000000..6ab2843
--- /dev/null
+++ b/src/interpreter.c
@@ -0,0 +1,58 @@
+#include <Python.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+	PyObject *pP1, *pP2, *pArgs, *pName, *pModule, *pDict, *pFunc, *pValue;
+
+	Py_Initialize();
+
+	//printf("%s\n", Py_GetVersion());
+
+	//pName = PyByteArray_FromStringAndSize("portage", strlen("portage"));
+	pModule = PyModule_New("portage");
+
+	pDict = PyModule_GetDict(pModule);
+	pFunc = PyDict_GetItemString(pDict, "pkgcmp");
+
+	if (PyCallable_Check(pFunc)) 
+	{
+		pP1 = PyByteArray_FromStringAndSize("app-portage/kuroo4-4.2", strlen("app-portage/kuroo4-4.2"));
+		pP2 = PyByteArray_FromStringAndSize("app-portage/kuroo4-4.3", strlen("app-portage/kuroo4-4.3"));
+
+		pArgs = PyTuple_New(2);
+
+		PyTuple_SetItem(pArgs, 0, pP1);	
+		PyTuple_SetItem(pArgs, 0, pP2);	
+
+		pValue = PyObject_CallObject(pFunc, pArgs);
+
+		if (pArgs != NULL)
+		{
+			Py_DECREF(pArgs);
+		}
+	}
+	else 
+		PyErr_Print();
+
+	int ret = PyLong_AsLong(pValue);
+	switch(ret)
+	{
+	case -1:
+		printf("less");
+		break;
+	case 0:
+		printf("same");
+		break;
+	case 1:
+		printf("more");
+		break;
+	}
+
+	printf("\n");
+
+	Py_DECREF(pModule);
+
+	Py_Finalize();
+}



             reply	other threads:[~2011-10-05 20:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05 20:56 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-10-05 20:56 [gentoo-commits] proj/layman:master commit in: src/ Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec
2011-10-05 20:56 Brian Dolbec

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=1fa0da3323562b7bfc74501d4b20a12bdfe5d094.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox