File: action.c

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 (91 lines) | stat: -rw-r--r-- 2,738 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 *                            COPYRIGHT
 *
 *  pcb-rnd, interactive printed circuit board design
 *  (this file is based on PCB, interactive printed circuit board design)
 *  Copyright (C) 1994,1995,1996 Thomas Nau
 *  Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton
 *
 *  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 St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *  Contact:
 *    Project page: http://repo.hu/projects/pcb-rnd
 *    lead developer: http://repo.hu/projects/pcb-rnd/contact.html
 *    mailing list: pcb-rnd (at) list.repo.hu (send "subscribe")
 *
 *
 *  Old contact info:
 *  Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA
 *  haceaton@aplcomm.jhuapl.edu
 *
 */

#include "config.h"
#include "autoroute.h"
#include <librnd/core/plugins.h>
#include <librnd/hid/hid.h>
#include <librnd/core/actions.h>
#include <librnd/core/event.h>
#include "funchash_core.h"

static const char pcb_acts_AutoRoute[] = "AutoRoute(AllRats|SelectedRats)";
static const char pcb_acth_AutoRoute[] = "Auto-route some or all rat lines.";
/* DOC: autoroute.html */
static fgw_error_t pcb_act_AutoRoute(fgw_arg_t *res, int argc, fgw_arg_t *argv)
{
	int op;

	RND_ACT_CONVARG(1, FGW_KEYWORD, AutoRoute, op = fgw_keyword(&argv[1]));

	rnd_hid_busy(&PCB->hidlib, 1);
	switch(op) {
		case F_AllRats:
		case F_All:
			if (AutoRoute(rnd_false))
				pcb_board_set_changed_flag(PCB, rnd_true);
			break;
		case F_SelectedRats:
		case F_Selected:
			if (AutoRoute(rnd_true))
				pcb_board_set_changed_flag(PCB, rnd_true);
			break;
		default:
			RND_ACT_FAIL(AutoRoute);
			return 1;
	}
	rnd_hid_busy(&PCB->hidlib, 0);
	RND_ACT_IRES(0);
	return 0;
}

static const char *autoroute_cookie = "autoroute plugin";

rnd_action_t autoroute_action_list[] = {
	{"AutoRoute", pcb_act_AutoRoute, pcb_acth_AutoRoute, pcb_acts_AutoRoute},
};

int pplg_check_ver_autoroute(int ver_needed) { return 0; }

void pplg_uninit_autoroute(void)
{
	rnd_remove_actions_by_cookie(autoroute_cookie);
}

int pplg_init_autoroute(void)
{
	RND_API_CHK_VER;
	RND_REGISTER_ACTIONS(autoroute_action_list, autoroute_cookie)
	return 0;
}