Wireshark-dev: Re: [Wireshark-dev] RFD: Creating subdirectories in epan/dissectors/

From: Evan Huus <eapache@xxxxxxxxx>
Date: Wed, 29 Aug 2012 12:03:41 -0400
On Wed, Aug 29, 2012 at 11:47 AM, Jeff Morriss
<jeff.morriss.ws@xxxxxxxxx> wrote:
> Joerg Mayer wrote:
>>
>> What I'd like to do is put these dissectors that belong *to a single
>> protocol*
>> into a subdirectory of that name, i.e. move them to
>>
>> xmpp/packet-conference.c
>> xmpp/packet-conference.h
>> xmpp/packet-core.c
>> xmpp/packet-core.h
>> xmpp/packet-gtalk.c
>> xmpp/packet-gtalk.h
>> xmpp/packet-jingle.c
>> xmpp/packet-jingle.h
>> xmpp/packet-other.c
>> xmpp/packet-other.h
>> xmpp/packet-utils.c
>> xmpp/packet-utils.h
>> xmpp/packet-xmpp.c    <- special case, main protocol name
>> xmpp/packet-xmpp.h    <- special case, main protocol name
>>
>> What do you think?
>
>
> I'm not 100% convinced either way, but I have to admit I do like having all
> the dissectors in the same directory.  "make -j 40" (on my 32-vCPU SPARC)
> works better that way ;-).

I'm pretty sure an autotools-generated Makefile will already recurse
to fill the given job-count as long as there aren't any weird
dependencies in place, so it shouldn't make any difference. Can't
speak for cmake or windows builds.

> More seriously, I imagine I'd find it easier to
> do:
>
> vi epan/dissectors/packet-xmpp<tab><tab>
>
> instead of:
>
> vi
> epan/dissectors/packet-xmpp<tab><tab>[1]^H^H^H^H^H^H^H^H^H^H^Hxmpp<tab>/<tab><tab>
>
> [1] insert grumpy remark here

Fair enough. So another tweak to the suggested naming:
packet-xmpp/xmpp-whatever.c

That should avoid file-name conflicts and work well with existing
muscle-memory. A good shell will even complete the "/xmpp-" in a
single <tab> assuming there are no makefiles in the directory to screw
things up. (That's another question though - do we keep one top-level
makefile in epan/dissectors/, or do we add one in each sub-directory?)

> I also like being able to, for example:
>
> grep tvb_get_ptr epan/dissectors/packet-*.c
>
> instead of:
>
> grep tvb_get_ptr epan/dissectors/packet-*.c epan/dissectors/*/packet-*.c

That's what tools like cscope [1] are for :)

Alternatively, there is a nicer way with grep:
grep -R --include="packet-*.c" tvb_get_ptr epan/dissectors/

[1] http://cscope.sourceforge.net/