Index: flag.c =================================================================== --- flag.c (nonexistent) +++ flag.c (revision 4487) @@ -0,0 +1,75 @@ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 1994,1995,1996,2004,2006 Thomas Nau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany + * Thomas.Nau@rz.uni-ulm.de + * + */ + +#include +#include "flag.h" + +/* This just fills in a FlagType with current flags. */ +FlagType MakeFlags(unsigned int flags) +{ + FlagType rv; + memset(&rv, 0, sizeof(rv)); + rv.f = flags; + return rv; +} + +/* This converts old flag bits (from saved PCB files) to new format. */ +FlagType OldFlags(unsigned int flags) +{ + FlagType rv; + int i, f; + memset(&rv, 0, sizeof(rv)); + /* If we move flag bits around, this is where we map old bits to them. */ + rv.f = flags & 0xffff; + f = 0x10000; + for (i = 0; i < 8; i++) { + /* use the closest thing to the old thermal style */ + if (flags & f) + rv.t[i / 2] |= (1 << (4 * (i % 2))); + f <<= 1; + } + return rv; +} + +FlagType AddFlags(FlagType flag, unsigned int flags) +{ + flag.f |= flags; + return flag; +} + +FlagType MaskFlags(FlagType flag, unsigned int flags) +{ + flag.f &= ~flags; + return flag; +} + +int mem_any_set(unsigned char *ptr, int bytes) +{ + while (bytes--) + if (*ptr++) + return 1; + return 0; +}