[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Interpreter for automation schematics



Thanks for that. I am making progress now...

Where can I find a list of all procedures and globals that can be used for scripting? The libgeda wikipage doesn't seem to cover them all.


//John


On 03/30/2011 01:36 PM, Peter Clifton wrote:
If you type ":" to get a scheme prompt, then enter:
(display "work dammit!")

in gschem, it does indeed print to the console. I wonder if your
function was not in scope when you called (test2)

I managed to make it work by putting your definition of test2 in my
~/.gEDA/gschemrc file, and then executing (test2) from the guile command
prompt in gschem.


BTW.. I hope you won't be too upset if in some couple of gEDA versions
time we have to change the syntax for placing executable code in various
config files. It may mean separating executable bits into a different
file explicitly, then referring to them from the (non-executable) config
files.

The reason is that we expect things like gafrc and gedarc to be sent
along with projects, and the fact they support executable code inside
them opens the same (if not greater) scope, for malicious code to be
hidden inside, similar to macro-viruses to be hidden in gEDA projects
which get passed around.

Whilst I don't think it is particularly likely that anyone in the
community will attempt to do this with the intent to attack any other
community member, Peter Brett did write a proof of concept exploit which
showed the risk. You can execute bad code without the user taking any
action other than opening the schematic file.


Btw.. the auto-uref and auto-place attribs functions are wired up to
hook calls inside gschem which pass arguments.

See hooks defined in gschem/src/g_register.c

For example:

move_component_hook = create_hook ("move-component-hook", 1);

Which is called in gschem/src/o_move.c

     switch (object->type) {
       case (OBJ_COMPLEX):
       case (OBJ_PLACEHOLDER):

         if (scm_hook_empty_p(move_component_hook) == SCM_BOOL_F&&
             object != NULL) {
           scm_run_hook(move_component_hook,
                        scm_cons (g_make_attrib_smob_list
                                  (w_current, object), SCM_EOL));
         }
	....

The g_make_attrib_smob_list() function creates a list of
attribute_smob's corresponding to the attributes of the object being
moved.

Each attrib_smob has a world pointer (to the TOPLEVEL struct), and a
pointer to the text object (which is the particular attribute).


To be completely honest, I think our guile API is a real mess. Peter
Brett wrote a nicer one, but it hasn't been merged yet. I'm a little
sceptical about what can be achieved through the hooks gschem provides.

Btw.. I've attached another example hook - one I wrote as a demo, and
that I use locally. It removes component numbering (and replaces with
a ?) when you copy a component with a refdes already set.

You hook it up with this in your gschemrc:

(load-from-path "/home/pcjc2/.gEDA/unnumber-refdes.scm")
(add-hook! copy-component-hook unnumber-refdes)


Best regards,



_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user