File: pstklib.h

package info (click to toggle)
pcb-rnd 3.1.7b-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,108 kB
  • sloc: ansic: 213,400; yacc: 6,241; sh: 4,698; awk: 3,016; makefile: 2,254; lex: 1,166; python: 519; xml: 261; lisp: 154; tcl: 67; perl: 34; javascript: 6; ruby: 5
file content (40 lines) | stat: -rw-r--r-- 1,464 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "board.h"
#include "data.h"
#include "ht_pstk.h"

/* Build a hash of subcircuit-to-prototype. Effectively a local library
   of unique footprint prototypes */

typedef struct {
	pcb_pstk_proto_t proto;  /* copy of a proto */
	long id;                 /* unique ID counted from 1 by pcb_pstklib_build */
	void *user_data;
	char extra[1];           /* as big as ctx->extra_size */
} pcb_pstklib_entry_t;

typedef struct pcb_pstklib_s pcb_pstklib_t;
struct pcb_pstklib_s {
	htprp_t protos;   /* value is (pcb_pstklib_entry_t *) */
	pcb_board_t *pcb;
	long next_id;

	/* user configuration */
	void (*on_new_entry)(pcb_pstklib_t *ctx, pcb_pstklib_entry_t *pe); /* optional: if set, called after a new entry is inserted */
	void (*on_free_entry)(pcb_pstklib_t *ctx, pcb_pstklib_entry_t *pe); /* optional: if set, called before freeing an entry on uninit */
	void *user_data;
	int extra_size;
};

void pcb_pstklib_init(pcb_pstklib_t *ctx, pcb_board_t *pcb);
void pcb_pstklib_uninit(pcb_pstklib_t *ctx);

/* Iterate all padstack prototypes within data and build ctx->protos hash */
void pcb_pstklib_build_data(pcb_pstklib_t *ctx, pcb_data_t *data);

/* Auto build the padstack proto lib from ctx->pcb, with option to recurse
   into subcircuits and collect prototypes there too */
void pcb_pstklib_build_pcb(pcb_pstklib_t *ctx, int recurse_subc);


/* return proto's prototype or NULL */
#define pcb_pstklib_get(ctx, proto)    htprp_get(&(ctx)->protos, (proto))