ptvrebit.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder/***********************************************************************
57221209d11b05aa0373cc3892d5df89ba96ebf9Christian Maeder* *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* This software is part of the ast package *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* Copyright (c) 2000-2011 AT&T Intellectual Property *
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski* and is licensed under the *
1549f3abf73c1122acff724f718b615c82fa3648Till Mossakowski* Eclipse Public License, Version 1.0 *
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu* by AT&T Intellectual Property *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* *
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder* A copy of the License is available at *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* http://www.eclipse.org/org/documents/epl-v10.html *
351145cfe8c03b4d47133c96b209f2bd6cfbf504Christian Maeder* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder* *
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski* Information and Software Systems Research *
1549f3abf73c1122acff724f718b615c82fa3648Till Mossakowski* AT&T Research *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* Florham Park NJ *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* Glenn Fowler <gsf@research.att.com> *
f8b715ab2993083761c0aedb78f1819bcf67b6ccChristian Maeder* Phong Vo <kpv@research.att.com> *
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder* *
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder***********************************************************************/
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder#pragma prototyped
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski#include "ptvlib.h"
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun Wang
23a00c966f2aa8da525d7a7c51933c99964426c0Christian Maeder/*
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder * return a copy of table a with prefixes limited to a maximum of m bits
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder */
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maeder
db453fe9625a9dab5d108f7a5e464598814144b8Jian Chun WangPtv_t*
8c63cd89ef840cd7a3d3b75f0207dc800388c800Christian Maederptvrebit(Ptv_t* a, int m)
575a55eadc8dcab8ee350324b417cbd9e52e69c0Christian Maeder{
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder Ptv_t* b;
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder Ptvprefix_t* ap;
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder if (b = ptvopen(a->disc, a->size))
0e2ae85e2453466d03c1fc5884a3d693235bb9d9Christian Maeder for (ap = (Ptvprefix_t*)dtfirst(a->dict); ap; ap = (Ptvprefix_t*)dtnext(a->dict, ap))
01aafb6a9520f05df5ff467b591ecb5474dcfc86Christian Maeder if (!ptvinsert(b, ptvmin(a->size, b->r[0], ap->min, m), ptvmin(a->size, b->r[1], ap->max, m)))
90c174bac60a72ffd81bc3bf5ae2dd9a61943b8bChristian Maeder {
2561b4bfc45d280ee2be8a7870314670e4e682e4Christian Maeder ptvclose(b);
ca020e82eb3567e7bdbb1cf70729efbd07e9caa4Klaus Luettich return 0;
aea143fff7a50aceb809845fbc42698b0b3f545aChristian Maeder }
ca020e82eb3567e7bdbb1cf70729efbd07e9caa4Klaus Luettich return b;
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder}
a001917177db7ae636853b37c0d0f9f4e90a83ffChristian Maeder