pcb 4.1.1
An interactive printed circuit board layout editor.

hidinit.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "global.h"
#include "hid.h"
#include "hidnogui.h"
#include "../hidint.h"
#include "compat.h"
#include "error.h"
#include "misc.h"
#include "pcb-printf.h"
#include "hid/common/hidlist.h"
Include dependency graph for hidinit.c:

Go to the source code of this file.

Data Structures

struct  ecache
struct  ccache

Defines

#define HID_DEF(x)   extern void hid_ ## x ## _init(void);
#define HID_DEF(x)   hid_ ## x ## _init();
#define HASH_SIZE   31

Typedefs

typedef struct ecache ecache
typedef struct ccache ccache

Functions

static void hid_load_dir (char *dirname)
 Search a directory for plugins and load them if found.
void hid_init ()
 Initialize the available hids and load plugins.
void hid_uninit (void)
 Call this at exit.
void hid_register_hid (HID *hid)
 Add an HID to the list of HIDs.
HIDhid_find_gui ()
 When PCB runs in interactive mode, this is called to instantiate one GUI HID which happens to be the GUI.
HIDhid_find_printer ()
 Finds the one printer HID and instantiates it.
HIDhid_find_exporter (const char *which)
 Finds the indicated exporter HID and instantiates it.
HID ** hid_enumerate ()
 This returns a NULL-terminated array of available HIDs.
void hid_register_attributes (HID_Attribute *a, int n)
void hid_parse_command_line (int *argc, char ***argv)
 A HID may use this if it does not need command line arguments in any special format.
static int attr_hash (HID_Attribute *a)
void hid_save_settings (int locally)
static void hid_set_attribute (char *name, char *value)
static void hid_load_settings_1 (char *fname)
void hid_load_settings ()
static void copy_color (int set, hidval *cval, hidval *aval)
int hid_cache_color (int set, const char *name, hidval *val, void **vcache)
 Used to cache color lookups.
void derive_default_filename (const char *pcbfile, HID_Attribute *filename_attrib, const char *suffix, char **memory)

Variables

HID ** hid_list = 0
 NULL terminated list of all static HID structures.
int hid_num_hids = 0
 Count of entries in the above.
HIDgui = NULL
HIDexporter = NULL
int pixel_slop = 1
HID_AttrNodehid_attr_nodes = 0

Define Documentation

#define HASH_SIZE   31

Definition at line 726 of file hidinit.c.

Referenced by hid_cache_color().

#define HID_DEF (   x)    extern void hid_ ## x ## _init(void);

Definition at line 74 of file hidinit.c.

#define HID_DEF (   x)    hid_ ## x ## _init();

Definition at line 74 of file hidinit.c.


Typedef Documentation

typedef struct ccache ccache
typedef struct ecache ecache

Function Documentation

static int attr_hash ( HID_Attribute a) [static]

Definition at line 486 of file hidinit.c.

References HID_Attribute::hash.

Referenced by hid_load_settings(), and hid_save_settings().

static void copy_color ( int  set,
hidval cval,
hidval aval 
) [static]

Definition at line 742 of file hidinit.c.

Referenced by hid_cache_color().

void derive_default_filename ( const char *  pcbfile,
HID_Attribute filename_attrib,
const char *  suffix,
char **  memory 
)
int hid_cache_color ( int  set,
const char *  name,
hidval val,
void **  cache 
)

Used to cache color lookups.

If set is zero, it looks up the name and if found sets val and returns nonzero. If not found, it returns zero. If set is nonzero, name/val is added to the cache.

Definition at line 751 of file hidinit.c.

References ccache::colors, copy_color(), hash(), HASH_SIZE, ccache::lru, malloc(), ecache::name, ecache::next, and ecache::val.

Referenced by eps_set_color(), ghid_set_color(), lesstif_set_color(), png_set_color(), set_gl_color_for_gc(), and use_gc().

Here is the call graph for this function:

HID** hid_enumerate ( void  )

This returns a NULL-terminated array of available HIDs.

The only real reason to use this is to locate all the export-style HIDs.

Definition at line 287 of file hidinit.c.

References hid_list.

Referenced by Export(), GetInfoString(), ghid_dialog_export(), Print(), print_defaults(), and usage().

HID* hid_find_exporter ( const char *  which)

Finds the indicated exporter HID and instantiates it.

Definition at line 269 of file hidinit.c.

References hid_num_hids.

Referenced by ActionPSCalib(), and main().

HID* hid_find_gui ( )

When PCB runs in interactive mode, this is called to instantiate one GUI HID which happens to be the GUI.

This HID is the one that interacts with the mouse and keyboard.

Definition at line 244 of file hidinit.c.

References hid_num_hids.

Referenced by main().

HID* hid_find_printer ( void  )

Finds the one printer HID and instantiates it.

Definition at line 257 of file hidinit.c.

References hid_num_hids.

Referenced by main(), Print(), and PrintCalibrate().

void hid_init ( void  )

Initialize the available hids and load plugins.

Call this as soon as possible from main().

The file hid/common/hidlist.h contains a list of HID_DEF statements, compiled by the build system. The HID_DEF macro is redefined here to call the init function for each of those hids.

Definition at line 173 of file hidinit.c.

References Concat(), exec_prefix, hid_load_dir(), hid_nogui_get_hid(), and homedir.

Referenced by main().

Here is the call graph for this function:

static void hid_load_dir ( char *  dirname) [static]

Search a directory for plugins and load them if found.

The specified path is searched for shared library objects and dynamic link libraries. If any are found, check their symbols for a "hid_x_init" (where x is the basename of the library file) or a pcb_plugin_init, and call it as a function if found.

Todo:
the MacOS .dylib should be added to this list

Definition at line 98 of file hidinit.c.

References Concat().

Referenced by hid_init().

Here is the call graph for this function:

void hid_load_settings ( void  )

Definition at line 710 of file hidinit.c.

References attr_hash(), HID_AttrNode::attributes, Concat(), HID_Attribute::hash, hid_load_settings_1(), homedir, HID_AttrNode::n, HID_AttrNode::next, and pcblibdir.

Referenced by main().

Here is the call graph for this function:

static void hid_load_settings_1 ( char *  fname) [static]

Definition at line 672 of file hidinit.c.

References f, hid_set_attribute(), and line.

Referenced by hid_load_settings().

Here is the call graph for this function:

void hid_register_hid ( HID hid)

Add an HID to the list of HIDs.

Called by the init funcs, used to set up hid_list.

Definition at line 216 of file hidinit.c.

References hid_num_hids, malloc(), hid_st::name, realloc(), and hid_st::struct_size.

Referenced by hid_batch_init(), hid_bom_init(), hid_eps_init(), hid_gcode_init(), hid_gerber_init(), hid_gsvit_init(), hid_ipcd356_init(), hid_lesstif_init(), hid_lpr_init(), hid_nelma_init(), hid_png_init(), hid_ps_init(), and REGISTER_FLAGS().

Here is the call graph for this function:

void hid_uninit ( void  )

Call this at exit.

Definition at line 207 of file hidinit.c.

Referenced by pcb_main_uninit().


Variable Documentation

HID* exporter = NULL

This is either NULL or points to the current HID that is being called to do the exporting.

The gui HIDs set and unset this var.

Definition at line 82 of file hidinit.c.

Referenced by Export(), GetInfoString(), ghid_dialog_export(), ghid_dialog_print(), main(), print_defaults(), usage(), and usage_hid().

HID* gui = NULL

This is initially set to a "no-gui" gui, and later reset by main.

hid_expose_callback also temporarily set it for drawing.

Definition at line 81 of file hidinit.c.

Referenced by _draw_pad(), _draw_pv(), _draw_pv_name(), ActionAttributes(), ActionAutoPlaceSelected(), ActionBell(), ActionChange2ndSize(), ActionChangeClearSize(), ActionChangeHole(), ActionChangeJoin(), ActionChangeName(), ActionChangeOctagon(), ActionChangePaste(), ActionChangePinName(), ActionChangeSquare(), ActionClearOctagon(), ActionClearSquare(), ActionConnection(), ActionDisplay(), ActionDRCheck(), ActionElementList(), ActionExecuteFile(), ActionFreeRotateBuffer(), ActionImport(), ActionLoadFrom(), ActionLoadVendorFrom(), ActionMorphPolygon(), ActionMoveToCurrentLayer(), ActionNew(), ActionPasteBuffer(), ActionQuit(), ActionRenumber(), ActionSaveTo(), ActionSelect(), ActionSetOctagon(), ActionSetSquare(), ActionToggleHideName(), ActionUnselect(), AdjustAttachedBox(), AdjustAttachedLine(), AdjustInsertPoint(), AdjustTwoLine(), append_drc_violation(), arc_callback(), AutoRoute(), backup_cb(), CenterDisplay(), ChangePolygonClearSize(), check_snap_object(), CheckAndOpenFile(), clearPin_callback(), ClearUndoList(), click_cb(), common_draw_pcb_arc(), common_draw_pcb_line(), common_draw_pcb_text(), common_fill_pcb_pad(), common_fill_pcb_pv(), common_gui_draw_pcb_polygon(), common_thindraw_pcb_pad(), common_thindraw_pcb_pv(), CursorAction(), Draw(), draw_dashed_line(), draw_element_name(), draw_element_package(), draw_octagon_poly(), draw_pad(), draw_pad_name(), draw_pin(), draw_via(), DrawAttached(), DrawEMark(), DrawEverything(), DrawLayer(), DrawLayerGroup(), DrawMark(), DrawMask(), DrawMaskBoardArea(), DrawPaste(), DrawPPV(), DrawRats(), DrawSilk(), DRCAll(), EnableAutosave(), EnforceLineDRC(), Export(), fab_circle(), fab_line(), fill_contour(), FinishStroke(), FitCrosshairIntoGrid(), gerber_set_layer(), GetInfoString(), GetXY(), ghid_dialog_export(), ghid_init_renderer(), ghid_listener_cb(), ghid_shutdown_renderer(), ghid_thindraw_pcb_polygon(), GlobalPuller(), hid_actionv(), hid_expose_callback(), hole_callback(), io_watch_handler_dbus_freed(), lgbutton_input(), line_callback(), LookupConnection(), LookupConnectionsToAllElements(), LookupElementConnections(), LookupUnusedPins(), main(), maybe_pull_1(), Message(), move_corner(), MoveLayer(), Netlist(), netnode_browse(), node_selection_changed_cb(), notify_crosshair_change(), notify_mark_change(), NotifyLine(), NotifyMode(), OpenConnectionDataFile(), pcb_dbus_connection_setup_with_mainloop(), pcb_main_uninit(), poly_callback(), Print(), PrintAssembly(), PrintBOM(), PrintCalibrate(), PrintFab(), ps_calibrate_1(), Puller(), QueryInputAndChangeObjectName(), QuitApplication(), rat_callback(), real_load_pcb(), Redraw(), ReleaseMode(), Report(), ReportAllNetLengths(), ReportDialog(), ReportDrills(), ReportFoundPins(), ReportNetLength(), ReportNetLengthByName(), reset_drc_dialog_message(), RouteAll(), SavePCB(), set_object_color(), teardrops(), text_at(), text_callback(), thindraw_contour(), thindraw_moved_pv(), throw_drc_dialog(), timeout_add(), timeout_handler_cb(), timeout_handler_dbus_freed(), TracePath(), usage(), watch_add(), XORDrawAttachedArc(), XORDrawAttachedLine(), XORDrawBuffer(), XORDrawElement(), XORDrawInsertPointObject(), XORDrawMoveOrCopyObject(), and XORPolygon().

HID** hid_list = 0

NULL terminated list of all static HID structures.

Built by hid_register_hid, used by hid_find_*() and hid_enumerate(). The order in this list is the same as the order of hid_register_hid calls.

Definition at line 78 of file hidinit.c.

Referenced by hid_enumerate().

int hid_num_hids = 0

Count of entries in the above.

Definition at line 79 of file hidinit.c.

Referenced by hid_find_exporter(), hid_find_gui(), hid_find_printer(), and hid_register_hid().

int pixel_slop = 1

The GUI may set this to be approximately the PCB size of a pixel, to allow for near-misses in selection and changes in drawing items smaller than a screen pixel.

Definition at line 84 of file hidinit.c.

Referenced by common_thindraw_pcb_pad(), DrawRat(), ghid_parse_arguments(), ghid_zoom_view_abs(), rat_callback(), SearchScreen(), XORDrawAttachedArc(), XORDrawAttachedLine(), zoom_max(), and zoom_to().