pcb 4.1.1
An interactive printed circuit board layout editor.
|
strflags. More...
#include <stdio.h>
#include <ctype.h>
#include "globalconst.h"
#include "global.h"
#include "compat.h"
#include "hid.h"
#include "strflags.h"
Go to the source code of this file.
Data Structures | |
struct | FlagHolder |
struct | FlagBitsType |
Defines | |
#define | N(x) x, sizeof(x)-1 |
#define | B buffers[bufptr] |
Functions | |
static char * | alloc_buf (int len) |
void | uninit_strflags_buf (void) |
static void | grow_layer_list (int num) |
Grow layer list. | |
void | uninit_strflags_layerlist (void) |
static void | set_layer_list (int layer, int v) |
Set layer list. | |
static const char * | parse_layer_list (const char *bp, int(*error)(const char *)) |
Parse layer list. | |
static int | printed_int_length (int i, int j) |
Number of character the value "i" requires when printed. | |
static char * | print_layer_list () |
Print layer list. | |
static int | error_ignore (const char *msg) |
static FlagType | common_string_to_flags (const char *flagstring, int(*error)(const char *msg), FlagBitsType *flagbits, int n_flagbits) |
FlagType | string_to_flags (const char *flagstring, int(*error)(const char *msg)) |
Convert strings to flags. | |
FlagType | string_to_pcbflags (const char *flagstring, int(*error)(const char *msg)) |
Convert strings to PCB flags. | |
static char * | common_flags_to_string (FlagType flags, int object_type, FlagBitsType *flagbits, int n_flagbits) |
Common flags converted to strings. | |
char * | flags_to_string (FlagType flags, int object_type) |
Object flags converted to strings. | |
char * | pcbflags_to_string (FlagType flags) |
PCB flags converted to strings. | |
Variables | |
static FlagBitsType | object_flagbits [] |
static FlagBitsType | pcb_flagbits [] |
struct { | |
char * ptr | |
int len | |
} | buffers [10] |
static int | bufptr = 0 |
static char * | layers = 0 |
static int | max_layers = 0 |
static int | num_layers = 0 |
static FlagType | empty_flags |
strflags.
The purpose of this interface is to make the file format able to handle more than 32 flags, and to hide the internal details of flags from the file format.
PCB, interactive printed circuit board design
Copyright (C) 2005 DJ Delorie
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Contact addresses for paper mail and Email:
DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA
Definition in file strflags.c.
Definition at line 82 of file strflags.c.
Referenced by gts_vertex_principal_directions(), r_create_tree(), vector_element(), vector_remove(), and vector_replace().
static char* alloc_buf | ( | int | len | ) | [static] |
Definition at line 157 of file strflags.c.
References B, bufptr, len, malloc(), and realloc().
Referenced by common_flags_to_string(), common_string_to_flags(), and parse_layer_list().
static char* common_flags_to_string | ( | FlagType | flags, |
int | object_type, | ||
FlagBitsType * | flagbits, | ||
int | n_flagbits | ||
) | [static] |
Common flags converted to strings.
Given a set of flags for a given type of object, return a string which reflects those flags.
The only requirement is that this string be parseable by string_to_flags.
Definition at line 541 of file strflags.c.
References alloc_buf(), CLEAR_FLAG, FlagHolder::Flags, GET_THERM, grow_layer_list(), len, FlagBitsType::nlen, print_layer_list(), printed_int_length(), set_layer_list(), TEST_ANY_THERMS, TEST_FLAG, and TEST_THERM.
Referenced by flags_to_string(), and pcbflags_to_string().
static FlagType common_string_to_flags | ( | const char * | flagstring, |
int(*)(const char *msg) | error, | ||
FlagBitsType * | flagbits, | ||
int | n_flagbits | ||
) | [static] |
Definition at line 425 of file strflags.c.
References alloc_buf(), ASSIGN_THERM, empty_flags, error, error_ignore(), FlagHolder::Flags, fp, layers, num_layers, parse_layer_list(), and SET_FLAG.
Referenced by string_to_flags(), and string_to_pcbflags().
static int error_ignore | ( | const char * | msg | ) | [static] |
Definition at line 418 of file strflags.c.
Referenced by common_string_to_flags().
char* flags_to_string | ( | FlagType | flags, |
int | object_type | ||
) |
Object flags converted to strings.
Given a set of flags for a given object type, return a string which can be output to a file.
The returned pointer must not be freed.
Definition at line 629 of file strflags.c.
References common_flags_to_string(), and ENTRIES.
Referenced by choose_example_line(), new_line(), ReportDialog(), and UndoFlag().
static void grow_layer_list | ( | int | num | ) | [static] |
Grow layer list.
This routine manages a list of layer-specific flags.
Callers should call grow_layer_list(0) to reset the list, and set_layer_list(layer,1) to set bits in the layer list.
The results are stored in layers[], which has num_layers
valid entries.
Definition at line 203 of file strflags.c.
References layers, max_layers, num_layers, and realloc().
Referenced by common_flags_to_string(), parse_layer_list(), and set_layer_list().
static const char* parse_layer_list | ( | const char * | bp, |
int(*)(const char *) | error | ||
) | [static] |
Parse layer list.
parse_layer_list() is passed a pointer to a string, and parses a list of integer which reflect layers to be flagged.
It returns a pointer to the first character following the list.
The syntax of the list is a paren-surrounded, comma-separated list of integers and/or pairs of integers separated by a dash (like "(1,2,3-7)").
Spaces and other punctuation are not allowed.
The results are stored in layers
[].
Definition at line 270 of file strflags.c.
References alloc_buf(), error, grow_layer_list(), and set_layer_list().
Referenced by common_string_to_flags().
char* pcbflags_to_string | ( | FlagType | flags | ) |
PCB flags converted to strings.
Definition at line 641 of file strflags.c.
References common_flags_to_string(), and ENTRIES.
Referenced by WritePCBDataHeader().
static char* print_layer_list | ( | ) | [static] |
Print layer list.
print_layer_list() uses the flags set in layers[] to build a string that represents them, using the syntax described below.
The syntax of the list is a paren-surrounded, comma-separated list of integers and/or pairs of integers separated by a dash (like "(1,2,3-7)").
Spaces and other punctuation are not allowed.
Definition at line 355 of file strflags.c.
References layers, len, malloc(), num_layers, printed_int_length(), and realloc().
Referenced by common_flags_to_string().
static int printed_int_length | ( | int | i, |
int | j | ||
) | [static] |
Number of character the value "i" requires when printed.
Definition at line 325 of file strflags.c.
Referenced by common_flags_to_string(), and print_layer_list().
static void set_layer_list | ( | int | layer, |
int | v | ||
) | [inline, static] |
Set layer list.
This routine manages a list of layer-specific flags.
Callers should call grow_layer_list(0) to reset the list, and set_layer_list(layer,1) to set bits in the layer list.
The results are stored in layers[], which has num_layers
valid entries.
Definition at line 244 of file strflags.c.
References grow_layer_list(), layer, layers, and num_layers.
Referenced by common_flags_to_string(), and parse_layer_list().
FlagType string_to_flags | ( | const char * | flagstring, |
int(*)(const char *msg) | error | ||
) |
Convert strings to flags.
When passed a string, parse it and return an appropriate set of flags.
Errors cause error() to be called with a suitable message; if error is NULL, errors are ignored.
Definition at line 497 of file strflags.c.
References common_string_to_flags(), ENTRIES, and error.
FlagType string_to_pcbflags | ( | const char * | flagstring, |
int(*)(const char *msg) | error | ||
) |
Convert strings to PCB flags.
When passed a string, parse it and return an appropriate set of flags.
Errors cause error() to be called with a suitable message; if error is NULL, errors are ignored.
Definition at line 516 of file strflags.c.
References common_string_to_flags(), ENTRIES, and error.
void uninit_strflags_buf | ( | void | ) |
Definition at line 175 of file strflags.c.
References buffers, n, and ptr.
Referenced by pcb_main_uninit().
void uninit_strflags_layerlist | ( | void | ) |
Definition at line 222 of file strflags.c.
References layers, max_layers, and num_layers.
Referenced by pcb_main_uninit().
struct { ... } buffers[10] [static] |
Referenced by uninit_strflags_buf().
int bufptr = 0 [static] |
Definition at line 155 of file strflags.c.
Referenced by alloc_buf().
FlagType empty_flags [static] |
Definition at line 422 of file strflags.c.
Referenced by common_string_to_flags().
char* layers = 0 [static] |
Definition at line 188 of file strflags.c.
Referenced by common_string_to_flags(), DrawLayerGroup(), grow_layer_list(), print_layer_list(), set_layer_list(), and uninit_strflags_layerlist().
int len |
Definition at line 153 of file strflags.c.
Referenced by ActionAddRats(), alloc_buf(), check_line_callback(), common_flags_to_string(), Concat(), corner(), dist_line_to_point(), drc_lines(), findpath(), ghid_config_init(), ghid_listener_cb(), gsvit_do_export(), gsvit_get_png_name(), gsvit_xml_out(), gts_eheap_remove_top(), gts_eheap_update(), gts_heap_remove_top(), gts_heap_top(), gts_hsurface_foreach(), leaky_strdup(), LoadNewlibFootprintsFromDir(), lrealpath(), miter(), nelma_do_export(), nelma_get_png_name(), opticurve(), order_nets_preroute_greedy(), orthopull_1(), pcb_author(), print_layer_list(), ReadLibraryContents(), ReadNetlist(), REGISTER_ACTIONS(), ReportDialog(), sift_down(), tempfile_name_new(), translate_accelerator(), triangle_interior_capacity(), and vianudge().
int max_layers = 0 [static] |
Definition at line 189 of file strflags.c.
Referenced by grow_layer_list(), and uninit_strflags_layerlist().
int num_layers = 0 |
Definition at line 189 of file strflags.c.
Referenced by common_string_to_flags(), grow_layer_list(), print_layer_list(), set_layer_list(), and uninit_strflags_layerlist().
FlagBitsType object_flagbits[] [static] |
{ { PINFLAG, N ("pin"), ALL_TYPES }, { VIAFLAG, N ("via"), ALL_TYPES }, { FOUNDFLAG, N ("found"), ALL_TYPES }, { HOLEFLAG, N ("hole"), PIN_TYPES }, { RATFLAG, N ("rat"), RATLINE_TYPE }, { PININPOLYFLAG, N ("pininpoly"), PIN_TYPES | PAD_TYPE }, { CLEARPOLYFLAG, N ("clearpoly"), POLYGON_TYPE }, { HIDENAMEFLAG, N ("hidename"), ELEMENT_TYPE }, { DISPLAYNAMEFLAG, N ("showname"), ELEMENT_TYPE }, { CLEARLINEFLAG, N ("clearline"), LINE_TYPE | ARC_TYPE | TEXT_TYPE }, { SELECTEDFLAG, N ("selected"), ALL_TYPES }, { ONSOLDERFLAG, N ("onsolder"), ELEMENT_TYPE | PAD_TYPE | TEXT_TYPE | ELEMENTNAME_TYPE }, { AUTOFLAG, N ("auto"), ALL_TYPES }, { SQUAREFLAG, N ("square"), PIN_TYPES | PAD_TYPE }, { RUBBERENDFLAG, N ("rubberend"), LINE_TYPE | ARC_TYPE }, { WARNFLAG, N ("warn"), PIN_TYPES | PAD_TYPE }, { USETHERMALFLAG, N ("usetherm"), PIN_TYPES | LINE_TYPE | ARC_TYPE }, { OCTAGONFLAG, N ("octagon"), PIN_TYPES | PAD_TYPE }, { DRCFLAG, N ("drc"), ALL_TYPES }, { LOCKFLAG, N ("lock"), ALL_TYPES }, { EDGE2FLAG, N ("edge2"), ALL_TYPES }, { FULLPOLYFLAG, N ("fullpoly"), POLYGON_TYPE}, { NOPASTEFLAG, N ("nopaste"), PAD_TYPE }, { CONNECTEDFLAG, N ("connected"), ALL_TYPES } }
Definition at line 88 of file strflags.c.
FlagBitsType pcb_flagbits[] [static] |
{ { SHOWNUMBERFLAG, N ("shownumber"), ALL_TYPES }, { LOCALREFFLAG, N ("localref"), ALL_TYPES }, { CHECKPLANESFLAG, N ("checkplanes"), ALL_TYPES }, { SHOWDRCFLAG, N ("showdrc"), ALL_TYPES }, { RUBBERBANDFLAG, N ("rubberband"), ALL_TYPES }, { DESCRIPTIONFLAG, N ("description"), ALL_TYPES }, { NAMEONPCBFLAG, N ("nameonpcb"), ALL_TYPES }, { AUTODRCFLAG, N ("autodrc"), ALL_TYPES }, { ALLDIRECTIONFLAG, N ("alldirection"), ALL_TYPES }, { SWAPSTARTDIRFLAG, N ("swapstartdir"), ALL_TYPES }, { UNIQUENAMEFLAG, N ("uniquename"), ALL_TYPES }, { CLEARNEWFLAG, N ("clearnew"), ALL_TYPES }, { NEWFULLPOLYFLAG, N ("newfullpoly"), ALL_TYPES }, { SNAPPINFLAG, N ("snappin"), ALL_TYPES }, { SHOWMASKFLAG, N ("showmask"), ALL_TYPES }, { THINDRAWFLAG, N ("thindraw"), ALL_TYPES }, { ORTHOMOVEFLAG, N ("orthomove"), ALL_TYPES }, { LIVEROUTEFLAG, N ("liveroute"), ALL_TYPES }, { THINDRAWPOLYFLAG, N ("thindrawpoly"), ALL_TYPES }, { LOCKNAMESFLAG, N ("locknames"), ALL_TYPES }, { ONLYNAMESFLAG, N ("onlynames"), ALL_TYPES }, { HIDENAMESFLAG, N ("hidenames"), ALL_TYPES }, { AUTOBURIEDVIASFLAG, N ("autoburiedvias"), ALL_TYPES }, }
Definition at line 115 of file strflags.c.
char* ptr |
Definition at line 152 of file strflags.c.
Referenced by ActionChangeName(), AddLine(), CheckShorts(), CopyObject(), CreateNewPCB(), CreateNewRubberbandEntry(), CreateRouteData(), FillDrill(), GetPointerMemory(), GetRubberbandMemory(), GetUndoSlot(), ghid_stop_timer(), InitializeDrill(), InsertPointIntoObject(), iso_sub(), MoveObjectAndRubberband(), NotifyMode(), PrintPadConnections(), Redo(), RemoveObject(), RotateObject(), Undo(), uninit_strflags_buf(), and XORDrawMoveOrCopyObject().