9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sig
@ 2003-07-29 14:47 Rob 'Commander' Pike
  2003-07-29 16:02 ` Dan Cross
  2003-07-29 17:28 ` [9fans] spam script rog
  0 siblings, 2 replies; 4+ messages in thread
From: Rob 'Commander' Pike @ 2003-07-29 14:47 UTC (permalink / raw)
  To: 9fans

inspired by rog's tweak to lookman, which didn't quite do what i want,
i wrote a little script to extract function signatures from the man pages:

% sig string auth_respond
	Point string(Image *dst, Point p, Image *src, Point sp, Font *f, char *s)
	int auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nresp, AuthGetkey *getkey, char *fmt, ...);
%

i show it below.  presotto has installed an earlier version, soon to
be updated, on sources.  you'll also want to sync against sources
because the draw(2) man page had a silliness that stopped sig working
right on it, which is also fixed there.

enjoy

-rob

#!/bin/rc
# Usage: sig key ...
#	prints out function signatures by grepping the manual


*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'}	# fold case, delete funny chars
if(~ $#* 0){
	echo Usage: sig function ... >/fd/2
	exit 1
}

for (i) {
	files=`{grep -l '[ 	]\*?'$i'\(' /sys/man/2/*}
	for(j in $files) {
		{echo .nr LL 20i; sed -n '/^.SH SYNOPSIS/,/^.SH.*DESCR/p'  $j } |
			sed 's/[ 	]+/ /g;s/^ +//;/^\.nf/d' |
			nroff -man |
			grep -i -e '[ 	]\*?'$i'\(' | sed 's/^[ +]/	/'
	}
}

exit 0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] sig
  2003-07-29 14:47 [9fans] sig Rob 'Commander' Pike
@ 2003-07-29 16:02 ` Dan Cross
  2003-07-29 20:49   ` boyd, rounin
  2003-07-29 17:28 ` [9fans] spam script rog
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Cross @ 2003-07-29 16:02 UTC (permalink / raw)
  To: 9fans

"Rob 'Commander' Pike" <r@google.com> writes:
>
> [...]

Commander?  What, did you join the Navy or something?

	- Dan C.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [9fans] spam script
  2003-07-29 14:47 [9fans] sig Rob 'Commander' Pike
  2003-07-29 16:02 ` Dan Cross
@ 2003-07-29 17:28 ` rog
  1 sibling, 0 replies; 4+ messages in thread
From: rog @ 2003-07-29 17:28 UTC (permalink / raw)
  To: 9fans

while we're on the subject of shell scripts, if anyone is interested
in building up a spam file with a view to training a bayesian filter
or somesuch, here's a script that makes it easier.

i haven't installed a filter yet, but i've accumulated 15MB of spam in
a month and a half...

it works under acme Mail; just highlight some messages and execute
"spam" (assuming that's what you've named the script); alternatively
execute "spam" within a message window.

unfortunately it's unable to delete the messages automatically and
currently it assumes it's dealing with /mail/fs/mbox.

  cheers,
    rog.

PS. it was a bit of an effort to get the current selection of an acme
window from within a script; it would make things easier if:
- the id of the current acme window was available as well as its tag filename;
- the addr file didn't revert back to its default state when the ctl file was closed;
- the data file provided only the number of characters selected by the address.
... but maybe these are important properties, i dunno.

#!/bin/rc
rfork n
fn save {
	{echo From spam; cat $1; echo} >> $home/spam
}
fn saveselected {
	cd $1
	{echo 'addr=dot' > ctl; x=`{cat}} < addr
	msgs=`{>[2] /dev/null dd -count 1 -bs `{echo $x(2) $x(1) -p | dc} < data |
		sed -e '/^	/d' -e 's/^\(deleted\)-//'  -e 's:/.*::'}
	for(i in $msgs)
		save /mail/fs/mbox/$i/raw
}

if(~ $#* 0 && ~ $#% 1){
	if(~ $% /mail/fs/mbox/){
		poss=`{awk '{print $1, $6}' < /mnt/acme/index | grep '^[0-9]+ /mail/fs/mbox/$'}
		if(! ~ $#poss 2){
			echo no acme window found
			exit nope
		}
		saveselected /mnt/acme/$poss(1)
	}

	if not
	if(test -f $%/raw)
		save $%/raw
}

if not
for(i in $*){
	save /mail/fs/mbox/$i/raw
}



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] sig
  2003-07-29 16:02 ` Dan Cross
@ 2003-07-29 20:49   ` boyd, rounin
  0 siblings, 0 replies; 4+ messages in thread
From: boyd, rounin @ 2003-07-29 20:49 UTC (permalink / raw)
  To: 9fans

> Commander?  What, did you join the Navy or something?

tomcat ball, 3.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-29 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 14:47 [9fans] sig Rob 'Commander' Pike
2003-07-29 16:02 ` Dan Cross
2003-07-29 20:49   ` boyd, rounin
2003-07-29 17:28 ` [9fans] spam script rog

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).