OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /v/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src                      Date:   22-Mar-2008 19:37:25
  Branch: HEAD                             Handle: 2008032218372400

  Modified files:
    openpkg-src/asterisk    asterisk.patch

  Log:
    add an Asterisk 1.6 port of app_backticks.c from me

  Summary:
    Revision    Changes     Path
    1.36        +155 -13    openpkg-src/asterisk/asterisk.patch
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/asterisk/asterisk.patch
  ============================================================================
  $ cvs diff -u -r1.35 -r1.36 asterisk.patch
  --- openpkg-src/asterisk/asterisk.patch       22 Mar 2008 15:58:06 -0000      
1.35
  +++ openpkg-src/asterisk/asterisk.patch       22 Mar 2008 18:37:24 -0000      
1.36
  @@ -1,6 +1,6 @@
   Index: Makefile
   --- Makefile.orig    2008-03-18 16:58:50 +0100
  -+++ Makefile 2008-03-22 16:56:21 +0100
  ++++ Makefile 2008-03-22 17:34:52 +0100
   @@ -121,42 +121,20 @@
    
    # Define standard directories for various platforms
  @@ -73,7 +73,7 @@
        mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
   Index: cdr/cdr_custom.c
   --- cdr/cdr_custom.c.orig    2007-11-21 00:16:15 +0100
  -+++ cdr/cdr_custom.c 2008-03-22 16:56:03 +0100
  ++++ cdr/cdr_custom.c 2008-03-22 17:34:52 +0100
   @@ -78,7 +78,7 @@
                                        ast_log(LOG_WARNING, "Format string too 
long, will be truncated, at line %d\n", var->lineno);
                                ast_copy_string(format, var->value, 
sizeof(format) - 1);
  @@ -85,7 +85,7 @@
                                        break;
   Index: cdr/cdr_sqlite3_custom.c
   --- cdr/cdr_sqlite3_custom.c.orig    2008-03-18 16:58:50 +0100
  -+++ cdr/cdr_sqlite3_custom.c 2008-03-22 16:56:03 +0100
  ++++ cdr/cdr_sqlite3_custom.c 2008-03-22 17:34:52 +0100
   @@ -317,7 +317,7 @@
                return AST_MODULE_LOAD_DECLINE;
    
  @@ -97,7 +97,7 @@
                ast_log(LOG_ERROR, "Could not open database %s.\n", filename);
   Index: channels/console_video.h
   --- channels/console_video.h.orig    2008-01-09 19:03:40 +0100
  -+++ channels/console_video.h 2008-03-22 16:56:03 +0100
  ++++ channels/console_video.h 2008-03-22 17:34:52 +0100
   @@ -28,10 +28,7 @@
                "console {device}"
    #else
  @@ -112,7 +112,7 @@
        "console {videodevice|videocodec"       \
   Index: configure
   --- configure.orig   2008-03-18 16:50:53 +0100
  -+++ configure        2008-03-22 16:56:03 +0100
  ++++ configure        2008-03-22 17:34:52 +0100
   @@ -4026,12 +4026,6 @@
        # note- does not work on FreeBSD
    
  @@ -128,7 +128,7 @@
         if test ${sysconfdir} = '${prefix}/etc'; then
   Index: include/asterisk/module.h
   --- include/asterisk/module.h.orig   2008-02-27 09:20:15 +0100
  -+++ include/asterisk/module.h        2008-03-22 16:56:03 +0100
  ++++ include/asterisk/module.h        2008-03-22 17:34:52 +0100
   @@ -271,7 +271,7 @@
    /* forward declare this pointer in modules, so that macro/function
       calls that need it can get it, since it will actually be declared
  @@ -140,7 +140,7 @@
    #define __MODULE_INFO_SECTION
   Index: main/Makefile
   --- main/Makefile.orig       2008-03-17 23:24:46 +0100
  -+++ main/Makefile    2008-03-22 16:56:03 +0100
  ++++ main/Makefile    2008-03-22 17:34:52 +0100
   @@ -82,10 +82,7 @@
    endif
    
  @@ -155,7 +155,7 @@
    ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
   Index: main/tcptls.c
   --- main/tcptls.c.orig       2008-03-12 23:50:14 +0100
  -+++ main/tcptls.c    2008-03-22 16:56:03 +0100
  ++++ main/tcptls.c    2008-03-22 17:34:52 +0100
   @@ -189,6 +189,7 @@
        if (!ast_strlen_zero(cfg->cafile) || !ast_strlen_zero(cfg->capath)) {
                if (SSL_CTX_load_verify_locations(cfg->ssl_ctx, 
S_OR(cfg->cafile, NULL), S_OR(cfg->capath,NULL)) == 0)
  @@ -166,8 +166,17 @@
        ast_verb(0, "SSL certificate ok\n");
   Index: menuselect-tree
   --- menuselect-tree.orig     2008-03-18 18:05:36 +0100
  -+++ menuselect-tree  2008-03-22 16:56:03 +0100
  -@@ -262,7 +262,6 @@
  ++++ menuselect-tree  2008-03-22 17:35:02 +0100
  +@@ -134,6 +134,8 @@
  + </member>
  + <member name="app_system" displayname="Generic System() application" 
remove_on_change="apps/app_system.o apps/app_system.so">
  + </member>
  ++<member name="app_backticks" displayname="Generic Backticks() application" 
remove_on_change="apps/app_backticks.o apps/app_backticks.so">
  ++</member>
  + <member name="app_talkdetect" displayname="Playback with Talk Detection" 
remove_on_change="apps/app_talkdetect.o apps/app_talkdetect.so">
  + </member>
  + <member name="app_test" displayname="Interface Test Application" 
remove_on_change="apps/app_test.o apps/app_test.so">
  +@@ -262,7 +264,6 @@
    </member>
    <member name="chan_zap" displayname="Zapata Telephony" 
remove_on_change="channels/chan_zap.o channels/chan_zap.so">
        <depend>res_smdi</depend>
  @@ -175,7 +184,7 @@
        <depend>zaptel</depend>
        <depend>tonezone</depend>
        <use>pri</use>
  -@@ -616,9 +615,9 @@
  +@@ -616,9 +617,9 @@
                <member name="CORE-SOUNDS-EN-ULAW" displayname="English, mu-Law 
format">
                </member>
                <member name="CORE-SOUNDS-EN-ALAW" displayname="English, a-Law 
format">
  @@ -186,7 +195,7 @@
                </member>
                <member name="CORE-SOUNDS-EN-G729" displayname="English, G.729 
format">
                </member>
  -@@ -676,6 +675,7 @@
  +@@ -676,6 +677,7 @@
                <member name="EXTRA-SOUNDS-EN-ULAW" displayname="English, 
mu-Law format">
                </member>
                <member name="EXTRA-SOUNDS-EN-ALAW" displayname="English, a-Law 
format">
  @@ -196,7 +205,7 @@
                </member>
   Index: sounds/sounds.xml
   --- sounds/sounds.xml.orig   2008-03-06 05:46:17 +0100
  -+++ sounds/sounds.xml        2008-03-22 16:56:03 +0100
  ++++ sounds/sounds.xml        2008-03-22 17:34:52 +0100
   @@ -4,9 +4,9 @@
                <member name="CORE-SOUNDS-EN-ULAW" displayname="English, mu-Law 
format">
                </member>
  @@ -216,3 +225,136 @@
                </member>
                <member name="EXTRA-SOUNDS-EN-GSM" displayname="English, GSM 
format" >
                </member>
  +Index: apps/app_backticks.c
  +--- apps/app_backticks.c.orig        2008-03-22 19:24:28 +0100
  ++++ apps/app_backticks.c     2008-03-22 19:29:01 +0100
  +@@ -0,0 +1,129 @@
  ++
  ++#include "asterisk.h"
  ++
  ++ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.36 $")
  ++
  ++#include <stdio.h> 
  ++#include <asterisk/file.h>
  ++#include <asterisk/logger.h>
  ++#include <asterisk/channel.h>
  ++#include <asterisk/pbx.h>
  ++#include <asterisk/module.h>
  ++#include <asterisk/lock.h>
  ++#include <asterisk/app.h>
  ++#include <stdlib.h>
  ++#include <unistd.h>
  ++#include <string.h>
  ++
  ++static char *app      = "BackTicks";
  ++static char *synopsis = "Execute a shell command and save the result as a 
variable.";
  ++static char *desc     = "  Backticks(<VARNAME>|<command>)\n\n"
  ++                        "Be sure to include a full path to the command!\n";
  ++
  ++static char *do_backticks(char *command, char *buf, size_t len) 
  ++{
  ++    int fds[2], pid = 0;
  ++    char *ret = NULL;
  ++
  ++    memset(buf, 0, len);
  ++    if (pipe(fds)) {    
  ++        ast_log(LOG_WARNING, "Pipe/Exec failed\n");
  ++    } else {
  ++        pid = fork();
  ++        if (pid < 0) {
  ++            ast_log(LOG_WARNING, "Fork failed\n");
  ++            close(fds[0]);
  ++            close(fds[1]);
  ++        } else if (pid) {
  ++            /* parent */
  ++            close(fds[1]);
  ++            read(fds[0], buf, len);
  ++            close(fds[0]);
  ++            ret = buf;
  ++        } else {
  ++            /* child */
  ++            char *argv[255] = {0};
  ++            int argc = 0;
  ++            char *p;
  ++            char *mycmd = ast_strdupa(command);
  ++            close(fds[0]);
  ++            dup2(fds[1], STDOUT_FILENO);
  ++            argv[argc++] = mycmd;
  ++            do {
  ++                if ((p = strchr(mycmd, ' '))) {
  ++                    *p = '\0';
  ++                    mycmd = ++p;
  ++                    argv[argc++] = mycmd;
  ++                }
  ++            } while (p != NULL);
  ++            close(fds[1]);          
  ++            execv(argv[0], argv); 
  ++            ast_log(LOG_ERROR, "exec of %s failed\n", argv[0]);
  ++            exit(0);
  ++        }
  ++    }
  ++    return ret;
  ++}
  ++
  ++static int backticks_exec(struct ast_channel *chan, void *data)
  ++{
  ++    int res = 0;
  ++    const char *usage = "Usage: Backticks(<VARNAME>|<command>)";
  ++    char buf[1024], *argv[2], *mydata;
  ++    int argc = 0;
  ++    
  ++    if (!data) {
  ++        ast_log(LOG_WARNING, "%s\n", usage);
  ++        return -1;
  ++    }
  ++    ast_autoservice_start(chan);
  ++    if (!(mydata = ast_strdupa(data))) {
  ++        ast_log(LOG_ERROR, "Memory Error!\n");
  ++        res = -1;
  ++    } else {
  ++        if((argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / 
sizeof(argv[0]))) < 2) {
  ++            ast_log(LOG_WARNING, "%s\n", usage);
  ++            res = -1;
  ++        }
  ++        if (do_backticks(argv[1], buf, sizeof(buf)))
  ++            pbx_builtin_setvar_helper(chan, argv[0], buf);
  ++        else {
  ++            ast_log(LOG_WARNING, "No Data!\n");
  ++            res = -1;
  ++        }
  ++    }
  ++    ast_autoservice_stop(chan);
  ++    return res;
  ++}
  ++
  ++static int function_backticks(struct ast_channel *chan, const char *cmd, 
char *data, char *buf, size_t len)
  ++{
  ++    if (!do_backticks(data, buf, len)) {
  ++        ast_log(LOG_WARNING, "No Data!\n");
  ++        return -1;
  ++    }
  ++    return 0;
  ++}
  ++
  ++static struct ast_custom_function backticks_function = {
  ++    .name     = "BACKTICKS", 
  ++    .desc     = "Executes a shell command and evaluates to the result.", 
  ++    .syntax   = "BACKTICKS(<command>)", 
  ++    .synopsis = "Executes a shell command.", 
  ++    .read     = function_backticks
  ++};
  ++
  ++static int unload_module(void)
  ++{
  ++    ast_custom_function_unregister(&backticks_function);
  ++    return ast_unregister_application(app);
  ++}
  ++
  ++static int load_module(void)
  ++{
  ++    ast_custom_function_register(&backticks_function);
  ++    return ast_register_application(app, backticks_exec, synopsis, desc);
  ++}
  ++
  ++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "BACKTICKS() dialplan function");
  ++
  @@ .
______________________________________________________________________
OpenPKG                                             http://openpkg.org
CVS Repository Commit List                     openpkg-cvs@openpkg.org

Reply via email to