Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:47:59 2009

## Asterisk developer's documentation

# app_cdr.c File Reference

Applications connected with CDR engine. More...

`#include <sys/types.h>`
`#include <stdlib.h>`
`#include "asterisk.h"`
`#include "asterisk/channel.h"`
`#include "asterisk/module.h"`
`#include "asterisk/pbx.h"`

Include dependency graph for app_cdr.c:

Go to the source code of this file.

## Functions

char * | description (void)
| Provides a description of the module.
char * | key ()
| Returns the ASTERISK_GPL_KEY.
int | load_module (void)
| Initialize the module.
static int | nocdr_exec (struct ast_channel *chan, void *data)
int | unload_module (void)
| Cleanup all module structures, sockets, etc.
int | usecount (void)
| Provides a usecount.

## Variables

| LOCAL_USER_DECL
static char * | nocdr_app = "NoCDR"
static char * | nocdr_descrip
static char * | nocdr_synopsis = "Tell Asterisk to not maintain a CDR for the current call"
| STANDARD_LOCAL_USER
static char * | tdesc = "Tell Asterisk to not maintain a CDR for the current call"

## Detailed Description

Applications connected with CDR engine.

Definition in file app_cdr.c.

## Function Documentation

char* description | ( | void |  | ) |

Provides a description of the module.

Returns:
  a short description of your module

Definition at line 82 of file app_cdr.c.

    00083 {
    00084    return tdesc;
    00085 }

char* key | ( | void |  | ) |

Returns the ASTERISK_GPL_KEY.

This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:

     char *key(void) {
             return ASTERISK_GPL_KEY;
     }

Returns:
  ASTERISK_GPL_KEY

Definition at line 94 of file app_cdr.c.

References ASTERISK_GPL_KEY.

    00095 {
    00096    return ASTERISK_GPL_KEY;
    00097 }

int load_module | ( | void |  | ) |

Initialize the module.

This function is called at module load time. Put all code in here that needs to set up your module's hardware, software, registrations, etc.

Returns:
  This function should return 0 on success and non-zero on failure. If the module is not loaded successfully, Asterisk will call its unload_module() function.

Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.

Returns:
  int Always 0.

TE STUFF END

Definition at line 77 of file app_cdr.c.

References ast_register_application(), and nocdr_exec().

    00078 {
    00079    return ast_register_application(nocdr_app, nocdr_exec, nocdr_synopsis, nocdr_descrip);
    00080 }

static int nocdr_exec | ( | struct ast_channel * | chan,
|  | void * | data |
| ) |  |  | `[static]`

Definition at line 50 of file app_cdr.c.

References ast_cdr_free(), ast_channel::cdr, LOCAL_USER_ADD, and LOCAL_USER_REMOVE.

Referenced by load_module().

    00051 {
    00052    struct localuser *u;
    00053
    00054    LOCAL_USER_ADD(u);
    00055
    00056    if (chan->cdr) {
    00057       ast_cdr_free(chan->cdr);
    00058       chan->cdr = NULL;
    00059    }
    00060
    00061    LOCAL_USER_REMOVE(u);
    00062
    00063    return 0;
    00064 }

int unload_module | ( | void |  | ) |

Cleanup all module structures, sockets, etc.

This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).

Returns:
  Zero on success, or non-zero on error.

Definition at line 66 of file app_cdr.c.

References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.

    00067 {
    00068    int res;
    00069
    00070    res = ast_unregister_application(nocdr_app);
    00071
    00072    STANDARD_HANGUP_LOCALUSERS;
    00073
    00074    return res;
    00075 }

int usecount | ( | void |  | ) |

Provides a usecount.

This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.

Returns:
  The module's usecount.

Definition at line 87 of file app_cdr.c.

References STANDARD_USECOUNT.

    00088 {
    00089    int res;
    00090    STANDARD_USECOUNT(res);
    00091    return res;
    00092 }

## Variable Documentation

LOCAL_USER_DECL

Definition at line 48 of file app_cdr.c.

char* nocdr_app = "NoCDR"`[static]`

Definition at line 43 of file app_cdr.c.

char* nocdr_descrip`[static]`

Initial value:

    "  NoCDR(): This application will tell Asterisk not to maintain a CDR for the\n"
    "current call.\n"

Definition at line 39 of file app_cdr.c.

char* nocdr_synopsis = "Tell Asterisk to not maintain a CDR for the current call"`[static]`

Definition at line 44 of file app_cdr.c.

STANDARD_LOCAL_USER

Definition at line 46 of file app_cdr.c.

char* tdesc = "Tell Asterisk to not maintain a CDR for the current call"`[static]`

Definition at line 37 of file app_cdr.c.