view mercurial/thirdparty/xdiff/xtypes.h @ 37047:fddcb51b5084

wireproto: define permissions-based routing of HTTPv2 wire protocol Now that we have a scaffolding for serving version 2 of the HTTP protocol, let's start implementing it. A good place to start is URL routing and basic request processing semantics. We can focus on content types, capabilities detect, etc later. Version 2 of the HTTP wire protocol encodes the needed permissions of the request in the URL path. The reasons for this are documented in the added documentation. In short, a) it makes it really easy and fail proof for server administrators to implement path-based authentication and b) it will enable clients to realize very early in a server exchange that authentication will be required to complete the operation. This latter point avoids all kinds of complexity and problems, like dealing with Expect: 100-continue and clients finding out later during `hg push` that they need to provide authentication. This will avoid the current badness where clients send a full bundle, get an HTTP 403, provide authentication, then retransmit the bundle. In order to implement command checking, we needed to implement a protocol handler for the new wire protocol. Our handler is just small enough to run the code we've implemented. Tests for the defined functionality have been added. I very much want to refactor the permissions checking code and define a better response format. But this can be done later. Nothing is covered by backwards compatibility at this point. Differential Revision: https://phab.mercurial-scm.org/D2836
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 19 Mar 2018 16:43:47 -0700
parents 882657a9f768
children
line wrap: on
line source

/*
 *  LibXDiff by Davide Libenzi ( File Differential Library )
 *  Copyright (C) 2003  Davide Libenzi
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, see
 *  <http://www.gnu.org/licenses/>.
 *
 *  Davide Libenzi <davidel@xmailserver.org>
 *
 */

#if !defined(XTYPES_H)
#define XTYPES_H



typedef struct s_chanode {
	struct s_chanode *next;
	int64_t icurr;
} chanode_t;

typedef struct s_chastore {
	chanode_t *head, *tail;
	int64_t isize, nsize;
	chanode_t *ancur;
	chanode_t *sncur;
	int64_t scurr;
} chastore_t;

typedef struct s_xrecord {
	struct s_xrecord *next;
	char const *ptr;
	int64_t size;
	uint64_t ha;
} xrecord_t;

typedef struct s_xdfile {
	/* manual memory management */
	chastore_t rcha;

	/* number of records (lines) */
	int64_t nrec;

	/* hash table size
	 * the maximum hash value in the table is (1 << hbits) */
	unsigned int hbits;

	/* hash table, hash value => xrecord_t
	 * note: xrecord_t is a linked list. */
	xrecord_t **rhash;

	/* range excluding common prefix and suffix
	 * [recs[i] for i in range(0, dstart)] are common prefix.
	 * [recs[i] for i in range(dstart, dend + 1 - dstart)] are interesting
	 * lines */
	int64_t dstart, dend;

	/* pointer to records (lines) */
	xrecord_t **recs;

	/* record changed, use original "recs" index
	 * rchag[i] can be either 0 or 1. 1 means recs[i] (line i) is marked
	 * "changed". */
	char *rchg;

	/* cleaned-up record index => original "recs" index
	 * clean-up means:
	 *  rule 1. remove common prefix and suffix
	 *  rule 2. remove records that are only on one side, since they can
	 *          not match the other side
	 * rindex[0] is likely dstart, if not removed up by rule 2.
	 * rindex[nreff - 1] is likely dend, if not removed by rule 2.
	 */
	int64_t *rindex;

	/* rindex size */
	int64_t nreff;

	/* cleaned-up record index => hash value
	 * ha[i] = recs[rindex[i]]->ha */
	uint64_t *ha;
} xdfile_t;

typedef struct s_xdfenv {
	xdfile_t xdf1, xdf2;

	/* number of lines for common prefix and suffix that are removed
	 * from xdf1 and xdf2 as a preprocessing step */
	int64_t nprefix, nsuffix;
} xdfenv_t;



#endif /* #if !defined(XTYPES_H) */