C#

using System;
public class runme {
        static void Main() {
                Console.WriteLine(pacman.pacman_initialize("/"));
                Console.WriteLine(pacman.pacman_initialize("/"));
        }
}

Java

public class main
{
        static
        {
                System.loadLibrary("pacman_java");
        }

        public static void main(String argv[])
        {
                // this will return with success (0)
                System.out.println(pacman.pacman_initialize("/"));
                // this will return with failure (-1) as the lib is already
                // initialized
                System.out.println(pacman.pacman_initialize("/"));
        }
}

Perl

use Pacman::Core;

# this does the same as pacman-g2 -Qo
sub getowner
{
        my $what = shift;
        $i = Pacman::Core::pacman_db_getpkgcache($db);
        while($i)
        {
                $pkg = Pacman::Core::void_to_PM_PKG(Pacman::Core::pacman_list_getdata($i));
                $j = Pacman::Core::void_to_PM_LIST(Pacman::Core::pacman_pkg_getinfo($pkg, $Pacman::Core::PM_PKG_FILES));
                while($j)
                {
                        if(Pacman::Core::void_to_char(Pacman::Core::pacman_list_getdata($j)) eq $what)
                        {
                                return Pacman::Core::void_to_char(Pacman::Core::pacman_pkg_getinfo($pkg, $Pacman::Core::PM_PKG_NAME));
                        }
                        $j = Pacman::Core::pacman_list_next($j);
                }
                $i = Pacman::Core::pacman_list_next($i);
        }
}

Pacman::Core::pacman_initialize("/");
$db = Pacman::Core::pacman_db_register('local');

print getowner("usr/bin/pacman-g2") . "\n";
print getowner("lib/libc.so.6") . "\n";

Python

import pacman

# this will return with success (0)
print pacman.initialize("/")
# this will return with failure (-1) as the lib is already initialized
print pacman.initialize("/")