[asterisk-dev] current status (Re: policy for managing headers)

Luigi Rizzo rizzo at icir.org
Mon Nov 19 12:02:32 CST 2007


At the bottom of this email you can find the current status of
"#include" statements in trunk, computed with

 grep -r '#include' . | grep -v .svn | grep -v Binary | \
	grep -v configure | grep -v autom | \
	awk '{$1 = ""; print $0} ' | sort | uniq -c | sort -nr | more

(there are about 400 C source files, though many are in subdirectories
imported from other projects and not converted/cleaned up yet).

A few reflections:
+ most files include "asterisk.h" which is how it should be
  (although asterisk.h contains a lot of global variables and options
  that are not of general use, so it might make sense move those
  extra definitions elsewhere and load the file only when necessary);

+ an incredibly large number of files include logger.h; this is no wonder
  given that this is our main reporting facility. However this seems to
  suggest that logger.h should be included by asterisk.h too, to avoid
  confusion. Same for <errno.h> because, in the end, we want to do
  error checking everywhere.

+ the number of inclusions of "channel.h" really seems overkill - while
  many apps and core files deal with channels, I don't think so many
  files really need to play with the internals of a channe. Probably
  a suimple "struct ast channel;" in asterisk.h should be enough.

Additionally, if you look carefully at the files, there is some mixture
in the content of specific headers - e.g. logger.h exports common APIs,
but also other very specific functions (e.g. ast_register_verbose(),
ast_console_puts_mutable() ) that are used only once or twice across
the tree. Same for many of the options in options.h

	cheers
	luigi

 281  "asterisk.h"
 257  "asterisk/logger.h"
 243  "asterisk/channel.h"
 206  "asterisk/module.h"
 188  "asterisk/utils.h"
 188  "asterisk/options.h"
 188  "asterisk/lock.h"
 174  "asterisk/pbx.h"
 173  <errno.h>
 133  <stdio.h>
 131  "asterisk/file.h"
 130  <string.h>
 122  "asterisk/app.h"
 116  <stdlib.h>
 106  "asterisk/config.h"
  92  "asterisk/cli.h"
  76  <fcntl.h>
  76  <ctype.h>
  73  <sys/time.h>
  70  <unistd.h>
  68  <sys/types.h>
  62  "asterisk/linkedlists.h"
  59  <netinet/in.h>
  58  <sys/stat.h>
  56  "asterisk/translate.h"
  54  <signal.h>
  50  "asterisk/callerid.h"
  47  "asterisk/sched.h"
  42  <math.h>
  42  "asterisk/frame.h"
  39  "asterisk/manager.h"
  38  <arpa/inet.h>
  36  "asterisk/musiconhold.h"
  35  <time.h>
  35  "config.h"
  35  "asterisk/stringfields.h"
  34  <assert.h>
  34  "f2c.h"
  32  "asterisk/say.h"
  31  "asterisk/causes.h"
  30  "../include/db.h"
  27  <sys/ioctl.h>
  26  <sys/socket.h>
  26  <limits.h>
  26  "asterisk/io.h"
  26  "asterisk/devicestate.h"
  25  <stdarg.h>
  25  "asterisk/cdr.h"
  24  <sys/signal.h>
  24  <sys/param.h>
  24  <regex.h>
  24  <pthread.h>
  24  "iLBC_define.h"
  24  "asterisk/astdb.h"
  23  "asterisk/dsp.h"
  22  "asterisk/features.h"
  22  "asterisk/endian.h"





More information about the asterisk-dev mailing list