ref: 1e836fda203372381999353ed365afddb170bdbe
dir: /bin/c/
#!/bin/rc rfork e fn isatty {grep -s '/dev/cons' /fd/0ctl} fn struct { ignore = (/sys/include/ape) search = $* if(~ $#search 0) search = (.) if(~ $search *^$ignore^*) ignore = (cat) if not ignore = (grep -v -e^'^'$ignore) files = `{walk -f $search | $ignore | grep '\.[chsyl]$'} echo 'X ,x@^(typedef[ \n]+)?struct([^}][^;]*\n*)+}.*;\n@ g@^(typedef[ \n]+)?struct[ ]+'$regex'@ { !echo '•' $%:$%dot(1) p }' | sam -d $files >[2]/dev/null } fn function { ignore = ('\.root.s$' 'cmd/python/') search = $* if(~ $#search 0) search = (.) if(~ $search *^$ignore^*) ignore = (cat) if not ignore = (grep -v -e^'^'$ignore) files = `{walk -f $search | $ignore | grep '\.[chsyl]$'} sep = ' • ' echo 'X ,x g@^([^ ]+[ ]+)*'$regex'\(@ { !echo -n $%:$%dot(1) $sep p }' | sam -d $files >[2]/dev/null } op = 'struct' identifier = '[a-zA-Z_0-9]*' flagfmt = 'f,s'; args = '[regexp] [searchpath]' if(! eval `''{aux/getflags $*}) aux/usage if(~ $flagf 1) op = 'function' if(~ $flags 1) op = 'struct' if(! isatty){ nl = ' ' '*' = `$nl{cat} if(! ~ $#% 0) cd `{basename -d $%} } regex = `{echo $1 | sed 's:%:'$identifier':g'} if(~ $#regex 0) regex = $identifier shift $op $*