text:
'''recombination prob. plots
'''

import os
import sys
import numbers
import cPickle as pickle
import gzip
import numpy as np

import aimseqtk.lib.common as lcommon
import aimseqtk.lib.drawcommon as drawcommon
from aimseqtk.src.recomb.recomb_model import RecombModel
import aimseqtk.src.recomb.recomb_cmp as rcmp
import aimseqtk.src.recomb.recomb_common as rcommon

def model_get_ydata(models, attr):
    assert attr in models[0].get_attrs_depth1()
    k2ydata = {}
    for k in models[0][attr]:
        k2ydata[k] = [m[attr][k] for m in models]
    return k2ydata

def model_get_ydata2(models, attr):
    assert attr in models[0].get_attrs_depth2()
    k_to_k2ydata = {}
    for k, k2v in models[0][attr].iteritems():
        k2ydata = {}
        for k2 in k2v:
            k2ydata[k2] = [m[attr][k][k2] for m in models]
        k_to_k2ydata[k] = k2ydata
    return k_to_k2ydata

def model_makeplots(indir, outdir):
    objs = lcommon.load_pickledir(indir)
    if not objs:
        return
    rcommon.union_models(objs)
    for attr in objs[0].get_attrs_depth1():
        outbase = os.path.join(outdir, attr)
        k2ydata = model_get_ydata(objs, attr)
        gene_attrs = ['v', 'd', 'j']
        if attr in gene_attrs:
            xlabels = lcommon.sort_by_gene_number(k2ydata.keys())
            rcmp.diff_plot(k2ydata, outbase, xlabels, attr.upper(),
                           ylabel='Frequency')
        else:
            rcmp.diff_plot(k2ydata, outbase, label=attr.upper(), xmin=-0.5,
                           xmax=30.5, ylabel='Frequency')
    for attr in objs[0].get_attrs_depth2():
        k_k2ydata = model_get_ydata2(objs, attr)
        for k, k2ydata in k_k2ydata.iteritems():
            if not isinstance(k, str):
                k = str(k)
            outbase = os.path.join(outdir, "%s_%s" % (attr, k))
            if attr in ['v2del', 'j2del', 'd2del']:
                rcmp.diff_plot(k2ydata, outbase, label=attr.upper(), xmin=-0.5,
                          xmax=16.5, ylabel='Frequency')
            else:
                rcmp.diff_plot(k2ydata, outbase, label=attr.upper(),
                               ylabel='Frequency')

def main():
    indir = sys.argv[1]
    outdir = sys.argv[2]

    model_makeplots(indir, outdir)

if __name__ == '__main__':
    main()


text:
from collections import Counter
import sets
import math
import sys
import os
from math import isinf

# Minimum normalized RSSI value detected; used as "not detected" value
MIN_DETECTED = 0

# Access Point class
class AccessPoint(object):
    def __init__(self, ap, from_django=False):
        if not from_django:
            self.mac = ap[0]
            self.strength_dbm = float(ap[1])
            self.strength = 10 ** (float(ap[1]) / 10)
            self.std = 10 ** (float(ap[2]) / 10)
            self.datetime = ap[3]
            #self.sample_size = ap[4]
        else:
            self.mac = ap['mac_address']
            self.strength_dbm = ap['signal_strength']
            self.strength = 10 ** (self.strength_dbm / 10)
            self.std = 10 ** (ap['standard_deviation'] / 10)
            self.datetime = ap['recorded']

# Location Class
# TODO: Look into storing previous distance calculations
class Location(object):
    def __init__(self, loc):
        self.x = loc[0]
        self.y = loc[1]
        self.direction = loc[2]
        self.floor_id = loc[3]
        self.init_aps(loc[4])

    def printLoc(self):
        sys.stdout.write("Location: (x, y) = (" + str(self.x) + ", " + str(self.y) + \
                "), Floor = " + str(self.floor_id) + "\n")

    # Stores Access Points in a {mac_id : AccessPoint} dictionary
    def init_aps(self, aps):
        self.aps = {}
        for ap in aps:
            self.aps[ap[0]] = AccessPoint(ap)

    #Calculates distance between this Location and the given dictionary of
    #AccessPoints (currently calls function to calculate Euclidean distance)
    def get_distance1(self, aps, gamma = .005):
        distances = []
        keys = sets.Set()
        for mac_id in aps.keys():
            keys.add(mac_id)
        for mac_id in self.aps.keys():
            keys.add(mac_id)
        euc_dist = euclidean(keys, self.aps, aps)
        self.euc_dist = euc_dist
        percent_shared = float(len([ap for ap in aps.keys() if ap in self.aps.keys()])) / len(keys)
        if percent_shared == 0:
            return float("INF")
        #return 1 / percent_shared + 1.5 * euc_dist
        return (1 / percent_shared) + (1.5 * euc_dist)  + (gamma * self.density)

    def get_distance2(self, aps):
        num_similar = 0
        for mac_id in aps.keys():
            if mac_id in self.aps.keys():
                num_similar += 1
        return num_similar

    #def get_distance(self, aps):
    #    coeffA = 1
    #    coeffB = 1
    #   coeffC = 1
    #   keys1 = self.aps.keys()
    #   keys2 = aps.keys()
    #   intersection = [key for key in keys1 if key in keys2]
    #   if len(intersection) == 0:
    #       return sys.maxint
    #   size_shared = len(intersection)
    #   size_diff = len(keys1) + len(keys2) - 2 * size_shared
    #   probability = 0
    #   for key in intersection:
    #       probability += similarity(self.aps[key], aps[key])
    #   probability = float(probability) / len(intersection)
    #   return coeffA * size_shared + coeffB * size_diff + coeffC * probability"""

def similarity(ap1, ap2):
    from scipy.stats import ttest_ind,norm
    return 1 - ttest_ind(
        norm.rvs(loc=ap1.strength,scale=ap1.std,size=ap1.sample_size),
        norm.rvs(loc=ap2.strength,scale=ap2.std,size=ap2.sample_size),
        equal_var = False)[1]

# Given a set of mac_ids and two dictionaries of AccessPoints, calculates the
# Euclidean distance between the two dictionaries
def euclidean(keys, aps1, aps2):
    rVal = 0
    for key in keys:
        strength1 = MIN_DETECTED
        if key in aps1:
            strength1 = aps1[key].strength
        strength1 = 10 ** (strength1 / 10)
        strength2 = MIN_DETECTED
        if key in aps2:
            strength2 = aps2[key].strength
        strength2 = 10 ** (strength2 / 10)
        rVal = rVal + (strength1 - strength2) ** 2
    return math.sqrt(rVal)

        # Given a list of tuples where t[0] is the value and t[1] is the distance,
# returns a weighted average of the values
def weighted_avg(tuples, inverse):
    ### If we want the unweighted average:
    #return sum([t[0] for t in tuples]) / len(tuples)
    s = 0
    for t in tuples:
        if t[1] == 0:
            return t[0]
    if inverse:
        weight_sum = sum([1 / t[1] for t in tuples])
    else:
        weight_sum = sum([t[1] for t in tuples])
    for t in tuples:
        if isinf(t[1]) or weight_sum == 0:
            print t[0]
            return t[0]
        if inverse:
            s += t[0] * (1 / t[1]) / weight_sum
        else:
            s += t[0] * t[1] / weight_sum
    return s

def jaccardDistance(aps1, aps2):
    count = 0
    for ap in aps2.values():
        if ap.mac in aps1.keys():
            count += 1
    intersection = count
    union = len(aps1.keys()) + len(aps2.keys()) - count
    return float(intersection) / union

def realDistance(d1, d2):
    if d1 is None or d2 is None:
        return 0
    return math.sqrt(pow(d1.x - d2.x, 2) + pow(d1.y - d2.y, 2))

# Uses k - Nearest Neighbor technique to get the coordinates associated with
# the given AccessPoint dictionary
def apply_kNN(data, aps, k = 3, element = None):
    k = min(k, len(data))
    #data = sorted(data, key=lambda x: x.get_distance1(aps))
    for d in data:
        d.distance = d.get_distance1(aps)
    data = sorted(data, key=lambda x: x.distance)
    #for d in data:
        #print jaccardDistance(aps, d.aps), "->", d.distance, "->", realDistance(d, element)
    #TODO: Reconsider avg vs. mode
    d = Counter([loc.floor_id for loc in data[:(k * 2 - 1)]])
    floor = d.most_common(1)[0][0]
    data = [d for d in data if d.floor_id == floor]
    x = weighted_avg([(loc.x, loc.distance) for loc in data[:k]], True)
    y = weighted_avg([(loc.y, loc.distance) for loc in data[:k]], True)
    return (x, y, floor, data[:k])

def apply_kNN_func(data, aps, func , k = 3):
    #function must take in two dictionaries from MAC : strength and return a strength
    k = min(k, len(data))
    #data = sorted(data, key=lambda x: x.get_distance1(aps))
    for d in data:
        d.distance =  func(aps, d.aps)
    data = sorted(data, key=lambda x: x.distance)
    #TODO: Reconsider avg vs. mode
    d = Counter([loc.floor_id for loc in data[:(k * 2 - 1)]])
    floor = d.most_common(1)[0][0]
    data = [d for d in data if d.floor_id == floor]
    x = weighted_avg([(loc.x, loc.distance) for loc in data[:k]], True)
    y = weighted_avg([(loc.y, loc.distance) for loc in data[:k]], True)
    return (x, y, floor)

# Returns the standard deviation of the given list
def get_sd(l):
    mean = get_mean(l)
    rVal = 0
    for elem in l:
        rVal += (elem - mean) ** 2
    return (rVal / (len(l) - 1)) ** .5

# Returns the mean of the given list
def get_mean(l):
    return sum(l) / len(l)

# Normalizes the signal strengths of all AccessPoints in the given array of
# Locations and the given AccessPoint dictionary
def normalize(data, aps):
    global MIN_DETECTED
    strengths = []
    for loc in data:
        for ap in loc.aps.values():
            strengths.append(ap.strength)
    mean = get_mean(strengths)
    st_dev = get_sd(strengths)
    for loc in data:
        for ap in loc.aps.values():
            ap.strength = (ap.strength - mean) / st_dev
            if ap.strength < MIN_DETECTED:
                MIN_DETECTED = ap.strength
    for ap in aps.values():
        ap.strength = (ap.strength - mean) / st_dev
        if ap.strength < MIN_DETECTED:
            MIN_DETECTED = ap.strength

# SUITE OF FUNCTIONS FOR TYLER

def transformAPs(aps):
    ap_list = []
    for ap in aps:
       pass

# ENDSUITE

# Returns a list of Locations and an AccessPoint dictionary
def get_locations(data):
    locations = []
    #sys.stderr.write("LENGTH: " + str(len(data)) + "\n")
    for d in data:
        cur_macs = d["macs"]
        cur_rss = d["rss"]
        cur_aps = []
        for i in range(len(cur_macs)):
            cur_aps.append((cur_macs[i], cur_rss[i], 0, 0))
        locations.append((d["x"], d["y"], d["direction"], d["floor_id"], cur_aps))
    return [Location(i) for i in locations]

def getData(db_cursor=None):
    if db_cursor is None:
        from scripts.db.db import Database
        password = os.environ.get('SIRIUS_PASSWORD')
        if password is None:
            raise Exception('No database password available')

        db = Database(password)

        cur = db.get_cur()
    else:
        cur = db_cursor
    cur.execute("""SELECT floor_id,marauder_accesspoint.location_id, x_coordinate, y_coordinate, direction,
         array_to_string(array_agg(mac_address),',') as MAC_list,
         array_to_string(array_agg(signal_strength),',') as strength_list
         from marauder_accesspoint
         join marauder_location
            on marauder_location.id=marauder_accesspoint.location_id
         group by floor_id,marauder_accesspoint.location_id,x_coordinate,y_coordinate,direction""")
    access_points = cur.fetchall()
    res = []
    for f in access_points:
        msg = {
            'floor_id': f[0],
            'location_id': f[1],
            'x': f[2],
            'y': f[3],
            'direction': f[4],
            'macs': f[5].split(','),
            'rss': map(float, f[6].split(','))
        }
        res.append(msg)
    return res

def kNN(test_aps, db_cursor=None):
    test_aps = {ap['mac_address'] : AccessPoint(ap, from_django=True) for ap in test_aps}
    trained_data = getData(db_cursor=db_cursor)
    locations = get_locations(trained_data)
    normalize(trained_data, test_aps)
    return apply_kNN(trained_data, test_aps)

# BRETT NORMALIZE FUNCTION
def normalize_all_data(data, testdata):
    global MIN_DETECTED
    strengths = []
    for loc in data:
        for ap in loc.aps.values():
            strengths.append(ap.strength)
    mean = get_mean(strengths)
    st_dev = get_sd(strengths)
    for loc in data:
        for ap in loc.aps.values():
            ap.strength = (ap.strength - mean) / st_dev
            if ap.strength < MIN_DETECTED:
                MIN_DETECTED = ap.strength
    for loc in testdata:
        for ap in loc.aps.values():
            ap.strength = (ap.strength - mean) / st_dev
            if ap.strength < MIN_DETECTED:
                MIN_DETECTED = ap.strength

# BRETT TEST STUFF
def testAccuracy():
    sql_data = getData()
    all_data = get_locations(sql_data)

    #DEN_THRESHOLD = 9.555 * 20 # Number of points within 20m
    DEN_THRESHOLD = 14.764 * 20

    # dens = []
    for i in range(len(all_data)):
        count = 1
        loc1 = all_data[i]
        for j in range(len(all_data)):
            if i == j:
                continue
            loc2 = all_data[j]
            if realDistance(loc1,loc2) < DEN_THRESHOLD:
                count += 1
        loc1.density = count

    data = [d for d in all_data if d.floor_id < 3]
    testdata = [d for d in all_data if d.floor_id == 15]
    normalize_all_data(data, testdata)
    wrong_floor_count = 0
    error_total = 0
    distances = [0] * 10 # [0-1 meter, 1-2, 2-3, etc]
    # 7, 8, 12, 16
    #testdata = [d for (i, d) in enumerate(testdata) if i == 16]
    for i in range(len(testdata)):
        element = testdata[i]
        aps = element.aps
        (x, y, floor, neighbors)  = apply_kNN(data, aps, element = element)
        cur_error = error(element, x, y, floor)
        if cur_error == -1:
            wrong_floor_count += 1
        else:
            print element.x, element.y, x, y
            #For Halligan_2.png, 14.764px ~= 1 meter
            #For Halligan_1.png 9.555px ~= 1 meter
            if floor == 1: #id NOT FLOOR NUMBER!!
                #print cur_error / 14.764
                error_total += cur_error / 14.764
                distances[min(int(cur_error / 14.764), 9)] += 1
            else:
                #print cur_error / 9.555
                error_total += cur_error / 9.555
                distances[min(int(cur_error / 9.555), 9)] += 1
    return
    print "FOR " + str(len(testdata)) + " POINTS:"
    print "Incorrect Floor Count:", wrong_floor_count
    print "Avg error: " + str(float(error_total) / (len(testdata) - wrong_floor_count)) + "m"
    print "Distances:", distances
    print ""

def getMinMax():
    sql_data = getData()
    dataa = get_locations(sql_data)
    normalize(dataa[:-1], dataa[-1].aps)
    minx = 100000
    maxx = 0
    miny = 100000
    maxy = 0
    for data in dataa:
        if data.x < minx:
            minx = data.x
        if data.x > maxx:
            maxx = data.x
        if data.y < miny:
            miny = data.y
        if data.y > maxy:
            maxy = data.y
    return (minx, maxx, miny, maxy)

def error(element, x, y, floor):
    if element.floor_id == 3 and floor != 2:
        return -1
    elif element.floor_id == 15 and floor != 1:
        return -1
    elif element.floor_id < 3 and element.floor_id != floor:
        return -1
    else:
        dist = math.sqrt(pow(element.x - x, 2) + pow(element.y - y, 2))
    return dist

def LOOCV():
    print "RUNNING LOOCV TESTS"
    print ""
    sql_data = getData()
    data = get_locations(sql_data)
    data = [d for d in data if d.floor_id != 3]
    print len(data)
    normalize(data[:-1], data[-1].aps) # Hacky way to normalize all data
    wrong_floor_count = 0
    error_total = 0
    distances = [0] * 10 # [0-1 meter, 1-2, 2-3, etc]
    for i in range(len(data)):
        element = data[i]
        data.remove(element)
        aps = element.aps
        (x, y, floor)  = apply_kNN(data, aps)
        cur_error = error(element, x, y, floor)
        if cur_error == -1:
            wrong_floor_count += 1
        else:
            #For Halligan_2.png, 14.764px ~= 1 meter
            #For Halligan_1.png 9.555px ~= 1 meter
            if floor == 1: #id NOT FLOOR NUMBER!!
                error_total += cur_error / 14.764
                distances[min(int(cur_error / 14.764), 9)] += 1
            else:
                error_total += cur_error / 9.555
                distances[min(int(cur_error / 9.555), 9)] += 1
        data.insert(i, element)
    print "FOR " + str(len(data)) + " POINTS:"
    print "Incorrect Floor Count:", wrong_floor_count
    print "Avg error: " + str(float(error_total) / (len(data) - wrong_floor_count)) + "m"
    print "Distances:", distances
    print ""

def LOOCV_func(data, distance_func ):
    wrong_floor_count = 0
    error_total = 0
    distances = [0] * 10 # [0-1 meter, 1-2, 2-3, etc]
    for i in range(len(data)):
        element = data[i]
        data.remove(element)
        aps = element.aps
        (x, y, floor)  = apply_kNN_func(data, aps,distance_func)
        cur_error = error(element, x, y, floor)
        if cur_error == -1:
            wrong_floor_count += 1
        else:
            #For Halligan_2.png, 14.764px ~= 1 meter
            #For Halligan_1.png 9.555px ~= 1 meter
            if floor == 1 or floor == 6: #id NOT FLOOR NUMBER!!
                error_total += cur_error / 14.764
                distances[min(int(cur_error / 14.764), 9)] += 1
            else:
                error_total += cur_error / 9.555
                distances[min(int(cur_error / 9.555), 9)] += 1
        data.insert(i, element)
    #Returns wrong floor count, average error
    return wrong_floor_count, float(error_total) / (len(data) - wrong_floor_count)

def percent_same(L1, L2):
    fullList = L1 + L2
    unique = len(set(fullList))
    total = len(fullList)
    if total == 0:
        return 1
    return float(unique) / total

def overlap_distance(aps1,aps2):
    rVal = 0
    for mac,ap1 in aps1.iteritems():
        if mac in aps2:
            strength1 = 10 ** (ap1.strength / 10)
            strength2 = 10 ** (aps2[mac].strength / 10)
            rVal = rVal + (strength1 - strength2) ** 2
    return math.sqrt(rVal)

def make_dist_func(alpha,beta,delta):
    return lambda APS_1, APS_2:  (alpha - beta) * percent_same(APS_1.keys(),APS_2.keys()) + alpha + delta * overlap_distance(APS_1,APS_2)

def error_rate(missed_floors, average_error):
    return average_error

def wrapper():
    minError = sys.maxint
    minAlpha = sys.maxint
    minBeta = sys.maxint
    minDleta = sys.maxint
    sql_data = getData()
    data = get_locations(sql_data)
    normalize(data[:-1], data[-1].aps) # Hacky way to normalize all data
    wrapper_data = {}
    wrapper_data["alpha"] = []
    wrapper_data["beta"] = []
    wrapper_data["delta"] = []
    wrapper_data["avgError"] = []
    wrapper_data["missed_floors"] = []
    for i in range(10):
        for j in range(10):
            for k in range(10):
                print "{} - {} - {}".format(i,j,k)
                alpha = i / 1.0 - 5
                beta = j / 1.0 - 5
                delta = k / 1.0 - 5
                dist_func = make_dist_func(alpha,beta,delta)
                (missed_floors, avgError) =LOOCV_func(data, dist_func)
                wrapper_data["alpha"].append(alpha)
                wrapper_data["beta"].append(beta)
                wrapper_data["delta"].append(delta)
                wrapper_data["avgError"].append(avgError)
                wrapper_data["missed_floors"].append(missed_floors)
    fp = open("wrapper_data.json","w+")
    import json
    fp.write( json.dumps(wrapper_data,indent=4) )
    fp.close()

if __name__ == "__main__":
    #wrapper()
    testAccuracy()
    #LOOCV()

redpajama_set_name: RedPajamaGithub


text:
#pragma once
#include <string>
#include "../Messaging/IMessage.h"
#include "../IProtocol.h"

#ifdef SendMessage
#undef SendMessage
#endif

namespace PluggableBot
{
	namespace Messages
	{
		using namespace Messaging;

		/**
		 * \brief Rządanie wysłania wiadomości przez odpowiedni protokół.
		 */
		class SendMessage
			: public IMessage
		{
		public:
			static const int MessageType = 2; //!< Typ wiadomości.

			/**
			 * \brief Wiadomość tekstowa, która ma zostać wysłana.
			 */
			const std::string Content;

			/**
			 * \brief Odbiorca wiadomości.
			 */
			const std::string Recipient;

			/**
			 * \brief Określa, który protokół powinien wysłać wiadomość.
			 */
			const ProtocolPointer Protocol;

			/**
			 * \brief  Inicializuje obiekt wiadomości niezbędnymi wartościami.
			 */
			SendMessage(const std::string& content, const std::string& recipient, const ProtocolPointer protocol)
				: IMessage(MessageType), Content(content), Recipient(recipient), Protocol(protocol)
			{ }
		};

	}
}


text:
USE test_example_dbms
GO

DROP TABLE Comments
DROP TABLE Posts
DROP TABLE Likes
DROP TABLE Pages
DROP TABLE Categories
DROP TABLE Users
GO

CREATE TABLE Users
	(uid INT PRIMARY KEY IDENTITY(1,1),
	 name VARCHAR(100),
	 city VARCHAR(100),
	 age TINYINT)

CREATE TABLE Categories
	(cid SMALLINT PRIMARY KEY IDENTITY(1,1),
	name VARCHAR(50),
	description VARCHAR(100))

CREATE TABLE Pages
	(pid INT PRIMARY KEY IDENTITY(1,1),
	name VARCHAR(100),
	cid SMALLINT REFERENCES Categories(cid))

CREATE TABLE Likes
	(uid INT REFERENCES Users(uid),
	pid INT REFERENCES Pages(pid),
	date DATETIME,
	PRIMARY KEY(uid,pid))

CREATE TABLE Posts
	(postid INT PRIMARY KEY IDENTITY(1,1),
	date DATETIME,
	text VARCHAR(1000),
	shares INT,
	uid INT REFERENCES Users(uid))

CREATE TABLE Comments
	(commid INT PRIMARY KEY IDENTITY(1,1),
	text VARCHAR(1000),
	date DATETIME,
	topcomm BIT,
	postid INT REFERENCES Posts(postid) ON DELETE CASCADE ON UPDATE CASCADE)
GO

--INSERTS
-----------------------
INSERT Users(name, city, age) VALUES ('u1','c',18) --ok
INSERT Users(name, city, age) VALUES ('u2','c',18)
INSERT Users(name, city, age) VALUES ('u3','c',20)
INSERT Users(name, city, age) VALUES ('u4','c',24) --ok
INSERT Users(name, city, age) VALUES ('u5','c',13)

INSERT Categories(name, description) VALUES ('cat1','cat1desc')
INSERT Categories(name, description) VALUES ('cat2','cat2desc')

INSERT Pages(name,cid) VALUES('p1',1)
INSERT Pages(name,cid) VALUES('p2',1)
INSERT Pages(name,cid) VALUES('p3',1)
INSERT Pages(name,cid) VALUES('p4',1)
INSERT Pages(name,cid) VALUES('p5',1)
INSERT Pages(name,cid) VALUES('p6',1)
INSERT Pages(name,cid) VALUES('p7',2)

INSERT Likes(uid, pid, date) VALUES(1,1, '1-1-2015')
INSERT Likes(uid, pid, date) VALUES(1,2, '1-1-2015')
INSERT Likes(uid, pid, date) VALUES(1,3, '1-1-2015')
INSERT Likes(uid, pid, date) VALUES(2,1, '1-1-2015')
INSERT Likes(uid, pid, date) VALUES(5,1, '1-1-2015')

INSERT Posts(date, shares, text, uid) VALUES ('5-10-2015',1,'po1',1)

INSERT Comments(text, date, topcomm, postid) VALUES ('co1','1-1-2015',1,1)
INSERT Comments(text, date, topcomm, postid) VALUES ('co2','1-1-2015',0,1)

INSERT Posts(date, shares, text, uid) VALUES ('5-10-2015',1,'po2',2)
INSERT Comments(text, date, topcomm, postid) VALUES ('co3','1-1-2015',1,2)

INSERT Posts(date, shares, text, uid) VALUES ('5-10-2015',1,'po3',4)
INSERT Comments(text, date, topcomm, postid) VALUES ('co4','1-1-2015',1,3)
INSERT Comments(text, date, topcomm, postid) VALUES ('co5','1-1-2015',0,3)

--3--
SELECT u.name, u.age, ISNULL(noOfLikes,0)
FROM Users u INNER JOIN
	(
        SELECT u.uid, c.postid, COUNT(commid) AS noOfComments
        FROM Users u INNER JOIN Posts p ON u.uid = p.uid
            INNER JOIN Comments c ON p.postid = c.postid
        WHERE u.age BETWEEN 18 AND 24 AND p.date BETWEEN '5-6-2015' AND '6-5-2015'
        GROUP BY u.uid, c.postid
        HAVING COUNT(commid) >=2
    ) t1
	ON u.uid = t1.uid
	LEFT JOIN
	(
        SELECT uid, COUNT(pid) noOfLikes
        FROM Likes
        GROUP BY uid
    ) t2
	ON t1.uid = t2.uid

ORDER BY noOfLikes ASC

GO
IF EXISTS (SELECT name FROM sys.indexes WHERE name = N'idx_nc_comments_postid')
	DROP INDEX idx_nc_comments_postid ON Comments;

CREATE NONCLUSTERED INDEX idx_nc_comments_postid
ON Comments(postid)

GO

SELECT *
FROM Comments
WITH (INDEX(idx_nc_comments_postid))
where postid = 3

SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRAN

	SELECT * FROM Users WHERE uid = 1
	WAITFOR DELAY '00:00:03'
	SELECT * FROM Users WHERE uid =1
COMMIT TRAN


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>vista Class Hierarchy</title>
<meta name="date" content="2016-06-09">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Hierarchy For Package vista

Package Hierarchies:

All Packages

Class Hierarchy

java.lang.Object

java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable)

java.awt.Container

java.awt.Window (implements javax.accessibility.Accessible)

java.awt.Frame (implements java.awt.MenuContainer)

javax.swing.JFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants)

vista.Cambio

vista.Comprar

vista.DetalleChocolates

vista.DetalleDulces

vista.DetalleGalletas

vista.DetalleRefrescos

vista.Opciones

vista.Screen

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
require 'spec_helper'

describe "resetting contexts" do
  after(:all) do
    Hyperloop::Context.instance_variable_set(:@context, nil)
  end

  it "resets everything nicely on the server" do
    Hyperloop::Context.reset!
    stub_const 'Operation', Class.new(Hyperloop::Operation)
    expect(Operation).to receive(:receiver).once.with({bar: 'goodgood'})
    Operation.class_eval do
      param :foo
      validate { false }
      step { abort! }
      on_dispatch { receiver }
    end
    expect(Operation.run(bar: 'good')).not_to be_resolved
    Hyperloop::Context.reset!
    Operation.class_eval do
      param :bar
      validate { params.bar == 'good' }
      step { params.bar = params.bar * 2 }
      on_dispatch { |params| receiver(params.to_h) }
    end
    expect(Operation.run(bar: 'good')).to be_resolved
  end

  it "resets operations nicely on the client", js: true do
    expect_promise do
      Hyperloop::Context.reset!
      class Operation < Hyperloop::Operation
        param :foo
        validate { false }
        step { abort! }
        on_dispatch { receiver }
      end
      Hyperloop::Context.reset!
      class Operation < Hyperloop::Operation
        param :bar
        validate { params.bar == 'good' }
        step { params.bar * 2 }
      end
      Operation.run(bar: 'good')
    end.to eq('goodgood')
  end

  it "does not reset any predefined boot receivers", js: true do
    on_client do
      class Store < Hyperloop::Store
        class << self
          attr_reader :boot_calls
          attr_reader :another_receiver_calls
          def booted
            puts "  booted called"
            @boot_calls ||= 0
            @boot_calls += 1
          end
          def another_receiver
            puts "  receiver called"
            @another_receiver_calls ||= 0
            @another_receiver_calls += 1
          end
        end
        receives Hyperloop::Application::Boot, :booted
      end
      puts ">>resetting"
      Hyperloop::Context.reset!(reboot = nil)
      class Store < Hyperloop::Store
        receives Hyperloop::Application::Boot, :another_receiver
      end
    end
    evaluate_ruby("puts '>>booting'") # do a separate evaluation to get initial boot completed
    evaluate_ruby do
      puts '>>resetting again'
      Hyperloop::Context.reset!(nil)
      puts '>>booting again'
      Hyperloop::Application::Boot.run
    end
    expect_evaluate_ruby('Store.boot_calls').to eq(2)
    expect_evaluate_ruby('Store.another_receiver_calls').to eq(1)
  end
end


text:
import {AfterViewInit, Component, forwardRef, Inject, OnDestroy, OnInit} from '@angular/core';
import {AlertController, IonicPage, NavController, NavParams} from 'ionic-angular';
import {GAPIS} from "../../common/gapis-auth";
import {Logger, LoggingService} from "ionic-logging-service";
import {SheetSelectionPage} from "../sheet-selection/sheet-selection";
import {RootStore} from "../../store/root";
import {Preferences} from "../../scheduling/people";
import {PageUtils} from "../page-utils";
import {SWBSafeJSON} from "../../common/json/safe-stringify";
import {Subject} from "rxjs";
import {take, takeUntil} from "rxjs/operators";
import {action, computed, observable} from "mobx-angular";
import Spreadsheet = gapi.client.sheets.Spreadsheet;

@IonicPage({
    name: 'page-share',
    defaultHistory: ['home']
})
@Component({
    selector: 'page-share',
    templateUrl: 'share.html',
    // changeDetection: ChangeDetectionStrategy.OnPush
})
export class SharePage implements OnInit, AfterViewInit, OnDestroy {
    private logger: Logger;

    @observable selectedSheet: Spreadsheet;
    selectedSheetTabName: string = "";
    isExporting: boolean;
    exportProgress: number;
    private ngUnsubscribe: Subject<any>;

    constructor(public navCtrl: NavController,
                @Inject(forwardRef(() => GAPIS)) public sheetAPI,
                private store: RootStore,
                private alertCtrlr: AlertController,
                private pageUtils: PageUtils,
                private logService: LoggingService,
                public navParams: NavParams) {
        this.logger = this.logService.getLogger("page.share");
        this.ngUnsubscribe = new Subject();
    }

    ngOnInit() {
    }

    ngAfterViewInit() {
        if (this.store.loggedInPerson == null) {
            this.logger.info('ngAfterViewInit', `opps no person! bye!`);
            if (this.navCtrl.canGoBack()) {
                this.navCtrl.pop();
            }
            return;
        }

        this.logger.info("ngAfterViewInit", "start of init");
        this.sheetAPI.selectedSheet$.pipe(
            takeUntil(this.ngUnsubscribe)
        ).subscribe(aSheet => {
            this.selectSheet(aSheet);
        })
    }

    ngOnDestroy() {
        this.ngUnsubscribe.next();
        this.ngUnsubscribe.complete();
        this.logger.info(`Share ngOnDestroy`);
    }

    @computed get canExportSheet(): boolean {
        if (this.isExporting) {
            return false;
        }
        return this.selectedSheet !== undefined && this.preferences.google_sheet_tab_id != null;
    }

    exportScheduleToSheet() {
        if (!this.canExportSheet) {
            return;
        }

        const alert = this.alertCtrlr.create({
            title: "Are you sure?",
            subTitle: "This will erase everything in the selected sheet",
            buttons: [
                {
                    text: "No",
                    role: "danger"
                },
                {
                    text: "Yes",
                    handler: () => {
                        this._exportScheduleToSheet();
                    }
                },
            ]
        });
        alert.present();
    }

    /*
    You can downgrade to your old version by running: npm i --save -E ionic@3.20.0
     */
    private async _exportScheduleToSheet() {
        this.exportProgress = 0;
        let schedule = await this.store.schedule$.pipe(take(1)).toPromise();
        if (schedule) {
            if (schedule) {
                let sheet = this.sheetAPI.findSheetWithIDIn(this.selectedSheet, this.preferences.google_sheet_tab_id);
                let progressSubscription = this.sheetAPI.progress.subscribe(progressValue => {
                    this.isExporting = true;
                    this.exportProgress = progressValue * 100;
                });
                try {
                    await this.sheetAPI.clearAndWriteSchedule(this.selectedSheet, sheet, schedule);
                    this.pageUtils.showMessage('Exported successfully');
                    this.isExporting = false;
                    this.exportProgress = 0;
                } catch (err) {
                    let message = err['result']['error']['message'] || err;
                    this.logger.error(`Error: ${SWBSafeJSON.stringify(message)}`);
                    this.pageUtils.showError(message, true);
                }

                progressSubscription.unsubscribe();
            }
        } else {
            this.pageUtils.showError('No schedule');
        }
    }

    @computed get loggedInToGoogle(): boolean {
        return this.sheetAPI.isSignedInToGoogle;
    }

    loginToGoogle() {
        this.sheetAPI.authenticate().subscribe();
    }

    logoutOfGoogle() {
        this.sheetAPI.signout().subscribe();
    }

    get preferences(): Preferences {
        if (this.store) {
            if (this.store.loggedInPerson) {
                return this.store.loggedInPerson.preferences;
            }
        }
        return null;
    }

    clearSheetSelection() {
        this.preferences.clearSelectedSheet();
    }

    selectSheetToExportInto() {
        // Get the sheet and make sure we can read it.
        let prefs = this.preferences;
        if (!prefs) {
            this.logger.error(`No preferences. Can't do stuff`);
            return;
        }

        this.navCtrl.push(SheetSelectionPage, {
            title: "Select sheet to export into",
            tab_title: "Select tab to export into",
            done: (spreadsheet, sheet, error) => {
                prefs.setSheetToExportTo(spreadsheet.spreadsheetId, sheet.properties.sheetId);
                console.log("Done. Selected sheet: " + spreadsheet.spreadsheetId + ", and tab: " + sheet.properties.title);
            }
        });
    }

    select_previous_schedule() {
        // this.navCtrl.push(SheetSelectionPage, {
        //     title: "Select sheet to use as previous schedule",
        //     tab_title: "Select tab to use as previous schedule",
        //     done: (spreadsheet, sheet, error) => {
        //         console.log("Done. Selected sheet: " + spreadsheet.spreadsheetId + ", and tab: " + sheet.properties.title + ", " + sheet.properties.sheetId);
        //         this.store.state.previous_sheet_id = spreadsheet.spreadsheetId;
        //         this.store.state.previous_sheet_tab_id = sheet.properties.sheetId;
        //     }
        // });
    }

    read_as_previous_schedule() {
        // if (this.store.ui_store.preferences.have_previous_selection) {
        //     let sheet_id = this.store.ui_store.preferences.previous_sheet_id;
        //     this.sheetAPI.load_sheet_with_id(sheet_id).subscribe((spreadsheet) => {
        //         let sheet = spreadsheet.sheets.find(s => s.properties.sheetId == this.store.state.previous_sheet_tab_id);
        //         this.sheetAPI.read_spreadsheet_data(spreadsheet, sheet).subscribe(rows => {
        //
        //             let reader = new SpreadsheetReader(this.store.people);
        //             reader.parse_schedule_from_spreadsheet(rows);
        //
        //             if (reader.has_problems) {
        //                 let dump_map = {};
        //                 for (let key of Array.from(reader.problems.keys())) {
        //                     dump_map[key] = Array.from(reader.problems.get(key));
        //                 }
        //                 let problems = toJS(dump_map);
        //                 let s = SafeJSON.stringify(problems);
        //                 this.logger.info(`Had problems: ${s}`);
        //             }
        //             this.logger.info("Made schedule!");
        //             this.store.setPreviousSchedule(reader.schedule);
        //         });
        //     });
        // }
    }

    @action
    private selectSheet(aSheet: any) {
        if (aSheet) {
            const tabId = this.preferences.google_sheet_tab_id;
            if (tabId) {
                let sheet = this.sheetAPI.findSheetWithIDIn(aSheet, tabId);
                if (sheet !== undefined) {
                    this.selectedSheetTabName = sheet.properties.title;
                    this.selectedSheet = aSheet;
                    this.logger.info("ngAfterViewInit", `Selected sheet: ${this.selectedSheet.properties.title}`);
                    return;
                }
            }

            this.selectedSheetTabName = "<not selected>";
            this.selectedSheet = null;
            this.logger.info("ngAfterViewInit", `No selected sheet?`);
        }
    }
}


text:
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Home
 *
 * @ORM\Table(name="home")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\HomeRepository")
 */
class Home {

}
?>


text:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public enum BeaversManagerState{
	GameStarting,
	LettingPlayerCutDowntree,
	Assault

}

public class BeaversManager : MonoBehaviour {

	[SerializeField]
	private GameObject m_beaverPrefab;

	[SerializeField]
	private GameObject m_beaverContainer;
	private List<Beaver> m_listBeavers;

	private treeManager m_treeManager;

	public Action<int> onBeaverKilledListener;

	private BeaversManagerState m_currentState;

	private int m_beaverCreated = 0;
	private int m_beaverKilledTotal = 0;

	// Use this for initialization
	void Start () {
		m_listBeavers = new List<Beaver> ();
		m_beaverContainer.transform.position = GameObject.FindGameObjectWithTag ("SpawnArea").transform.position;

		m_currentState = BeaversManagerState.GameStarting;

		m_timeStateStarted[(int)m_currentState] = Time.time;

		m_treeManager = GameObject.FindGameObjectWithTag ("TreeManager").GetComponent<treeManager>();
	}

	private float m_lastCreated;
	public float[] m_frequenceCreationBeaver = new float[]{
		0, //GameStarting
		0.333f,	//LettingPlayerCutDowntree
		2f	//Assault
	};

	private float[] m_timeStateStarted = new float[]{
		0,
		0f,	//LettingPlayerCutDowntree
		0f	//Assault
	};
	private float[] m_timeToStayInState = new float[]{
		8f,
		8f,	//LettingPlayerCutDowntree
		10f		//Assault
	};
	// Update is called once per frame
	void Update () {
		if (m_beaverCreated - m_beaverKilledTotal >= 50) {
			m_currentState = BeaversManagerState.LettingPlayerCutDowntree;
			return;
		}

		if (m_currentState == BeaversManagerState.GameStarting) {
			if (Time.time - m_timeStateStarted [(int)m_currentState] > m_timeToStayInState [(int)m_currentState]) {
				int cur = (int)m_currentState;
				cur++;
				m_currentState = (BeaversManagerState)cur;
				m_timeStateStarted[(int)m_currentState] = Time.time;
				return;
			}
		}

		if(Time.time - m_lastCreated >= 1/m_frequenceCreationBeaver[(int)m_currentState]){
			CreateBeaver();
			m_lastCreated = Time.time;
		}

		//Change State lorsque temps écoulé
		if (Time.time - m_timeStateStarted [(int)m_currentState] > m_timeToStayInState [(int)m_currentState]) {
			int cur = (int)m_currentState;
			cur = (cur+1)%3;
			if(cur == 0){
				cur = 1;

			}
			m_currentState = (BeaversManagerState)cur;
			m_timeStateStarted[(int)m_currentState] = Time.time;
		}
	}

	public void SmashBeaversHangOnTree(){
		foreach(Beaver beav in m_listBeavers){
			if(beav.getCurrentState() == BeaverState.HangOnTree){
				beav.changeState(BeaverState.Flying);
			}
		}
	}

	public void destroyBeaversOnTree(){
		foreach (Beaver beav in m_listBeavers) {
			if (beav.getCurrentState () == BeaverState.HangOnTree) {
				beav.transform.position = new Vector3(
					-GameObject.FindGameObjectWithTag ("SpawnArea").transform.position.x,
					beav.transform.position.y,
					beav.transform.position.z
					);
				beav.changeState(BeaverState.Running);
			}
		}
	}

	void CreateBeaver(){
		m_beaverCreated++;
		GameObject plop = Instantiate (m_beaverPrefab);
		plop.transform.SetParent (m_beaverContainer.transform);
		plop.transform.localPosition = Vector3.zero;
		plop.name = "Beaver_"+m_beaverCreated.ToString();

		Beaver beav = plop.gameObject.GetComponent<Beaver> ();
		beav.destroyListener += removeBeaver;
		beav.Initialize (m_treeManager);

		m_listBeavers.Add (plop.gameObject.GetComponent<Beaver> ());
	}

	public void letThePlayerCuttingDownTree(){
		m_currentState = BeaversManagerState.LettingPlayerCutDowntree;
		m_timeStateStarted[1] = Time.time;
	}

 	void removeBeaver(Beaver beav){
		beav.destroyListener -= removeBeaver;
		m_listBeavers.Remove (beav);
		m_beaverKilledTotal++;
		if (onBeaverKilledListener != null) {
			onBeaverKilledListener(m_beaverKilledTotal);
		}
	}

	public void Restart(){
		m_currentState = BeaversManagerState.GameStarting;

		m_timeStateStarted[(int)m_currentState] = Time.time;
		m_beaverCreated = 0;
		m_beaverKilledTotal = 0;
		if (m_listBeavers!=null) {
			foreach (Beaver b in m_listBeavers) {
				GameObject.Destroy (b.gameObject);
			}
			m_listBeavers.Clear ();
		}
	}

	public int getBeaverOnScreen(){
		return m_beaverCreated - m_beaverKilledTotal;

	}

	public int getBeaverKilledTotal() {
		return m_beaverKilledTotal;
	}
}


text:
import React, { Component } from 'react';
import { Switch, Route } from 'react-router';
import { ConnectedRouter } from 'react-router-redux';
import { Provider } from 'react-redux';
import createHistory from 'history/createBrowserHistory';
import { withRouter } from 'react-router-dom';
import configureStore from './store/configureStore';
import Main from './containers/Main';
import Share from './containers/Share';
import SignIn from './containers/SignIn';
import SignUp from './containers/SignUp';
import Forgot from './containers/Forgot';

const history = createHistory();

const store = configureStore();

export { history };

export default class extends Component {
  render() {
    return (
      <Provider store={store}>
        <ConnectedRouter history={history}>
          <Switch>
            <Route exact path="/signin" component={withRouter(SignIn)} />
            <Route exact path="/signup" component={withRouter(SignUp)} />
            <Route exact path="/forgot" component={withRouter(Forgot)} />
            <Route exact path="/share" component={withRouter(Share)} />
            <Route path="/" component={withRouter(Main)} />
          </Switch>
        </ConnectedRouter>
      </Provider>
    );
  }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Constant Field Values</title>
<meta name="date" content="2016-03-03">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Package

Class

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Constant Field Values

Contents

fr.rouen.*

fr.rouen.*

fr.rouen.univ.fdd.model.Main

Modifier and Type
Constant Field
Value

public static final double
BASE_CONFIDENCE
0.0

public static final double
BASE_SUPPORT
0.3333333333333333

public static final java.lang.String
SAMPLE_FILE
"sample.data"

Skip navigation links

Package

Class

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
Author: Yoav Ram

[**GrowthRates**](https://sourceforge.net/projects/growthrates/) is a program for analysis of growth curve data, published in:
> Hall, B. G., H. Acar and M. Barlow. 2014 Growth Rates Made Easy. Mol. Biol. Evol. 31: 232-238 doi:10.1093/molbev/mst197

**GrowthRatesPy** provides a Python API for using **GrowthRates** from within Python code.

See the [documentation](https://yoavram.github.io/GrowthRatesPy/) for more details.


text:
#ifndef ARCHIVE_H_INCLUDED
#define	ARCHIVE_H_INCLUDED

/*
 * The version number is expressed as a single integer that makes it
 * easy to compare versions at build time: for version a.b.c, the
 * version number is printf("%d%03d%03d",a,b,c).  For example, if you
 * know your application requires version 2.12.108 or later, you can
 * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
 */
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define	ARCHIVE_VERSION_NUMBER 3003002

#include <sys/stat.h>
#include <stddef.h>  /* for wchar_t */
#include <stdio.h> /* For FILE * */
#include <time.h> /* For time_t */

/*
 * Note: archive.h is for use outside of libarchive; the configuration
 * headers (config.h, archive_platform.h, etc.) are purely internal.
 * Do NOT use HAVE_XXX configuration macros to control the behavior of
 * this header!  If you must conditionalize, use predefined compiler and/or
 * platform macros.
 */
#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
# include <stdint.h>
#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__) && !defined(_SCO_DS) && !defined(__osf__)
# include <inttypes.h>
#endif

/* Get appropriate definitions of 64-bit integer */
#if !defined(__LA_INT64_T_DEFINED)
/* Older code relied on the __LA_INT64_T macro; after 4.0 we'll switch to the typedef exclusively. */
# if ARCHIVE_VERSION_NUMBER < 4000000
#define __LA_INT64_T la_int64_t
# endif
#define __LA_INT64_T_DEFINED
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
typedef __int64 la_int64_t;
# else
# include <unistd.h>  /* ssize_t */
#  if defined(_SCO_DS) || defined(__osf__)
typedef long long la_int64_t;
#  else
typedef int64_t la_int64_t;
#  endif
# endif
#endif

/* The la_ssize_t should match the type used in 'struct stat' */
#if !defined(__LA_SSIZE_T_DEFINED)
/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
# if ARCHIVE_VERSION_NUMBER < 4000000
#define __LA_SSIZE_T la_ssize_t
# endif
#define __LA_SSIZE_T_DEFINED
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
#  if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
typedef ssize_t la_ssize_t;
#  elif defined(_WIN64)
typedef __int64 la_ssize_t;
#  else
typedef long la_ssize_t;
#  endif
# else
# include <unistd.h>  /* ssize_t */
typedef ssize_t la_ssize_t;
# endif
#endif

/* Large file support for Android */
#ifdef __ANDROID__
#include "android_lf.h"
#endif

/*
 * On Windows, define LIBARCHIVE_STATIC if you're building or using a
 * .lib.  The default here assumes you're building a DLL.  Only
 * libarchive source should ever define __LIBARCHIVE_BUILD.
 */
#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
# ifdef __LIBARCHIVE_BUILD
#  ifdef __GNUC__
#   define __LA_DECL	__attribute__((dllexport)) extern
#  else
#   define __LA_DECL	__declspec(dllexport)
#  endif
# else
#  ifdef __GNUC__
#   define __LA_DECL
#  else
#   define __LA_DECL	__declspec(dllimport)
#  endif
# endif
#else
/* Static libraries or non-Windows needs no special declaration. */
# define __LA_DECL
#endif

#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__MINGW32__)
#define	__LA_PRINTF(fmtarg, firstvararg) \
	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#else
#define	__LA_PRINTF(fmtarg, firstvararg)	/* nothing */
#endif

#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
# define __LA_DEPRECATED __attribute__((deprecated))
#else
# define __LA_DEPRECATED
#endif

#ifdef __cplusplus
extern "C" {
#endif

/*
 * The version number is provided as both a macro and a function.
 * The macro identifies the installed header; the function identifies
 * the library version (which may not be the same if you're using a
 * dynamically-linked version of the library).  Of course, if the
 * header and library are very different, you should expect some
 * strangeness.  Don't do that.
 */
__LA_DECL int		archive_version_number(void);

/*
 * Textual name/version of the library, useful for version displays.
 */
#define	ARCHIVE_VERSION_ONLY_STRING "3.3.2"
#define	ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char *	archive_version_string(void);

/*
 * Detailed textual name/version of the library and its dependencies.
 * This has the form:
 *    "libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ..."
 * the list of libraries described here will vary depending on how
 * libarchive was compiled.
 */
__LA_DECL const char *	archive_version_details(void);

/*
 * Returns NULL if libarchive was compiled without the associated library.
 * Otherwise, returns the version number that libarchive was compiled
 * against.
 */
__LA_DECL const char *  archive_zlib_version(void);
__LA_DECL const char *  archive_liblzma_version(void);
__LA_DECL const char *  archive_bzlib_version(void);
__LA_DECL const char *  archive_liblz4_version(void);

/* Declare our basic types. */
struct archive;
struct archive_entry;

/*
 * Error codes: Use archive_errno() and archive_error_string()
 * to retrieve details.  Unless specified otherwise, all functions
 * that return 'int' use these codes.
 */
#define	ARCHIVE_EOF	  1	/* Found end of archive. */
#define	ARCHIVE_OK	  0	/* Operation was successful. */
#define	ARCHIVE_RETRY	(-10)	/* Retry might succeed. */
#define	ARCHIVE_WARN	(-20)	/* Partial success. */
/* For example, if write_header "fails", then you can't push data. */
#define	ARCHIVE_FAILED	(-25)	/* Current operation cannot complete. */
/* But if write_header is "fatal," then this archive is dead and useless. */
#define	ARCHIVE_FATAL	(-30)	/* No more operations are possible. */

/*
 * As far as possible, archive_errno returns standard platform errno codes.
 * Of course, the details vary by platform, so the actual definitions
 * here are stored in "archive_platform.h".  The symbols are listed here
 * for reference; as a rule, clients should not need to know the exact
 * platform-dependent error code.
 */
/* Unrecognized or invalid file format. */
/* #define	ARCHIVE_ERRNO_FILE_FORMAT */
/* Illegal usage of the library. */
/* #define	ARCHIVE_ERRNO_PROGRAMMER_ERROR */
/* Unknown or unclassified error. */
/* #define	ARCHIVE_ERRNO_MISC */

/*
 * Callbacks are invoked to automatically read/skip/write/open/close the
 * archive. You can provide your own for complex tasks (like breaking
 * archives across multiple tapes) or use standard ones built into the
 * library.
 */

/* Returns pointer and size of next block of data from archive. */
typedef la_ssize_t	archive_read_callback(struct archive *,
			    void *_client_data, const void **_buffer);

/* Skips at most request bytes from archive and returns the skipped amount.
 * This may skip fewer bytes than requested; it may even skip zero bytes.
 * If you do skip fewer bytes than requested, libarchive will invoke your
 * read callback and discard data as necessary to make up the full skip.
 */
typedef la_int64_t	archive_skip_callback(struct archive *,
			    void *_client_data, la_int64_t request);

/* Seeks to specified location in the file and returns the position.
 * Whence values are SEEK_SET, SEEK_CUR, SEEK_END from stdio.h.
 * Return ARCHIVE_FATAL if the seek fails for any reason.
 */
typedef la_int64_t	archive_seek_callback(struct archive *,
    void *_client_data, la_int64_t offset, int whence);

/* Returns size actually written, zero on EOF, -1 on error. */
typedef la_ssize_t	archive_write_callback(struct archive *,
			    void *_client_data,
			    const void *_buffer, size_t _length);

typedef int	archive_open_callback(struct archive *, void *_client_data);

typedef int	archive_close_callback(struct archive *, void *_client_data);

/* Switches from one client data object to the next/prev client data object.
 * This is useful for reading from different data blocks such as a set of files
 * that make up one large file.
 */
typedef int archive_switch_callback(struct archive *, void *_client_data1,
			    void *_client_data2);

/*
 * Returns a passphrase used for encryption or decryption, NULL on nothing
 * to do and give it up.
 */
typedef const char *archive_passphrase_callback(struct archive *,
			    void *_client_data);

/*
 * Codes to identify various stream filters.
 */
#define	ARCHIVE_FILTER_NONE	0
#define	ARCHIVE_FILTER_GZIP	1
#define	ARCHIVE_FILTER_BZIP2	2
#define	ARCHIVE_FILTER_COMPRESS	3
#define	ARCHIVE_FILTER_PROGRAM	4
#define	ARCHIVE_FILTER_LZMA	5
#define	ARCHIVE_FILTER_XZ	6
#define	ARCHIVE_FILTER_UU	7
#define	ARCHIVE_FILTER_RPM	8
#define	ARCHIVE_FILTER_LZIP	9
#define	ARCHIVE_FILTER_LRZIP	10
#define	ARCHIVE_FILTER_LZOP	11
#define	ARCHIVE_FILTER_GRZIP	12
#define	ARCHIVE_FILTER_LZ4	13

#if ARCHIVE_VERSION_NUMBER < 4000000
#define	ARCHIVE_COMPRESSION_NONE	ARCHIVE_FILTER_NONE
#define	ARCHIVE_COMPRESSION_GZIP	ARCHIVE_FILTER_GZIP
#define	ARCHIVE_COMPRESSION_BZIP2	ARCHIVE_FILTER_BZIP2
#define	ARCHIVE_COMPRESSION_COMPRESS	ARCHIVE_FILTER_COMPRESS
#define	ARCHIVE_COMPRESSION_PROGRAM	ARCHIVE_FILTER_PROGRAM
#define	ARCHIVE_COMPRESSION_LZMA	ARCHIVE_FILTER_LZMA
#define	ARCHIVE_COMPRESSION_XZ		ARCHIVE_FILTER_XZ
#define	ARCHIVE_COMPRESSION_UU		ARCHIVE_FILTER_UU
#define	ARCHIVE_COMPRESSION_RPM		ARCHIVE_FILTER_RPM
#define	ARCHIVE_COMPRESSION_LZIP	ARCHIVE_FILTER_LZIP
#define	ARCHIVE_COMPRESSION_LRZIP	ARCHIVE_FILTER_LRZIP
#endif

/*
 * Codes returned by archive_format.
 *
 * Top 16 bits identifies the format family (e.g., "tar"); lower
 * 16 bits indicate the variant.  This is updated by read_next_header.
 * Note that the lower 16 bits will often vary from entry to entry.
 * In some cases, this variation occurs as libarchive learns more about
 * the archive (for example, later entries might utilize extensions that
 * weren't necessary earlier in the archive; in this case, libarchive
 * will change the format code to indicate the extended format that
 * was used).  In other cases, it's because different tools have
 * modified the archive and so different parts of the archive
 * actually have slightly different formats.  (Both tar and cpio store
 * format codes in each entry, so it is quite possible for each
 * entry to be in a different format.)
 */
#define	ARCHIVE_FORMAT_BASE_MASK		0xff0000
#define	ARCHIVE_FORMAT_CPIO			0x10000
#define	ARCHIVE_FORMAT_CPIO_POSIX		(ARCHIVE_FORMAT_CPIO | 1)
#define	ARCHIVE_FORMAT_CPIO_BIN_LE		(ARCHIVE_FORMAT_CPIO | 2)
#define	ARCHIVE_FORMAT_CPIO_BIN_BE		(ARCHIVE_FORMAT_CPIO | 3)
#define	ARCHIVE_FORMAT_CPIO_SVR4_NOCRC		(ARCHIVE_FORMAT_CPIO | 4)
#define	ARCHIVE_FORMAT_CPIO_SVR4_CRC		(ARCHIVE_FORMAT_CPIO | 5)
#define	ARCHIVE_FORMAT_CPIO_AFIO_LARGE		(ARCHIVE_FORMAT_CPIO | 6)
#define	ARCHIVE_FORMAT_SHAR			0x20000
#define	ARCHIVE_FORMAT_SHAR_BASE		(ARCHIVE_FORMAT_SHAR | 1)
#define	ARCHIVE_FORMAT_SHAR_DUMP		(ARCHIVE_FORMAT_SHAR | 2)
#define	ARCHIVE_FORMAT_TAR			0x30000
#define	ARCHIVE_FORMAT_TAR_USTAR		(ARCHIVE_FORMAT_TAR | 1)
#define	ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE	(ARCHIVE_FORMAT_TAR | 2)
#define	ARCHIVE_FORMAT_TAR_PAX_RESTRICTED	(ARCHIVE_FORMAT_TAR | 3)
#define	ARCHIVE_FORMAT_TAR_GNUTAR		(ARCHIVE_FORMAT_TAR | 4)
#define	ARCHIVE_FORMAT_ISO9660			0x40000
#define	ARCHIVE_FORMAT_ISO9660_ROCKRIDGE	(ARCHIVE_FORMAT_ISO9660 | 1)
#define	ARCHIVE_FORMAT_ZIP			0x50000
#define	ARCHIVE_FORMAT_EMPTY			0x60000
#define	ARCHIVE_FORMAT_AR			0x70000
#define	ARCHIVE_FORMAT_AR_GNU			(ARCHIVE_FORMAT_AR | 1)
#define	ARCHIVE_FORMAT_AR_BSD			(ARCHIVE_FORMAT_AR | 2)
#define	ARCHIVE_FORMAT_MTREE			0x80000
#define	ARCHIVE_FORMAT_RAW			0x90000
#define	ARCHIVE_FORMAT_XAR			0xA0000
#define	ARCHIVE_FORMAT_LHA			0xB0000
#define	ARCHIVE_FORMAT_CAB			0xC0000
#define	ARCHIVE_FORMAT_RAR			0xD0000
#define	ARCHIVE_FORMAT_7ZIP			0xE0000
#define	ARCHIVE_FORMAT_WARC			0xF0000

/*
 * Codes returned by archive_read_format_capabilities().
 *
 * This list can be extended with values between 0 and 0xffff.
 * The original purpose of this list was to let different archive
 * format readers expose their general capabilities in terms of
 * encryption.
 */
#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0)  /* reader can detect encrypted data */
#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1)  /* reader can detect encryptable metadata (pathname, mtime, etc.) */

/*
 * Codes returned by archive_read_has_encrypted_entries().
 *
 * In case the archive does not support encryption detection at all
 * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
 * for some other reason (e.g. not enough bytes read) cannot say if
 * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
 * is returned.
 */
#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1

/*-
 * Basic outline for reading an archive:
 *   1) Ask archive_read_new for an archive reader object.
 *   2) Update any global properties as appropriate.
 *      In particular, you'll certainly want to call appropriate
 *      archive_read_support_XXX functions.
 *   3) Call archive_read_open_XXX to open the archive
 *   4) Repeatedly call archive_read_next_header to get information about
 *      successive archive entries.  Call archive_read_data to extract
 *      data for entries of interest.
 *   5) Call archive_read_free to end processing.
 */
__LA_DECL struct archive	*archive_read_new(void);

/*
 * The archive_read_support_XXX calls enable auto-detect for this
 * archive handle.  They also link in the necessary support code.
 * For example, if you don't want bzlib linked in, don't invoke
 * support_compression_bzip2().  The "all" functions provide the
 * obvious shorthand.
 */

#if ARCHIVE_VERSION_NUMBER < 4000000
__LA_DECL int archive_read_support_compression_all(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_bzip2(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_compress(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_gzip(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_lzip(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_lzma(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_none(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_program(struct archive *,
		     const char *command) __LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_program_signature
		(struct archive *, const char *,
		 const void * /* match */, size_t) __LA_DEPRECATED;

__LA_DECL int archive_read_support_compression_rpm(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_uu(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_read_support_compression_xz(struct archive *)
		__LA_DEPRECATED;
#endif

__LA_DECL int archive_read_support_filter_all(struct archive *);
__LA_DECL int archive_read_support_filter_bzip2(struct archive *);
__LA_DECL int archive_read_support_filter_compress(struct archive *);
__LA_DECL int archive_read_support_filter_gzip(struct archive *);
__LA_DECL int archive_read_support_filter_grzip(struct archive *);
__LA_DECL int archive_read_support_filter_lrzip(struct archive *);
__LA_DECL int archive_read_support_filter_lz4(struct archive *);
__LA_DECL int archive_read_support_filter_lzip(struct archive *);
__LA_DECL int archive_read_support_filter_lzma(struct archive *);
__LA_DECL int archive_read_support_filter_lzop(struct archive *);
__LA_DECL int archive_read_support_filter_none(struct archive *);
__LA_DECL int archive_read_support_filter_program(struct archive *,
		     const char *command);
__LA_DECL int archive_read_support_filter_program_signature
		(struct archive *, const char * /* cmd */,
				    const void * /* match */, size_t);
__LA_DECL int archive_read_support_filter_rpm(struct archive *);
__LA_DECL int archive_read_support_filter_uu(struct archive *);
__LA_DECL int archive_read_support_filter_xz(struct archive *);

__LA_DECL int archive_read_support_format_7zip(struct archive *);
__LA_DECL int archive_read_support_format_all(struct archive *);
__LA_DECL int archive_read_support_format_ar(struct archive *);
__LA_DECL int archive_read_support_format_by_code(struct archive *, int);
__LA_DECL int archive_read_support_format_cab(struct archive *);
__LA_DECL int archive_read_support_format_cpio(struct archive *);
__LA_DECL int archive_read_support_format_empty(struct archive *);
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
__LA_DECL int archive_read_support_format_lha(struct archive *);
__LA_DECL int archive_read_support_format_mtree(struct archive *);
__LA_DECL int archive_read_support_format_rar(struct archive *);
__LA_DECL int archive_read_support_format_raw(struct archive *);
__LA_DECL int archive_read_support_format_tar(struct archive *);
__LA_DECL int archive_read_support_format_warc(struct archive *);
__LA_DECL int archive_read_support_format_xar(struct archive *);
/* archive_read_support_format_zip() enables both streamable and seekable
 * zip readers. */
__LA_DECL int archive_read_support_format_zip(struct archive *);
/* Reads Zip archives as stream from beginning to end.  Doesn't
 * correctly handle SFX ZIP files or ZIP archives that have been modified
 * in-place. */
__LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
/* Reads starting from central directory; requires seekable input. */
__LA_DECL int archive_read_support_format_zip_seekable(struct archive *);

/* Functions to manually set the format and filters to be used. This is
 * useful to bypass the bidding process when the format and filters to use
 * is known in advance.
 */
__LA_DECL int archive_read_set_format(struct archive *, int);
__LA_DECL int archive_read_append_filter(struct archive *, int);
__LA_DECL int archive_read_append_filter_program(struct archive *,
    const char *);
__LA_DECL int archive_read_append_filter_program_signature
    (struct archive *, const char *, const void * /* match */, size_t);

/* Set various callbacks. */
__LA_DECL int archive_read_set_open_callback(struct archive *,
    archive_open_callback *);
__LA_DECL int archive_read_set_read_callback(struct archive *,
    archive_read_callback *);
__LA_DECL int archive_read_set_seek_callback(struct archive *,
    archive_seek_callback *);
__LA_DECL int archive_read_set_skip_callback(struct archive *,
    archive_skip_callback *);
__LA_DECL int archive_read_set_close_callback(struct archive *,
    archive_close_callback *);
/* Callback used to switch between one data object to the next */
__LA_DECL int archive_read_set_switch_callback(struct archive *,
    archive_switch_callback *);

/* This sets the first data object. */
__LA_DECL int archive_read_set_callback_data(struct archive *, void *);
/* This sets data object at specified index */
__LA_DECL int archive_read_set_callback_data2(struct archive *, void *,
    unsigned int);
/* This adds a data object at the specified index. */
__LA_DECL int archive_read_add_callback_data(struct archive *, void *,
    unsigned int);
/* This appends a data object to the end of list */
__LA_DECL int archive_read_append_callback_data(struct archive *, void *);
/* This prepends a data object to the beginning of list */
__LA_DECL int archive_read_prepend_callback_data(struct archive *, void *);

/* Opening freezes the callbacks. */
__LA_DECL int archive_read_open1(struct archive *);

/* Convenience wrappers around the above. */
__LA_DECL int archive_read_open(struct archive *, void *_client_data,
		     archive_open_callback *, archive_read_callback *,
		     archive_close_callback *);
__LA_DECL int archive_read_open2(struct archive *, void *_client_data,
		     archive_open_callback *, archive_read_callback *,
		     archive_skip_callback *, archive_close_callback *);

/*
 * A variety of shortcuts that invoke archive_read_open() with
 * canned callbacks suitable for common situations.  The ones that
 * accept a block size handle tape blocking correctly.
 */
/* Use this if you know the filename.  Note: NULL indicates stdin. */
__LA_DECL int archive_read_open_filename(struct archive *,
		     const char *_filename, size_t _block_size);
/* Use this for reading multivolume files by filenames.
 * NOTE: Must be NULL terminated. Sorting is NOT done. */
__LA_DECL int archive_read_open_filenames(struct archive *,
		     const char **_filenames, size_t _block_size);
__LA_DECL int archive_read_open_filename_w(struct archive *,
		     const wchar_t *_filename, size_t _block_size);
/* archive_read_open_file() is a deprecated synonym for ..._open_filename(). */
__LA_DECL int archive_read_open_file(struct archive *,
		     const char *_filename, size_t _block_size) __LA_DEPRECATED;
/* Read an archive that's stored in memory. */
__LA_DECL int archive_read_open_memory(struct archive *,
		     const void * buff, size_t size);
/* A more involved version that is only used for internal testing. */
__LA_DECL int archive_read_open_memory2(struct archive *a, const void *buff,
		     size_t size, size_t read_size);
/* Read an archive that's already open, using the file descriptor. */
__LA_DECL int archive_read_open_fd(struct archive *, int _fd,
		     size_t _block_size);
/* Read an archive that's already open, using a FILE *. */
/* Note: DO NOT use this with tape drives. */
__LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);

/* Parses and returns next entry header. */
__LA_DECL int archive_read_next_header(struct archive *,
		     struct archive_entry **);

/* Parses and returns next entry header using the archive_entry passed in */
__LA_DECL int archive_read_next_header2(struct archive *,
		     struct archive_entry *);

/*
 * Retrieve the byte offset in UNCOMPRESSED data where last-read
 * header started.
 */
__LA_DECL la_int64_t		 archive_read_header_position(struct archive *);

/*
 * Returns 1 if the archive contains at least one encrypted entry.
 * If the archive format not support encryption at all
 * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
 * If for any other reason (e.g. not enough data read so far)
 * we cannot say whether there are encrypted entries, then
 * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
 * In general, this function will return values below zero when the
 * reader is uncertain or totally incapable of encryption support.
 * When this function returns 0 you can be sure that the reader
 * supports encryption detection but no encrypted entries have
 * been found yet.
 *
 * NOTE: If the metadata/header of an archive is also encrypted, you
 * cannot rely on the number of encrypted entries. That is why this
 * function does not return the number of encrypted entries but#
 * just shows that there are some.
 */
__LA_DECL int	archive_read_has_encrypted_entries(struct archive *);

/*
 * Returns a bitmask of capabilities that are supported by the archive format reader.
 * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
 */
__LA_DECL int		 archive_read_format_capabilities(struct archive *);

/* Read data from the body of an entry.  Similar to read(2). */
__LA_DECL la_ssize_t		 archive_read_data(struct archive *,
				    void *, size_t);

/* Seek within the body of an entry.  Similar to lseek(2). */
__LA_DECL la_int64_t archive_seek_data(struct archive *, la_int64_t, int);

/*
 * A zero-copy version of archive_read_data that also exposes the file offset
 * of each returned block.  Note that the client has no way to specify
 * the desired size of the block.  The API does guarantee that offsets will
 * be strictly increasing and that returned blocks will not overlap.
 */
__LA_DECL int archive_read_data_block(struct archive *a,
		    const void **buff, size_t *size, la_int64_t *offset);

/*-
 * Some convenience functions that are built on archive_read_data:
 *  'skip': skips entire entry
 *  'into_buffer': writes data into memory buffer that you provide
 *  'into_fd': writes data to specified filedes
 */
__LA_DECL int archive_read_data_skip(struct archive *);
__LA_DECL int archive_read_data_into_fd(struct archive *, int fd);

/*
 * Set read options.
 */
/* Apply option to the format only. */
__LA_DECL int archive_read_set_format_option(struct archive *_a,
			    const char *m, const char *o,
			    const char *v);
/* Apply option to the filter only. */
__LA_DECL int archive_read_set_filter_option(struct archive *_a,
			    const char *m, const char *o,
			    const char *v);
/* Apply option to both the format and the filter. */
__LA_DECL int archive_read_set_option(struct archive *_a,
			    const char *m, const char *o,
			    const char *v);
/* Apply option string to both the format and the filter. */
__LA_DECL int archive_read_set_options(struct archive *_a,
			    const char *opts);

/*
 * Add a decryption passphrase.
 */
__LA_DECL int archive_read_add_passphrase(struct archive *, const char *);
__LA_DECL int archive_read_set_passphrase_callback(struct archive *,
			    void *client_data, archive_passphrase_callback *);

/*-
 * Convenience function to recreate the current entry (whose header
 * has just been read) on disk.
 *
 * This does quite a bit more than just copy data to disk. It also:
 *  - Creates intermediate directories as required.
 *  - Manages directory permissions:  non-writable directories will
 *    be initially created with write permission enabled; when the
 *    archive is closed, dir permissions are edited to the values specified
 *    in the archive.
 *  - Checks hardlinks:  hardlinks will not be extracted unless the
 *    linked-to file was also extracted within the same session. (TODO)
 */

/* The "flags" argument selects optional behavior, 'OR' the flags you want. */

/* Default: Do not try to set owner/group. */
#define	ARCHIVE_EXTRACT_OWNER			(0x0001)
/* Default: Do obey umask, do not restore SUID/SGID/SVTX bits. */
#define	ARCHIVE_EXTRACT_PERM			(0x0002)
/* Default: Do not restore mtime/atime. */
#define	ARCHIVE_EXTRACT_TIME			(0x0004)
/* Default: Replace existing files. */
#define	ARCHIVE_EXTRACT_NO_OVERWRITE 		(0x0008)
/* Default: Try create first, unlink only if create fails with EEXIST. */
#define	ARCHIVE_EXTRACT_UNLINK			(0x0010)
/* Default: Do not restore ACLs. */
#define	ARCHIVE_EXTRACT_ACL			(0x0020)
/* Default: Do not restore fflags. */
#define	ARCHIVE_EXTRACT_FFLAGS			(0x0040)
/* Default: Do not restore xattrs. */
#define	ARCHIVE_EXTRACT_XATTR 			(0x0080)
/* Default: Do not try to guard against extracts redirected by symlinks. */
/* Note: With ARCHIVE_EXTRACT_UNLINK, will remove any intermediate symlink. */
#define	ARCHIVE_EXTRACT_SECURE_SYMLINKS		(0x0100)
/* Default: Do not reject entries with '..' as path elements. */
#define	ARCHIVE_EXTRACT_SECURE_NODOTDOT		(0x0200)
/* Default: Create parent directories as needed. */
#define	ARCHIVE_EXTRACT_NO_AUTODIR		(0x0400)
/* Default: Overwrite files, even if one on disk is newer. */
#define	ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER	(0x0800)
/* Detect blocks of 0 and write holes instead. */
#define	ARCHIVE_EXTRACT_SPARSE			(0x1000)
/* Default: Do not restore Mac extended metadata. */
/* This has no effect except on Mac OS. */
#define	ARCHIVE_EXTRACT_MAC_METADATA		(0x2000)
/* Default: Use HFS+ compression if it was compressed. */
/* This has no effect except on Mac OS v10.6 or later. */
#define	ARCHIVE_EXTRACT_NO_HFS_COMPRESSION	(0x4000)
/* Default: Do not use HFS+ compression if it was not compressed. */
/* This has no effect except on Mac OS v10.6 or later. */
#define	ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED	(0x8000)
/* Default: Do not reject entries with absolute paths */
#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
/* Default: Do not clear no-change flags when unlinking object */
#define	ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS	(0x20000)

__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
		     int flags);
__LA_DECL int archive_read_extract2(struct archive *, struct archive_entry *,
		     struct archive * /* dest */);
__LA_DECL void	 archive_read_extract_set_progress_callback(struct archive *,
		     void (*_progress_func)(void *), void *_user_data);

/* Record the dev/ino of a file that will not be written.  This is
 * generally set to the dev/ino of the archive being read. */
__LA_DECL void		archive_read_extract_set_skip_file(struct archive *,
		     la_int64_t, la_int64_t);

/* Close the file and release most resources. */
__LA_DECL int		 archive_read_close(struct archive *);
/* Release all resources and destroy the object. */
/* Note that archive_read_free will call archive_read_close for you. */
__LA_DECL int		 archive_read_free(struct archive *);
#if ARCHIVE_VERSION_NUMBER < 4000000
/* Synonym for archive_read_free() for backwards compatibility. */
__LA_DECL int		 archive_read_finish(struct archive *) __LA_DEPRECATED;
#endif

/*-
 * To create an archive:
 *   1) Ask archive_write_new for an archive writer object.
 *   2) Set any global properties.  In particular, you should set
 *      the compression and format to use.
 *   3) Call archive_write_open to open the file (most people
 *       will use archive_write_open_file or archive_write_open_fd,
 *       which provide convenient canned I/O callbacks for you).
 *   4) For each entry:
 *      - construct an appropriate struct archive_entry structure
 *      - archive_write_header to write the header
 *      - archive_write_data to write the entry data
 *   5) archive_write_close to close the output
 *   6) archive_write_free to cleanup the writer and release resources
 */
__LA_DECL struct archive	*archive_write_new(void);
__LA_DECL int archive_write_set_bytes_per_block(struct archive *,
		     int bytes_per_block);
__LA_DECL int archive_write_get_bytes_per_block(struct archive *);
/* XXX This is badly misnamed; suggestions appreciated. XXX */
__LA_DECL int archive_write_set_bytes_in_last_block(struct archive *,
		     int bytes_in_last_block);
__LA_DECL int archive_write_get_bytes_in_last_block(struct archive *);

/* The dev/ino of a file that won't be archived.  This is used
 * to avoid recursively adding an archive to itself. */
__LA_DECL int archive_write_set_skip_file(struct archive *,
    la_int64_t, la_int64_t);

#if ARCHIVE_VERSION_NUMBER < 4000000
__LA_DECL int archive_write_set_compression_bzip2(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_compress(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_gzip(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_lzip(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_lzma(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_none(struct archive *)
		__LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_program(struct archive *,
		     const char *cmd) __LA_DEPRECATED;
__LA_DECL int archive_write_set_compression_xz(struct archive *)
		__LA_DEPRECATED;
#endif

/* A convenience function to set the filter based on the code. */
__LA_DECL int archive_write_add_filter(struct archive *, int filter_code);
__LA_DECL int archive_write_add_filter_by_name(struct archive *,
		     const char *name);
__LA_DECL int archive_write_add_filter_b64encode(struct archive *);
__LA_DECL int archive_write_add_filter_bzip2(struct archive *);
__LA_DECL int archive_write_add_filter_compress(struct archive *);
__LA_DECL int archive_write_add_filter_grzip(struct archive *);
__LA_DECL int archive_write_add_filter_gzip(struct archive *);
__LA_DECL int archive_write_add_filter_lrzip(struct archive *);
__LA_DECL int archive_write_add_filter_lz4(struct archive *);
__LA_DECL int archive_write_add_filter_lzip(struct archive *);
__LA_DECL int archive_write_add_filter_lzma(struct archive *);
__LA_DECL int archive_write_add_filter_lzop(struct archive *);
__LA_DECL int archive_write_add_filter_none(struct archive *);
__LA_DECL int archive_write_add_filter_program(struct archive *,
		     const char *cmd);
__LA_DECL int archive_write_add_filter_uuencode(struct archive *);
__LA_DECL int archive_write_add_filter_xz(struct archive *);

/* A convenience function to set the format based on the code or name. */
__LA_DECL int archive_write_set_format(struct archive *, int format_code);
__LA_DECL int archive_write_set_format_by_name(struct archive *,
		     const char *name);
/* To minimize link pollution, use one or more of the following. */
__LA_DECL int archive_write_set_format_7zip(struct archive *);
__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
__LA_DECL int archive_write_set_format_cpio(struct archive *);
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
__LA_DECL int archive_write_set_format_gnutar(struct archive *);
__LA_DECL int archive_write_set_format_iso9660(struct archive *);
__LA_DECL int archive_write_set_format_mtree(struct archive *);
__LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
__LA_DECL int archive_write_set_format_pax(struct archive *);
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
__LA_DECL int archive_write_set_format_raw(struct archive *);
__LA_DECL int archive_write_set_format_shar(struct archive *);
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
__LA_DECL int archive_write_set_format_ustar(struct archive *);
__LA_DECL int archive_write_set_format_v7tar(struct archive *);
__LA_DECL int archive_write_set_format_warc(struct archive *);
__LA_DECL int archive_write_set_format_xar(struct archive *);
__LA_DECL int archive_write_set_format_zip(struct archive *);
__LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const char *filename);
__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
__LA_DECL int archive_write_zip_set_compression_store(struct archive *);
__LA_DECL int archive_write_open(struct archive *, void *,
		     archive_open_callback *, archive_write_callback *,
		     archive_close_callback *);
__LA_DECL int archive_write_open_fd(struct archive *, int _fd);
__LA_DECL int archive_write_open_filename(struct archive *, const char *_file);
__LA_DECL int archive_write_open_filename_w(struct archive *,
		     const wchar_t *_file);
/* A deprecated synonym for archive_write_open_filename() */
__LA_DECL int archive_write_open_file(struct archive *, const char *_file)
		__LA_DEPRECATED;
__LA_DECL int archive_write_open_FILE(struct archive *, FILE *);
/* _buffSize is the size of the buffer, _used refers to a variable that
 * will be updated after each write into the buffer. */
__LA_DECL int archive_write_open_memory(struct archive *,
			void *_buffer, size_t _buffSize, size_t *_used);

/*
 * Note that the library will truncate writes beyond the size provided
 * to archive_write_header or pad if the provided data is short.
 */
__LA_DECL int archive_write_header(struct archive *,
		     struct archive_entry *);
__LA_DECL la_ssize_t	archive_write_data(struct archive *,
			    const void *, size_t);

/* This interface is currently only available for archive_write_disk handles.  */
__LA_DECL la_ssize_t	 archive_write_data_block(struct archive *,
				    const void *, size_t, la_int64_t);

__LA_DECL int		 archive_write_finish_entry(struct archive *);
__LA_DECL int		 archive_write_close(struct archive *);
/* Marks the archive as FATAL so that a subsequent free() operation
 * won't try to close() cleanly.  Provides a fast abort capability
 * when the client discovers that things have gone wrong. */
__LA_DECL int            archive_write_fail(struct archive *);
/* This can fail if the archive wasn't already closed, in which case
 * archive_write_free() will implicitly call archive_write_close(). */
__LA_DECL int		 archive_write_free(struct archive *);
#if ARCHIVE_VERSION_NUMBER < 4000000
/* Synonym for archive_write_free() for backwards compatibility. */
__LA_DECL int		 archive_write_finish(struct archive *) __LA_DEPRECATED;
#endif

/*
 * Set write options.
 */
/* Apply option to the format only. */
__LA_DECL int archive_write_set_format_option(struct archive *_a,
			    const char *m, const char *o,
			    const char *v);
/* Apply option to the filter only. */
__LA_DECL int archive_write_set_filter_option(struct archive *_a,
			    const char *m, const char *o,
			    const char *v);
/* Apply option to both the format and the filter. */
__LA_DECL int archive_write_set_option(struct archive *_a,
			    const char *m, const char *o,
			    const char *v);
/* Apply option string to both the format and the filter. */
__LA_DECL int archive_write_set_options(struct archive *_a,
			    const char *opts);

/*
 * Set a encryption passphrase.
 */
__LA_DECL int archive_write_set_passphrase(struct archive *_a, const char *p);
__LA_DECL int archive_write_set_passphrase_callback(struct archive *,
			    void *client_data, archive_passphrase_callback *);

/*-
 * ARCHIVE_WRITE_DISK API
 *
 * To create objects on disk:
 *   1) Ask archive_write_disk_new for a new archive_write_disk object.
 *   2) Set any global properties.  In particular, you probably
 *      want to set the options.
 *   3) For each entry:
 *      - construct an appropriate struct archive_entry structure
 *      - archive_write_header to create the file/dir/etc on disk
 *      - archive_write_data to write the entry data
 *   4) archive_write_free to cleanup the writer and release resources
 *
 * In particular, you can use this in conjunction with archive_read()
 * to pull entries out of an archive and create them on disk.
 */
__LA_DECL struct archive	*archive_write_disk_new(void);
/* This file will not be overwritten. */
__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
    la_int64_t, la_int64_t);
/* Set flags to control how the next item gets created.
 * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
__LA_DECL int		 archive_write_disk_set_options(struct archive *,
		     int flags);
/*
 * The lookup functions are given uname/uid (or gname/gid) pairs and
 * return a uid (gid) suitable for this system.  These are used for
 * restoring ownership and for setting ACLs.  The default functions
 * are naive, they just return the uid/gid.  These are small, so reasonable
 * for applications that don't need to preserve ownership; they
 * are probably also appropriate for applications that are doing
 * same-system backup and restore.
 */
/*
 * The "standard" lookup functions use common system calls to lookup
 * the uname/gname, falling back to the uid/gid if the names can't be
 * found.  They cache lookups and are reasonably fast, but can be very
 * large, so they are not used unless you ask for them.  In
 * particular, these match the specifications of POSIX "pax" and old
 * POSIX "tar".
 */
__LA_DECL int	 archive_write_disk_set_standard_lookup(struct archive *);
/*
 * If neither the default (naive) nor the standard (big) functions suit
 * your needs, you can write your own and register them.  Be sure to
 * include a cleanup function if you have allocated private data.
 */
__LA_DECL int archive_write_disk_set_group_lookup(struct archive *,
    void * /* private_data */,
    la_int64_t (*)(void *, const char *, la_int64_t),
    void (* /* cleanup */)(void *));
__LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
    void * /* private_data */,
    la_int64_t (*)(void *, const char *, la_int64_t),
    void (* /* cleanup */)(void *));
__LA_DECL la_int64_t archive_write_disk_gid(struct archive *, const char *, la_int64_t);
__LA_DECL la_int64_t archive_write_disk_uid(struct archive *, const char *, la_int64_t);

/*
 * ARCHIVE_READ_DISK API
 *
 * This is still evolving and somewhat experimental.
 */
__LA_DECL struct archive *archive_read_disk_new(void);
/* The names for symlink modes here correspond to an old BSD
 * command-line argument convention: -L, -P, -H */
/* Follow all symlinks. */
__LA_DECL int archive_read_disk_set_symlink_logical(struct archive *);
/* Follow no symlinks. */
__LA_DECL int archive_read_disk_set_symlink_physical(struct archive *);
/* Follow symlink initially, then not. */
__LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *);
/* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */
__LA_DECL int archive_read_disk_entry_from_file(struct archive *,
    struct archive_entry *, int /* fd */, const struct stat *);
/* Look up gname for gid or uname for uid. */
/* Default implementations are very, very stupid. */
__LA_DECL const char *archive_read_disk_gname(struct archive *, la_int64_t);
__LA_DECL const char *archive_read_disk_uname(struct archive *, la_int64_t);
/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
 * results for performance. */
__LA_DECL int	archive_read_disk_set_standard_lookup(struct archive *);
/* You can install your own lookups if you like. */
__LA_DECL int	archive_read_disk_set_gname_lookup(struct archive *,
    void * /* private_data */,
    const char *(* /* lookup_fn */)(void *, la_int64_t),
    void (* /* cleanup_fn */)(void *));
__LA_DECL int	archive_read_disk_set_uname_lookup(struct archive *,
    void * /* private_data */,
    const char *(* /* lookup_fn */)(void *, la_int64_t),
    void (* /* cleanup_fn */)(void *));
/* Start traversal. */
__LA_DECL int	archive_read_disk_open(struct archive *, const char *);
__LA_DECL int	archive_read_disk_open_w(struct archive *, const wchar_t *);
/*
 * Request that current entry be visited.  If you invoke it on every
 * directory, you'll get a physical traversal.  This is ignored if the
 * current entry isn't a directory or a link to a directory.  So, if
 * you invoke this on every returned path, you'll get a full logical
 * traversal.
 */
__LA_DECL int	archive_read_disk_descend(struct archive *);
__LA_DECL int	archive_read_disk_can_descend(struct archive *);
__LA_DECL int	archive_read_disk_current_filesystem(struct archive *);
__LA_DECL int	archive_read_disk_current_filesystem_is_synthetic(struct archive *);
__LA_DECL int	archive_read_disk_current_filesystem_is_remote(struct archive *);
/* Request that the access time of the entry visited by traversal be restored. */
__LA_DECL int  archive_read_disk_set_atime_restored(struct archive *);
/*
 * Set behavior. The "flags" argument selects optional behavior.
 */
/* Request that the access time of the entry visited by traversal be restored.
 * This is the same as archive_read_disk_set_atime_restored. */
#define	ARCHIVE_READDISK_RESTORE_ATIME		(0x0001)
/* Default: Do not skip an entry which has nodump flags. */
#define	ARCHIVE_READDISK_HONOR_NODUMP		(0x0002)
/* Default: Skip a mac resource fork file whose prefix is "._" because of
 * using copyfile. */
#define	ARCHIVE_READDISK_MAC_COPYFILE		(0x0004)
/* Default: Traverse mount points. */
#define	ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS	(0x0008)
/* Default: Xattrs are read from disk. */
#define	ARCHIVE_READDISK_NO_XATTR		(0x0010)
/* Default: ACLs are read from disk. */
#define	ARCHIVE_READDISK_NO_ACL			(0x0020)
/* Default: File flags are read from disk. */
#define	ARCHIVE_READDISK_NO_FFLAGS		(0x0040)

__LA_DECL int  archive_read_disk_set_behavior(struct archive *,
		    int flags);

/*
 * Set archive_match object that will be used in archive_read_disk to
 * know whether an entry should be skipped. The callback function
 * _excluded_func will be invoked when an entry is skipped by the result
 * of archive_match.
 */
__LA_DECL int	archive_read_disk_set_matching(struct archive *,
		    struct archive *_matching, void (*_excluded_func)
		    (struct archive *, void *, struct archive_entry *),
		    void *_client_data);
__LA_DECL int	archive_read_disk_set_metadata_filter_callback(struct archive *,
		    int (*_metadata_filter_func)(struct archive *, void *,
		    	struct archive_entry *), void *_client_data);

/* Simplified cleanup interface;
 * This calls archive_read_free() or archive_write_free() as needed. */
__LA_DECL int	archive_free(struct archive *);

/*
 * Accessor functions to read/set various information in
 * the struct archive object:
 */

/* Number of filters in the current filter pipeline. */
/* Filter #0 is the one closest to the format, -1 is a synonym for the
 * last filter, which is always the pseudo-filter that wraps the
 * client callbacks. */
__LA_DECL int		 archive_filter_count(struct archive *);
__LA_DECL la_int64_t	 archive_filter_bytes(struct archive *, int);
__LA_DECL int		 archive_filter_code(struct archive *, int);
__LA_DECL const char *	 archive_filter_name(struct archive *, int);

#if ARCHIVE_VERSION_NUMBER < 4000000
/* These don't properly handle multiple filters, so are deprecated and
 * will eventually be removed. */
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, -1); */
__LA_DECL la_int64_t	 archive_position_compressed(struct archive *)
				__LA_DEPRECATED;
/* As of libarchive 3.0, this is an alias for archive_filter_bytes(a, 0); */
__LA_DECL la_int64_t	 archive_position_uncompressed(struct archive *)
				__LA_DEPRECATED;
/* As of libarchive 3.0, this is an alias for archive_filter_name(a, 0); */
__LA_DECL const char	*archive_compression_name(struct archive *)
				__LA_DEPRECATED;
/* As of libarchive 3.0, this is an alias for archive_filter_code(a, 0); */
__LA_DECL int		 archive_compression(struct archive *)
				__LA_DEPRECATED;
#endif

__LA_DECL int		 archive_errno(struct archive *);
__LA_DECL const char	*archive_error_string(struct archive *);
__LA_DECL const char	*archive_format_name(struct archive *);
__LA_DECL int		 archive_format(struct archive *);
__LA_DECL void		 archive_clear_error(struct archive *);
__LA_DECL void		 archive_set_error(struct archive *, int _err,
			    const char *fmt, ...) __LA_PRINTF(3, 4);
__LA_DECL void		 archive_copy_error(struct archive *dest,
			    struct archive *src);
__LA_DECL int		 archive_file_count(struct archive *);

/*
 * ARCHIVE_MATCH API
 */
__LA_DECL struct archive *archive_match_new(void);
__LA_DECL int	archive_match_free(struct archive *);

/*
 * Test if archive_entry is excluded.
 * This is a convenience function. This is the same as calling all
 * archive_match_path_excluded, archive_match_time_excluded
 * and archive_match_owner_excluded.
 */
__LA_DECL int	archive_match_excluded(struct archive *,
		    struct archive_entry *);

/*
 * Test if pathname is excluded. The conditions are set by following functions.
 */
__LA_DECL int	archive_match_path_excluded(struct archive *,
		    struct archive_entry *);
/* Add exclusion pathname pattern. */
__LA_DECL int	archive_match_exclude_pattern(struct archive *, const char *);
__LA_DECL int	archive_match_exclude_pattern_w(struct archive *,
		    const wchar_t *);
/* Add exclusion pathname pattern from file. */
__LA_DECL int	archive_match_exclude_pattern_from_file(struct archive *,
		    const char *, int _nullSeparator);
__LA_DECL int	archive_match_exclude_pattern_from_file_w(struct archive *,
		    const wchar_t *, int _nullSeparator);
/* Add inclusion pathname pattern. */
__LA_DECL int	archive_match_include_pattern(struct archive *, const char *);
__LA_DECL int	archive_match_include_pattern_w(struct archive *,
		    const wchar_t *);
/* Add inclusion pathname pattern from file. */
__LA_DECL int	archive_match_include_pattern_from_file(struct archive *,
		    const char *, int _nullSeparator);
__LA_DECL int	archive_match_include_pattern_from_file_w(struct archive *,
		    const wchar_t *, int _nullSeparator);
/*
 * How to get statistic information for inclusion patterns.
 */
/* Return the amount number of unmatched inclusion patterns. */
__LA_DECL int	archive_match_path_unmatched_inclusions(struct archive *);
/* Return the pattern of unmatched inclusion with ARCHIVE_OK.
 * Return ARCHIVE_EOF if there is no inclusion pattern. */
__LA_DECL int	archive_match_path_unmatched_inclusions_next(
		    struct archive *, const char **);
__LA_DECL int	archive_match_path_unmatched_inclusions_next_w(
		    struct archive *, const wchar_t **);

/*
 * Test if a file is excluded by its time stamp.
 * The conditions are set by following functions.
 */
__LA_DECL int	archive_match_time_excluded(struct archive *,
		    struct archive_entry *);

/*
 * Flags to tell a matching type of time stamps. These are used for
 * following functions.
 */
/* Time flag: mtime to be tested. */
#define ARCHIVE_MATCH_MTIME	(0x0100)
/* Time flag: ctime to be tested. */
#define ARCHIVE_MATCH_CTIME	(0x0200)
/* Comparison flag: Match the time if it is newer than. */
#define ARCHIVE_MATCH_NEWER	(0x0001)
/* Comparison flag: Match the time if it is older than. */
#define ARCHIVE_MATCH_OLDER	(0x0002)
/* Comparison flag: Match the time if it is equal to. */
#define ARCHIVE_MATCH_EQUAL	(0x0010)
/* Set inclusion time. */
__LA_DECL int	archive_match_include_time(struct archive *, int _flag,
		    time_t _sec, long _nsec);
/* Set inclusion time by a date string. */
__LA_DECL int	archive_match_include_date(struct archive *, int _flag,
		    const char *_datestr);
__LA_DECL int	archive_match_include_date_w(struct archive *, int _flag,
		    const wchar_t *_datestr);
/* Set inclusion time by a particular file. */
__LA_DECL int	archive_match_include_file_time(struct archive *,
		    int _flag, const char *_pathname);
__LA_DECL int	archive_match_include_file_time_w(struct archive *,
		    int _flag, const wchar_t *_pathname);
/* Add exclusion entry. */
__LA_DECL int	archive_match_exclude_entry(struct archive *,
		    int _flag, struct archive_entry *);

/*
 * Test if a file is excluded by its uid ,gid, uname or gname.
 * The conditions are set by following functions.
 */
__LA_DECL int	archive_match_owner_excluded(struct archive *,
		    struct archive_entry *);
/* Add inclusion uid, gid, uname and gname. */
__LA_DECL int	archive_match_include_uid(struct archive *, la_int64_t);
__LA_DECL int	archive_match_include_gid(struct archive *, la_int64_t);
__LA_DECL int	archive_match_include_uname(struct archive *, const char *);
__LA_DECL int	archive_match_include_uname_w(struct archive *,
		    const wchar_t *);
__LA_DECL int	archive_match_include_gname(struct archive *, const char *);
__LA_DECL int	archive_match_include_gname_w(struct archive *,
		    const wchar_t *);

/* Utility functions */
/* Convenience function to sort a NULL terminated list of strings */
__LA_DECL int archive_utility_string_sort(char **);

#ifdef __cplusplus
}
#endif

/* These are meaningless outside of this header. */
#undef __LA_DECL

#endif /* !ARCHIVE_H_INCLUDED */