On Mar 28, 2008, at 6:00 PM, Sherm Pendley wrote: On Fri, Mar 28, 2008 at 8:21 PM, Rick Mann <email@hidden> wrote:
On Mar 28, 2008, at 5:12 PM, Sherm Pendley wrote: > sys/sysctl.h > > Searching in the help turns up nothing. Command-double-click turns > up nothing. > > Use the terminal, Luke! :-) > > find /usr/include -name '*.h' -print0 | xargs -0 grep kinfo_proc
Thanks. I'll keep that around. But really, Xcode should handle this.
You're right - it should.
How do I know it's in /usr and not in /System/Library?
You don't. If you knew where it was, you wouldn't have asked. :-)
Am I supposed
to check in multiple places each time (which is very often) Xcode doesn't find something?
If you find (lol) yourself needing to do this often, you could do what any good *nix user would do: write a script. :-)
#!/bin/sh
for name in $@ ; do find /usr/include -name '*.h' -print0 | xargs -0 grep $name find /System/Library -name '*.h' -print0 | xargs -0 grep $name find /Library -name '*.h' -print0 | xargs -0 grep $name done
Save that as "find-def", then just "find-def kinfo_proc" whenever you need it. Someone with sufficient AppleScript-fu (which I lack, sorry) could probably hook this into Xcode's script menu, so that it finds the currently selected text instead of the command-line arguments.
Yes, it's klunky, and no, you're not "supposed" to have to do this. It's a workaround - klunky goes with the territory.
Which is exactly why we index SDKs and system headers with a source-code-aware Spotlight indexer. Spotlight finds that symbol in less than a second without a trip to Terminal. You shouldn't have to do what "any good *NIX user does" when you have a Mac :-)
As to why the Documentation Viewer (and Spotlight, and even Google) doesn't provide a better direct answer, well, kinfo_proc is somewhat obscure, and there aren't actually any C functions that are defined to take a kinfo_proc as an input parameter or return it as a result. (sysctl takes a void * in the position that you would supply a pointer to a kinfo_proc structure). The only real documentation that exists for it at all, on any OS, is in the sysctl(3) man page, and that's one mention in source code, barely more than there is in that tech note.
So please file a Radar bug that low-level kernel APIs need better API documentation, and avail yourself of Spotlight to search for things if you don't know where they might be: that's exactly what it's there for.
Chris |