Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
November 2007
- 8 participants
- 332 discussions
13 Nov '07
Author: mikej
Date: Tue Nov 13 18:18:52 2007
New Revision: 6251
Modified:
freeswitch/trunk/src/mod/applications/mod_expr/Makefile
Log:
fix build error on OsX 10.5
Modified: freeswitch/trunk/src/mod/applications/mod_expr/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/Makefile (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/Makefile Tue Nov 13 18:18:52 2007
@@ -1,6 +1,6 @@
BASE=../../../..
LOCAL_SOURCES=expreval.c exprinit.c exprobj.c exprutil.c exprfunc.c exprmem.c exprpars.c exprval.c
LOCAL_OBJS=expreval.o exprinit.o exprobj.o exprutil.o exprfunc.o exprmem.o exprpars.o exprval.o
-LOCAL_LIBADD=-lm
+LOCAL_LDFLAGS=-lm
include $(BASE)/build/modmake.rules
1
0
13 Nov '07
Author: mikej
Date: Tue Nov 13 18:12:34 2007
New Revision: 6250
Modified:
freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/Makefile
freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
Log:
fix sun studio build
Modified: freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/Makefile (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/Makefile Tue Nov 13 18:12:34 2007
@@ -13,8 +13,9 @@
MRCP_APR_INCLUDES = -I../../../../libs/apr/include
MRCP_APU_INCLUDES = -I../../../../libs/apr-util/include
-LOCAL_CFLAGS= -Wno-unused
-LOCAL_CFLAGS+= -Wno-comment -Wno-sign-compare $(OPENMRCP_INCLUDE) $(MRCP_APR_INCLUDES) $(MRCP_APU_INCLUDES)
+#do not specify gcc specific compiler flags
+#LOCAL_CFLAGS= -Wno-unused -Wno-comment -Wno-sign-compare
+LOCAL_CFLAGS= $(OPENMRCP_INCLUDE) $(MRCP_APR_INCLUDES) $(MRCP_APU_INCLUDES)
LOCAL_LIBADD=$(OPENMRCP_LIBS)
Modified: freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c (original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c Tue Nov 13 18:12:34 2007
@@ -56,6 +56,7 @@
#pragma warning (disable:188)
#endif
+#include <switch.h>
#include "openmrcp_client.h"
#include "mrcp_client_context.h"
@@ -63,7 +64,6 @@
#include "mrcp_synthesizer.h"
#include "mrcp_generic_header.h"
-#include <switch.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_openmrcp_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_openmrcp_shutdown);
1
0
13 Nov '07
Author: anthm
Date: Tue Nov 13 17:06:44 2007
New Revision: 6249
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Log:
fix some stuff and add set_user func
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Tue Nov 13 17:06:44 2007
@@ -372,6 +372,7 @@
limit_execute_sql(sql, NULL);
switch_safe_free(sql);
stream->write_function(stream, "+OK");
+ goto done;
} else if (!strcasecmp(argv[0], "select")) {
char buf[256] = "";
callback_t cbt = { 0 };
1
0
13 Nov '07
Author: anthm
Date: Tue Nov 13 17:05:02 2007
New Revision: 6248
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Log:
fix some stuff and add set_user func
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Tue Nov 13 17:05:02 2007
@@ -349,7 +349,7 @@
goto error;
}
- if (!strcasecmp(argv[0], "set")) {
+ if (!strcasecmp(argv[0], "insert")) {
if (argc < 4) {
goto error;
}
@@ -363,7 +363,16 @@
switch_safe_free(sql);
stream->write_function(stream, "+OK");
goto done;
- } else if (!strcasecmp(argv[0], "get")) {
+ } else if (!strcasecmp(argv[0], "delete")) {
+ if (argc < 2) {
+ goto error;
+ }
+ sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+ assert(sql);
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ stream->write_function(stream, "+OK");
+ } else if (!strcasecmp(argv[0], "select")) {
char buf[256] = "";
callback_t cbt = { 0 };
if (argc < 3) {
1
0
Author: mikej
Date: Tue Nov 13 17:04:42 2007
New Revision: 6247
Modified:
freeswitch/trunk/libs/curl/configure.ac
freeswitch/trunk/libs/curl/lib/config.h.in
Log:
fix qwirk in solaris build
Modified: freeswitch/trunk/libs/curl/configure.ac
==============================================================================
--- freeswitch/trunk/libs/curl/configure.ac (original)
+++ freeswitch/trunk/libs/curl/configure.ac Tue Nov 13 17:04:42 2007
@@ -417,6 +417,15 @@
dnl socket lib?
AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
+AC_CHECK_LIB(socket, socket,
+ [HAVE_SOCKET="1"
+ LIBS="$LIBS -lsocket"
+ ])
+
+if test "$HAVE_SOCKET" = "1"; then
+ AC_DEFINE(HAVE_SOCKET, 1, [If you have socket])
+fi
+
dnl dl lib?
AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
Modified: freeswitch/trunk/libs/curl/lib/config.h.in
==============================================================================
--- freeswitch/trunk/libs/curl/lib/config.h.in (original)
+++ freeswitch/trunk/libs/curl/lib/config.h.in Tue Nov 13 17:04:42 2007
@@ -621,16 +621,16 @@
/* Define to the function return type for send. */
#undef SEND_TYPE_RETV
-/* The size of `curl_off_t', as computed by sizeof. */
+/* The size of a `curl_off_t', as computed by sizeof. */
#undef SIZEOF_CURL_OFF_T
-/* The size of `long', as computed by sizeof. */
+/* The size of a `long', as computed by sizeof. */
#undef SIZEOF_LONG
-/* The size of `size_t', as computed by sizeof. */
+/* The size of a `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
-/* The size of `time_t', as computed by sizeof. */
+/* The size of a `time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T
/* Define to 1 if you have the ANSI C header files. */
@@ -685,7 +685,7 @@
/* type to use in place of in_addr_t if not defined */
#undef in_addr_t
-/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* type to use in place of socklen_t if not defined */
1
0
13 Nov '07
Author: anthm
Date: Tue Nov 13 17:03:05 2007
New Revision: 6246
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Log:
fix some stuff and add set_user func
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Tue Nov 13 17:03:05 2007
@@ -408,7 +408,7 @@
mydata = switch_core_session_strdup(session, data);
argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
}
- printf("WTF [%s] %d\n", argv[0], argc);
+
if (argc < 4) {
goto error;
}
1
0
[commit] r6245 - in freeswitch/trunk: . src/mod/dialplans/mod_dialplan_asterisk w32/Library
by Freeswitch SVN 13 Nov '07
by Freeswitch SVN 13 Nov '07
13 Nov '07
Author: mikej
Date: Tue Nov 13 15:59:42 2007
New Revision: 6245
Modified:
freeswitch/trunk/Freeswitch.sln
freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/ (props changed)
freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.vcproj
freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj
Log:
add mod_dialplan_asterisk to the windowns build.
Modified: freeswitch/trunk/Freeswitch.sln
==============================================================================
--- freeswitch/trunk/Freeswitch.sln (original)
+++ freeswitch/trunk/Freeswitch.sln Tue Nov 13 15:59:42 2007
@@ -3,20 +3,20 @@
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchConsole", "w32\Console\FreeSwitchConsole.vcproj", "{1AF3A893-F7BE-43DD-B697-8AB2397C0D67}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchCoreLib", "w32\Library\FreeSwitchCore.vcproj", "{202D7A4E-760D-4D0E-AFA1-D7459CED30FF}"
ProjectSection(ProjectDependencies) = postProject
- {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
- {101130D1-3EA6-4ED2-B65D-CEB5243A20ED} = {101130D1-3EA6-4ED2-B65D-CEB5243A20ED}
- {EEF031CB-FED8-451E-A471-91EC8D4F6750} = {EEF031CB-FED8-451E-A471-91EC8D4F6750}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
- {89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C}
- {8D04B550-D240-4A44-8A18-35DA3F7038D9} = {8D04B550-D240-4A44-8A18-35DA3F7038D9}
{50AD0E28-B8D7-4FCC-8FC3-599F6AC69761} = {50AD0E28-B8D7-4FCC-8FC3-599F6AC69761}
+ {8D04B550-D240-4A44-8A18-35DA3F7038D9} = {8D04B550-D240-4A44-8A18-35DA3F7038D9}
+ {89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C}
+ {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {EEF031CB-FED8-451E-A471-91EC8D4F6750} = {EEF031CB-FED8-451E-A471-91EC8D4F6750}
+ {101130D1-3EA6-4ED2-B65D-CEB5243A20ED} = {101130D1-3EA6-4ED2-B65D-CEB5243A20ED}
+ {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3} = {6EDFEFD5-3596-4FA9-8EBA-B331547B35A3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_g729", "src\mod\codecs\mod_g729\mod_g729.vcproj", "{1D95CD95-0DE2-48C3-AC23-D5C7D1C9C0F0}"
@@ -26,15 +26,15 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_gsm", "src\mod\codecs\mod_gsm\mod_gsm.vcproj", "{4926323F-4EA8-4B7D-A3D3-65488725988F}"
ProjectSection(ProjectDependencies) = postProject
- {8FD2E297-4096-47E5-9258-C48FF1841523} = {8FD2E297-4096-47E5-9258-C48FF1841523}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {8FD2E297-4096-47E5-9258-C48FF1841523} = {8FD2E297-4096-47E5-9258-C48FF1841523}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sndfile", "src\mod\formats\mod_sndfile\mod_sndfile.vcproj", "{AFAC0568-7548-42D5-9F6A-8D3400A1E4F6}"
ProjectSection(ProjectDependencies) = postProject
- {3D0370CA-BED2-4657-A475-32375CBCB6E4} = {3D0370CA-BED2-4657-A475-32375CBCB6E4}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {3D0370CA-BED2-4657-A475-32375CBCB6E4} = {3D0370CA-BED2-4657-A475-32375CBCB6E4}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_g711", "src\mod\codecs\mod_g711\mod_g711.vcproj", "{B1FE4613-3F4B-4DAF-9714-2472BF8F56AE}"
@@ -44,16 +44,16 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_iax", "src\mod\endpoints\mod_iax\mod_iax.vcproj", "{3A5B9131-F20C-4A85-9447-6C1610941CEE}"
ProjectSection(ProjectDependencies) = postProject
- {5CC054B7-6DAA-46BF-9A08-3B33B83E8D3E} = {5CC054B7-6DAA-46BF-9A08-3B33B83E8D3E}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {5CC054B7-6DAA-46BF-9A08-3B33B83E8D3E} = {5CC054B7-6DAA-46BF-9A08-3B33B83E8D3E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_PortAudio", "src\mod\endpoints\mod_portaudio\mod_PortAudio.vcproj", "{5FD31A25-5D83-4794-8BEE-904DAD84CE71}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {0A18A071-125E-442F-AFF7-A3F68ABECF99} = {0A18A071-125E-442F-AFF7-A3F68ABECF99}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99} = {0A18A071-125E-442F-AFF7-A3F68ABECF99}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_l16", "src\mod\codecs\mod_l16\mod_l16.vcproj", "{5844AFE1-AA3E-4BDB-A9EF-119AEF19DF88}"
@@ -63,14 +63,14 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_speex", "src\mod\codecs\mod_speex\mod_speex.vcproj", "{5580D60E-0F77-4716-9CD4-B8E5986FA375}"
ProjectSection(ProjectDependencies) = postProject
- {1C469CDD-A3AF-4A94-A592-B2CF12F2D918} = {1C469CDD-A3AF-4A94-A592-B2CF12F2D918}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {1C469CDD-A3AF-4A94-A592-B2CF12F2D918} = {1C469CDD-A3AF-4A94-A592-B2CF12F2D918}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_woomera", "src\mod\endpoints\mod_woomera\mod_woomera.vcproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Codecs", "Codecs", "{F881ADA2-2F1A-4046-9FEB-191D9422D781}"
@@ -91,8 +91,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_xml", "src\mod\dialplans\mod_dialplan_xml\mod_dialplan_xml.vcproj", "{07113B25-D3AF-4E04-BA77-4CD1171F022C}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "FreeSwitchSetup", "w32\Setup\Setup.vdproj", "{B17FFBE6-A942-4056-8346-B624FB5D995B}"
@@ -106,22 +106,22 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_directory", "src\mod\dialplans\mod_dialplan_directory\mod_dialplan_directory.vcproj", "{A27CCA23-1541-4337-81A4-F0A6413078A0}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_zeroconf", "src\mod\event_handlers\mod_zeroconf\mod_zeroconf.vcproj", "{C7705DC4-2088-493E-AF8D-65BC6D65C125}"
ProjectSection(ProjectDependencies) = postProject
- {0D826AF5-0506-4C50-BB8B-7DB019AC21AE} = {0D826AF5-0506-4C50-BB8B-7DB019AC21AE}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {49C34584-B6DA-448F-83CF-27584DC9FC90} = {49C34584-B6DA-448F-83CF-27584DC9FC90}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {49C34584-B6DA-448F-83CF-27584DC9FC90} = {49C34584-B6DA-448F-83CF-27584DC9FC90}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {0D826AF5-0506-4C50-BB8B-7DB019AC21AE} = {0D826AF5-0506-4C50-BB8B-7DB019AC21AE}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_event_multicast", "src\mod\event_handlers\mod_event_multicast\mod_event_multicast.vcproj", "{784113EF-44D9-4949-835D-7065D3C7AD08}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libteletone", "libs\libteletone\libteletone.vcproj", "{89385C74-5860-4174-9CAF-A39E7C48909C}"
@@ -130,10 +130,10 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey", "src\mod\languages\mod_spidermonkey\mod_spidermonkey.vcproj", "{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}"
ProjectSection(ProjectDependencies) = postProject
- {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
- {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
+ {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ASR-TTS", "ASR-TTS", "{4CF6A6AC-07DE-4B9E-ABE1-7F98B64E0BB0}"
@@ -155,22 +155,22 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_ilbc", "src\mod\codecs\mod_ilbc\mod_ilbc.vcproj", "{D3EC0AFF-76FC-4210-A825-9A17410660A3}"
ProjectSection(ProjectDependencies) = postProject
- {989BB874-7AF1-44CB-8E5C-CC8113D267E8} = {989BB874-7AF1-44CB-8E5C-CC8113D267E8}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {989BB874-7AF1-44CB-8E5C-CC8113D267E8} = {989BB874-7AF1-44CB-8E5C-CC8113D267E8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dingaling", "src\mod\endpoints\mod_dingaling\mod_dingaling.vcproj", "{FFAA4C52-3A53-4F99-90C1-D59D1F0427F3}"
ProjectSection(ProjectDependencies) = postProject
- {E727E8F6-935D-46FE-8B0E-37834748A0E3} = {E727E8F6-935D-46FE-8B0E-37834748A0E3}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{1906D736-08BD-4EE1-924F-B536249B9A54} = {1906D736-08BD-4EE1-924F-B536249B9A54}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {E727E8F6-935D-46FE-8B0E-37834748A0E3} = {E727E8F6-935D-46FE-8B0E-37834748A0E3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_commands", "src\mod\applications\mod_commands\mod_commands.vcproj", "{30A5B29C-983E-4580-9FD0-D647CCDCC7EB}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Loggers", "Loggers", "{A7AB4405-FDB7-4853-9FBB-1516B1C3D80A}"
@@ -184,41 +184,41 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_xml_rpc", "src\mod\xml_int\mod_xml_rpc\mod_xml_rpc.vcproj", "{CBEC7225-0C21-4DA8-978E-1F158F8AD950}"
ProjectSection(ProjectDependencies) = postProject
- {155844C3-EC5F-407F-97A4-A2DDADED9B2F} = {155844C3-EC5F-407F-97A4-A2DDADED9B2F}
- {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
- {A3FE0076-B366-429D-A238-D7304DA7D3C1} = {A3FE0076-B366-429D-A238-D7304DA7D3C1}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{356EC96D-4C9F-47B5-9083-FC328B87BA94} = {356EC96D-4C9F-47B5-9083-FC328B87BA94}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {A3FE0076-B366-429D-A238-D7304DA7D3C1} = {A3FE0076-B366-429D-A238-D7304DA7D3C1}
+ {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
+ {155844C3-EC5F-407F-97A4-A2DDADED9B2F} = {155844C3-EC5F-407F-97A4-A2DDADED9B2F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_rss", "src\mod\applications\mod_rss\mod_rss.vcproj", "{B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_conference", "src\mod\applications\mod_conference\mod_conference.vcproj", "{C24FB505-05D7-4319-8485-7540B44C8603}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dptools", "src\mod\applications\mod_dptools\mod_dptools.vcproj", "{B5881A85-FE70-4F64-8607-2CAAE52669C6}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_event_socket", "src\mod\event_handlers\mod_event_socket\mod_event_socket.vcproj", "{05515420-16DE-4E63-BE73-85BE85BA5142}"
ProjectSection(ProjectDependencies) = postProject
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_cdr", "src\mod\event_handlers\mod_cdr\mod_cdr.vcproj", "{3D1EED36-A510-4EDB-B4D9-4E0F4A5EC2A8}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Libraries", "_Libraries", "{EB910B0D-F27D-4B62-B67B-DE834C99AC5B}"
@@ -231,8 +231,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdingaling", "libs\libdingaling\libdingaling.vcproj", "{1906D736-08BD-4EE1-924F-B536249B9A54}"
ProjectSection(ProjectDependencies) = postProject
- {E727E8F6-935D-46FE-8B0E-37834748A0E3} = {E727E8F6-935D-46FE-8B0E-37834748A0E3}
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
+ {E727E8F6-935D-46FE-8B0E-37834748A0E3} = {E727E8F6-935D-46FE-8B0E-37834748A0E3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsrtp", "libs\srtp\libsrtp.vcproj", "{EEF031CB-FED8-451E-A471-91EC8D4F6750}"
@@ -257,8 +257,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libaprutil", "libs\win32\apr-util\libaprutil.vcproj", "{F057DA7F-79E5-4B00-845C-EF446EF055E3}"
ProjectSection(ProjectDependencies) = postProject
- {101130D1-3EA6-4ED2-B65D-CEB5243A20ED} = {101130D1-3EA6-4ED2-B65D-CEB5243A20ED}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {101130D1-3EA6-4ED2-B65D-CEB5243A20ED} = {101130D1-3EA6-4ED2-B65D-CEB5243A20ED}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Downloads", "_Downloads", "{C120A020-773F-4EA3-923F-B67AF28B750D}"
@@ -276,8 +276,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mDNSResponder static library", "libs\win32\howl\libmDNSResponder.vcproj", "{49C34584-B6DA-448F-83CF-27584DC9FC90}"
ProjectSection(ProjectDependencies) = postProject
- {0D826AF5-0506-4C50-BB8B-7DB019AC21AE} = {0D826AF5-0506-4C50-BB8B-7DB019AC21AE}
{5927104D-C14C-4AC8-925C-4AB681762E75} = {5927104D-C14C-4AC8-925C-4AB681762E75}
+ {0D826AF5-0506-4C50-BB8B-7DB019AC21AE} = {0D826AF5-0506-4C50-BB8B-7DB019AC21AE}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsndfile", "libs\win32\libsndfile\libsndfile.vcproj", "{3D0370CA-BED2-4657-A475-32375CBCB6E4}"
@@ -297,34 +297,34 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sofia", "src\mod\endpoints\mod_sofia\mod_sofia.vcproj", "{0DF3ABD0-DDC0-4265-B778-07C66780979B}"
ProjectSection(ProjectDependencies) = postProject
- {70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {70A49BC2-7500-41D0-B75D-EDCC5BE987A0}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{DF018947-0FFF-4EB3-BDEE-441DC81DA7A4} = {DF018947-0FFF-4EB3-BDEE-441DC81DA7A4}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {70A49BC2-7500-41D0-B75D-EDCC5BE987A0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libg726", "libs\codec\g726\libg726.vcproj", "{5A6A281A-AA50-470A-8305-202BDA1CD1BF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_g726", "src\mod\codecs\mod_g726\mod_g726.vcproj", "{486369EB-F150-4B56-BCC8-77B9E18FF5F5}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{5A6A281A-AA50-470A-8305-202BDA1CD1BF} = {5A6A281A-AA50-470A-8305-202BDA1CD1BF}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libg7xx", "libs\codec\g7xx\libg7xx.vcproj", "{D71E7338-8D9C-4FE4-A15F-D5CC60202C7C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_g722", "src\mod\codecs\mod_g722\mod_g722.vcproj", "{D42518CC-7475-454D-B392-0E132C07D761}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{D71E7338-8D9C-4FE4-A15F-D5CC60202C7C} = {D71E7338-8D9C-4FE4-A15F-D5CC60202C7C}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsofia_sip_ua_static", "libs\win32\sofia\libsofia_sip_ua_static.vcproj", "{70A49BC2-7500-41D0-B75D-EDCC5BE987A0}"
ProjectSection(ProjectDependencies) = postProject
- {8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A} = {8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A}
{DF018947-0FFF-4EB3-BDEE-441DC81DA7A4} = {DF018947-0FFF-4EB3-BDEE-441DC81DA7A4}
+ {8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A} = {8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download PTHREAD", "libs\win32\Download PTHREAD.vcproj", "{8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A}"
@@ -336,81 +336,81 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_g723_1", "src\mod\codecs\mod_g723_1\mod_g723_1.vcproj", "{FEA1EEF7-876F-48DE-88BF-C0E3E606D758}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_native_file", "src\mod\formats\mod_native_file\mod_native_file.vcproj", "{9254C4B0-6F60-42B6-BB3A-36D63FC001C7}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_core_db", "src\mod\languages\mod_spidermonkey_core_db\mod_spidermonkey_core_db.vcproj", "{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}"
ProjectSection(ProjectDependencies) = postProject
- {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_teletone", "src\mod\languages\mod_spidermonkey_teletone\mod_spidermonkey_teletone.vcproj", "{8F992C49-6C51-412F-B2A3-34EAB708EB65}"
ProjectSection(ProjectDependencies) = postProject
- {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {89385C74-5860-4174-9CAF-A39E7C48909C} = {89385C74-5860-4174-9CAF-A39E7C48909C}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libudns", "libs\win32\udns\libudns.vcproj", "{4043FC6A-9A30-4577-8AD5-9B233C9575D8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_enum", "src\mod\applications\mod_enum\mod_enum.vcproj", "{71A967D5-0E99-4CEF-A587-98836EE6F2EF}"
ProjectSection(ProjectDependencies) = postProject
- {4043FC6A-9A30-4577-8AD5-9B233C9575D8} = {4043FC6A-9A30-4577-8AD5-9B233C9575D8}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {4043FC6A-9A30-4577-8AD5-9B233C9575D8} = {4043FC6A-9A30-4577-8AD5-9B233C9575D8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_etpan", "src\mod\languages\mod_spidermonkey_etpan\mod_spidermonkey_etpan.vcproj", "{D6C82F86-2B05-4A7F-8CC6-D2592E66FBB9}"
ProjectSection(ProjectDependencies) = postProject
- {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- {BA4DED3C-E56F-4484-BFC3-9C13E461A1BE} = {BA4DED3C-E56F-4484-BFC3-9C13E461A1BE}
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}
+ {BA4DED3C-E56F-4484-BFC3-9C13E461A1BE} = {BA4DED3C-E56F-4484-BFC3-9C13E461A1BE}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_odbc", "src\mod\languages\mod_spidermonkey_odbc\mod_spidermonkey_odbc.vcproj", "{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}"
ProjectSection(ProjectDependencies) = postProject
- {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libetpan", "libs\win32\etpan\libetpan.vcproj", "{BA4DED3C-E56F-4484-BFC3-9C13E461A1BE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_xml_curl", "src\mod\xml_int\mod_xml_curl\mod_xml_curl.vcproj", "{AB91A099-7690-4ECF-8994-E458F4EA1ED4}"
ProjectSection(ProjectDependencies) = postProject
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
{87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "say", "say", "{6CD61A1D-797C-470A-BE08-8C31B68BB336}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_say_en", "src\mod\say\mod_say_en\mod_say_en.vcproj", "{988CACF7-3FCB-4992-BE69-77872AE67DC8}"
ProjectSection(ProjectDependencies) = postProject
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "portaudio", "libs\portaudio\build\msvc\portaudio.vcproj", "{0A18A071-125E-442F-AFF7-A3F68ABECF99}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_xml_cdr", "src\mod\xml_int\mod_xml_cdr\mod_xml_cdr.vcproj", "{08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}"
ProjectSection(ProjectDependencies) = postProject
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {87EE9DA4-DE1E-4448-8324-183C98DCA588} = {87EE9DA4-DE1E-4448-8324-183C98DCA588}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_amr", "src\mod\codecs\mod_amr\mod_amr.vcproj", "{8DEB383C-4091-4F42-A56F-C9E46D552D79}"
@@ -567,16 +567,16 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpcore", "libs\openmrcp\mrcpcore\mrcpcore.vcproj", "{829A9309-3B94-43C0-846B-7EC9D6D35F8B}"
ProjectSection(ProjectDependencies) = postProject
- {AA91F0AC-6562-435E-814C-5C94689FEFA2} = {AA91F0AC-6562-435E-814C-5C94689FEFA2}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {AA91F0AC-6562-435E-814C-5C94689FEFA2} = {AA91F0AC-6562-435E-814C-5C94689FEFA2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rtspcore", "libs\openmrcp\rtspcore\rtspcore.vcproj", "{EB751DC4-87BD-4766-B78D-DFB64BA9F988}"
ProjectSection(ProjectDependencies) = postProject
- {829A9309-3B94-43C0-846B-7EC9D6D35F8B} = {829A9309-3B94-43C0-846B-7EC9D6D35F8B}
- {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
+ {829A9309-3B94-43C0-846B-7EC9D6D35F8B} = {829A9309-3B94-43C0-846B-7EC9D6D35F8B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpmediaframe", "libs\openmrcp\module\mrcpmediaframe\mrcpmediaframe.vcproj", "{9EA22C31-BB7E-4C40-A698-2C6792D1E0C6}"
@@ -593,8 +593,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpsofiasip", "libs\openmrcp\module\mrcpsofiasip\mrcpsofiasip.vcproj", "{819C7242-6184-46FE-BC7B-C7E25C0581EE}"
ProjectSection(ProjectDependencies) = postProject
- {829A9309-3B94-43C0-846B-7EC9D6D35F8B} = {829A9309-3B94-43C0-846B-7EC9D6D35F8B}
{70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {70A49BC2-7500-41D0-B75D-EDCC5BE987A0}
+ {829A9309-3B94-43C0-846B-7EC9D6D35F8B} = {829A9309-3B94-43C0-846B-7EC9D6D35F8B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mrcpv2agent", "libs\openmrcp\module\mrcpv2agent\mrcpv2agent.vcproj", "{FB64EA08-3BC0-48AE-BE4B-74F1024B756E}"
@@ -604,27 +604,27 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenmrcpclient", "libs\openmrcp\platform\openmrcpclient\libopenmrcpclient.vcproj", "{A407B661-D7DC-4E30-B268-FFF3296C35E6}"
ProjectSection(ProjectDependencies) = postProject
- {FB64EA08-3BC0-48AE-BE4B-74F1024B756E} = {FB64EA08-3BC0-48AE-BE4B-74F1024B756E}
- {9EA22C31-BB7E-4C40-A698-2C6792D1E0C6} = {9EA22C31-BB7E-4C40-A698-2C6792D1E0C6}
- {819C7242-6184-46FE-BC7B-C7E25C0581EE} = {819C7242-6184-46FE-BC7B-C7E25C0581EE}
{CF78E84D-8456-44F2-8197-0E0E88D30A3C} = {CF78E84D-8456-44F2-8197-0E0E88D30A3C}
+ {819C7242-6184-46FE-BC7B-C7E25C0581EE} = {819C7242-6184-46FE-BC7B-C7E25C0581EE}
+ {9EA22C31-BB7E-4C40-A698-2C6792D1E0C6} = {9EA22C31-BB7E-4C40-A698-2C6792D1E0C6}
+ {FB64EA08-3BC0-48AE-BE4B-74F1024B756E} = {FB64EA08-3BC0-48AE-BE4B-74F1024B756E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_openmrcp", "src\mod\asr_tts\mod_openmrcp\mod_openmrcp.vcproj", "{E7116F50-2B10-472F-92BD-C8667AA9C1AE}"
ProjectSection(ProjectDependencies) = postProject
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- {A407B661-D7DC-4E30-B268-FFF3296C35E6} = {A407B661-D7DC-4E30-B268-FFF3296C35E6}
- {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{70A49BC2-7500-41D0-B75D-EDCC5BE987A0} = {70A49BC2-7500-41D0-B75D-EDCC5BE987A0}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {F057DA7F-79E5-4B00-845C-EF446EF055E3} = {F057DA7F-79E5-4B00-845C-EF446EF055E3}
+ {A407B661-D7DC-4E30-B268-FFF3296C35E6} = {A407B661-D7DC-4E30-B268-FFF3296C35E6}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_spidermonkey_socket", "src\mod\languages\mod_spidermonkey_socket\mod_spidermonkey_socket.vcproj", "{028C7278-05D7-4E18-82FE-BE231B844F41}"
ProjectSection(ProjectDependencies) = postProject
- {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}
- {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
- {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
{204FA0DE-305D-4414-AE2E-F195A23F390D} = {204FA0DE-305D-4414-AE2E-F195A23F390D}
+ {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF}
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F} = {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_voicemail", "src\mod\applications\mod_voicemail\mod_voicemail.vcproj", "{D7F1E3F2-A3F4-474C-8555-15122571AF52}"
@@ -672,6 +672,11 @@
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_dialplan_asterisk", "src\mod\dialplans\mod_dialplan_asterisk\mod_dialplan_asterisk.vcproj", "{E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}"
+ ProjectSection(ProjectDependencies) = postProject
+ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -1272,6 +1277,12 @@
{65A6273D-FCAB-4C55-B09E-65100141A5D4}.Release|Win32.ActiveCfg = Release|Win32
{65A6273D-FCAB-4C55-B09E-65100141A5D4}.Release|Win32.Build.0 = Release|Win32
{65A6273D-FCAB-4C55-B09E-65100141A5D4}.Release|x64.ActiveCfg = Release|Win32
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}.Debug|Win32.Build.0 = Debug|Win32
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}.Debug|x64.ActiveCfg = Debug|Win32
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}.Release|Win32.ActiveCfg = Release|Win32
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}.Release|Win32.Build.0 = Release|Win32
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1308,6 +1319,7 @@
{65A6273D-FCAB-4C55-B09E-65100141A5D4} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78}
{07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
+ {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4}
{C7705DC4-2088-493E-AF8D-65BC6D65C125} = {9ADF1E48-2F5C-4ED7-A893-596259FABFE0}
{784113EF-44D9-4949-835D-7065D3C7AD08} = {9ADF1E48-2F5C-4ED7-A893-596259FABFE0}
{05515420-16DE-4E63-BE73-85BE85BA5142} = {9ADF1E48-2F5C-4ED7-A893-596259FABFE0}
Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c (original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c Tue Nov 13 15:59:42 2007
@@ -261,8 +261,9 @@
app = argv[2];
if ((arg = strchr(app, '('))) {
+ char *p;
*arg++ = '\0';
- char *p = strrchr(arg, ')');
+ p = strrchr(arg, ')');
if (p) {
*p = '\0';
}
Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.vcproj
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.vcproj (original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.vcproj Tue Nov 13 15:59:42 2007
@@ -3,7 +3,7 @@
ProjectType="Visual C++"
Version="8.00"
Name="mod_dialplan_asterisk"
- ProjectGUID="{07113B25-D3AF-4E04-BA77-4CD1171F022C}"
+ ProjectGUID="{E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24}"
RootNamespace="mod_dialplan_asterisk"
Keyword="Win32Proj"
>
@@ -22,9 +22,60 @@
CharacterSet="2"
>
<Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
</Configuration>
<Configuration
Name="Release|Win32"
@@ -33,9 +84,60 @@
CharacterSet="2"
>
<Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
</Configuration>
</Configurations>
<References>
Modified: freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj
==============================================================================
--- freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj (original)
+++ freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj Tue Nov 13 15:59:42 2007
@@ -263,6 +263,10 @@
>
</File>
<File
+ RelativePath="..\..\src\switch_config.c"
+ >
+ </File>
+ <File
RelativePath="..\..\src\switch_console.c"
>
</File>
1
0
Author: mikej
Date: Tue Nov 13 15:49:48 2007
New Revision: 6244
Modified:
freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj
Log:
use switch_time.c changed file name.
Modified: freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj
==============================================================================
--- freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj (original)
+++ freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj Tue Nov 13 15:49:48 2007
@@ -207,10 +207,6 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
- RelativePath="..\..\src\softtimer.c"
- >
- </File>
- <File
RelativePath="..\..\libs\stfu\stfu.c"
>
<FileConfiguration
@@ -427,6 +423,10 @@
>
</File>
<File
+ RelativePath="..\..\src\switch_time.c"
+ >
+ </File>
+ <File
RelativePath="..\..\src\switch_utils.c"
>
</File>
@@ -477,11 +477,11 @@
>
</File>
<File
- RelativePath="..\..\src\include\private\switch_core.h"
+ RelativePath="..\..\src\include\switch_core.h"
>
</File>
<File
- RelativePath="..\..\src\include\switch_core.h"
+ RelativePath="..\..\src\include\private\switch_core.h"
>
</File>
<File
1
0
13 Nov '07
Author: mikej
Date: Tue Nov 13 15:23:26 2007
New Revision: 6242
Modified:
freeswitch/trunk/src/mod/applications/mod_expr/conio.h
freeswitch/trunk/src/mod/applications/mod_expr/exprconf.h
freeswitch/trunk/src/mod/applications/mod_expr/expreval.c
freeswitch/trunk/src/mod/applications/mod_expr/expreval.h
freeswitch/trunk/src/mod/applications/mod_expr/exprfunc.c
freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h
freeswitch/trunk/src/mod/applications/mod_expr/exprincl.h
freeswitch/trunk/src/mod/applications/mod_expr/exprinit.c
freeswitch/trunk/src/mod/applications/mod_expr/exprmem.c
freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h
freeswitch/trunk/src/mod/applications/mod_expr/exprobj.c
freeswitch/trunk/src/mod/applications/mod_expr/exprpars.c
freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h
freeswitch/trunk/src/mod/applications/mod_expr/exprutil.c
freeswitch/trunk/src/mod/applications/mod_expr/exprval.c
Log:
dos2unix
Modified: freeswitch/trunk/src/mod/applications/mod_expr/conio.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/conio.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/conio.h Tue Nov 13 15:23:26 2007
@@ -1,161 +1,161 @@
-/* A conio implementation for Mingw/Dev-C++.
- *
- * Written by:
- * Hongli Lai <hongli(a)telekabel.nl>
- * tkorrovi <tkorrovi(a)altavista.net> on 2002/02/26.
- * Andrew Westcott <ajwestco(a)users.sourceforge.net>
- *
- * Offered for use in the public domain without any warranty.
- */
-
-#ifndef _CONIO_H_
-#define _CONIO_H_
-
-
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BLINK 0
-
-typedef enum
-{
- BLACK,
- BLUE,
- GREEN,
- CYAN,
- RED,
- MAGENTA,
- BROWN,
- LIGHTGRAY,
- DARKGRAY,
- LIGHTBLUE,
- LIGHTGREEN,
- LIGHTCYAN,
- LIGHTRED,
- LIGHTMAGENTA,
- YELLOW,
- WHITE
-} COLORS;
-
-
-#define cgets _cgets
-#define cprintf _cprintf
-#define cputs _cputs
-#define cscanf _cscanf
-#define ScreenClear clrscr
-
-/* blinkvideo */
-
-void clreol (void);
-void clrscr (void);
-
-int _conio_gettext (int left, int top, int right, int bottom,
- char *str);
-/* _conio_kbhit */
-
-void delline (void);
-
-/* gettextinfo */
-void gotoxy(int x, int y);
-/*
-highvideo
-insline
-intensevideo
-lowvideo
-movetext
-normvideo
-*/
-
-void gotoxy(int x, int y);
-
-void puttext (int left, int top, int right, int bottom, char *str);
-
-// Screen Variables
-
-/* ScreenCols
-ScreenGetChar
-ScreenGetCursor
-ScreenMode
-ScreenPutChar
-ScreenPutString
-ScreenRetrieve
-ScreenRows
-ScreenSetCursor
-ScreenUpdate
-ScreenUpdateLine
-ScreenVisualBell
-_set_screen_lines */
-
-void _setcursortype (int type);
-
-void textattr (int _attr);
-
-void textbackground (int color);
-
-void textcolor (int color);
-
-/* textmode */
-
-int wherex (void);
-
-int wherey (void);
-
-/* window */
-
-
-
-/* The code below was part of Mingw's conio.h */
-/*
- * conio.h
- *
- * Low level console I/O functions. Pretty please try to use the ANSI
- * standard ones if you are writing new code.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Colin Peters <colin(a)bird.fu.is.saga-u.ac.jp>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.4 $
- * $Author: hongli $
- * $Date: 2002/04/26 19:31:25 $
- *
- */
-
-char* _cgets (char*);
-int _cprintf (const char*, ...);
-int _cputs (const char*);
-int _cscanf (char*, ...);
-
-int _getch (void);
-int _getche (void);
-int _kbhit (void);
-int _putch (int);
-int _ungetch (int);
-
-
-int getch (void);
-int getche (void);
-int kbhit (void);
-int putch (int);
-int ungetch (int);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CONIO_H_ */
+/* A conio implementation for Mingw/Dev-C++.
+ *
+ * Written by:
+ * Hongli Lai <hongli(a)telekabel.nl>
+ * tkorrovi <tkorrovi(a)altavista.net> on 2002/02/26.
+ * Andrew Westcott <ajwestco(a)users.sourceforge.net>
+ *
+ * Offered for use in the public domain without any warranty.
+ */
+
+#ifndef _CONIO_H_
+#define _CONIO_H_
+
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define BLINK 0
+
+typedef enum
+{
+ BLACK,
+ BLUE,
+ GREEN,
+ CYAN,
+ RED,
+ MAGENTA,
+ BROWN,
+ LIGHTGRAY,
+ DARKGRAY,
+ LIGHTBLUE,
+ LIGHTGREEN,
+ LIGHTCYAN,
+ LIGHTRED,
+ LIGHTMAGENTA,
+ YELLOW,
+ WHITE
+} COLORS;
+
+
+#define cgets _cgets
+#define cprintf _cprintf
+#define cputs _cputs
+#define cscanf _cscanf
+#define ScreenClear clrscr
+
+/* blinkvideo */
+
+void clreol (void);
+void clrscr (void);
+
+int _conio_gettext (int left, int top, int right, int bottom,
+ char *str);
+/* _conio_kbhit */
+
+void delline (void);
+
+/* gettextinfo */
+void gotoxy(int x, int y);
+/*
+highvideo
+insline
+intensevideo
+lowvideo
+movetext
+normvideo
+*/
+
+void gotoxy(int x, int y);
+
+void puttext (int left, int top, int right, int bottom, char *str);
+
+// Screen Variables
+
+/* ScreenCols
+ScreenGetChar
+ScreenGetCursor
+ScreenMode
+ScreenPutChar
+ScreenPutString
+ScreenRetrieve
+ScreenRows
+ScreenSetCursor
+ScreenUpdate
+ScreenUpdateLine
+ScreenVisualBell
+_set_screen_lines */
+
+void _setcursortype (int type);
+
+void textattr (int _attr);
+
+void textbackground (int color);
+
+void textcolor (int color);
+
+/* textmode */
+
+int wherex (void);
+
+int wherey (void);
+
+/* window */
+
+
+
+/* The code below was part of Mingw's conio.h */
+/*
+ * conio.h
+ *
+ * Low level console I/O functions. Pretty please try to use the ANSI
+ * standard ones if you are writing new code.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ * Created by Colin Peters <colin(a)bird.fu.is.saga-u.ac.jp>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.4 $
+ * $Author: hongli $
+ * $Date: 2002/04/26 19:31:25 $
+ *
+ */
+
+char* _cgets (char*);
+int _cprintf (const char*, ...);
+int _cputs (const char*);
+int _cscanf (char*, ...);
+
+int _getch (void);
+int _getche (void);
+int _kbhit (void);
+int _putch (int);
+int _ungetch (int);
+
+
+int getch (void);
+int getche (void);
+int kbhit (void);
+int putch (int);
+int ungetch (int);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _CONIO_H_ */
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprconf.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprconf.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprconf.h Tue Nov 13 15:23:26 2007
@@ -1,29 +1,29 @@
-/*
- File: exprconf.h
- Auth: Brian Allen Vanderburg II
- Date: Thursday, October 20, 2005
- Desc: Configuration for ExprEval
-
- This file is part of ExprEval.
-*/
-
-#ifndef __BAVII_EXPRCONF_H
-#define __BAVII_EXPRCONF_H
-
-/*
- Error checking level
-
- 0: Don't check any errors (don't use errno). Divide by 0
- is avoided and the part that divides by 0 is 0. For example
- '4+1/0' is 4.
-
- 1: Check math errors.
-*/
-#define EXPR_ERROR_LEVEL_NONE 0
-#define EXPR_ERROR_LEVEL_CHECK 1
-
-#ifndef EXPR_ERROR_LEVEL
-#define EXPR_ERROR_LEVEL EXPR_ERROR_LEVEL_CHECK
-#endif
-
-#endif /* __BAVII_EXPRCONF_H */
+/*
+ File: exprconf.h
+ Auth: Brian Allen Vanderburg II
+ Date: Thursday, October 20, 2005
+ Desc: Configuration for ExprEval
+
+ This file is part of ExprEval.
+*/
+
+#ifndef __BAVII_EXPRCONF_H
+#define __BAVII_EXPRCONF_H
+
+/*
+ Error checking level
+
+ 0: Don't check any errors (don't use errno). Divide by 0
+ is avoided and the part that divides by 0 is 0. For example
+ '4+1/0' is 4.
+
+ 1: Check math errors.
+*/
+#define EXPR_ERROR_LEVEL_NONE 0
+#define EXPR_ERROR_LEVEL_CHECK 1
+
+#ifndef EXPR_ERROR_LEVEL
+#define EXPR_ERROR_LEVEL EXPR_ERROR_LEVEL_CHECK
+#endif
+
+#endif /* __BAVII_EXPRCONF_H */
Modified: freeswitch/trunk/src/mod/applications/mod_expr/expreval.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/expreval.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/expreval.c Tue Nov 13 15:23:26 2007
@@ -1,268 +1,268 @@
-/*
- File: expreval.c
- Auth: Brian Allen Vanderburg II
- Date: Wednesday, April 30, 2003
- Desc: Evaluation routines for the ExprEval library
-
- This file is part of ExprEval.
-*/
-
-/* Includes */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-
-/* Defines for error checking */
-#include <errno.h>
-
-#if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
-#define EXPR_RESET_ERR() errno = 0
-#define EXPR_CHECK_ERR() if(errno) return EXPR_ERROR_OUTOFRANGE
-#else
-#define EXPR_RESET_ERR()
-#define EXPR_CHECK_ERR()
-#endif
-
-
-/* This routine will evaluate an expression */
-int exprEval(exprObj *obj, EXPRTYPE *val)
- {
- EXPRTYPE dummy;
-
- if(val == NULL)
- val = &dummy;
-
- /* Make sure it was parsed successfully */
- if(!obj->parsedbad && obj->parsedgood && obj->headnode)
- {
- /* Do NOT reset the break count. Let is accumulate
- between calls until breaker function is called */
- return exprEvalNode(obj, obj->headnode, 0, val);
- }
- else
- return EXPR_ERROR_BADEXPR;
- }
-
-/* Evaluate a node */
-int exprEvalNode(exprObj *obj, exprNode *nodes, int curnode, EXPRTYPE *val)
- {
- int err;
- int pos;
- EXPRTYPE d1, d2;
-
- if(obj == NULL || nodes == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Update n to point to correct node */
- nodes += curnode;
-
- /* Check breaker count */
- if(obj->breakcur-- <= 0)
- {
- /* Reset count before returning */
- obj->breakcur = obj->breakcount;
-
- if(exprGetBreakResult(obj))
- {
- return EXPR_ERROR_BREAK;
- }
- }
-
- switch(nodes->type)
- {
- case EXPR_NODETYPE_MULTI:
- {
- /* Multi for multiple expressions in one string */
- for(pos = 0; pos < nodes->data.oper.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.oper.nodes, pos, val);
- if(err)
- return err;
- }
- break;
- }
-
- case EXPR_NODETYPE_ADD:
- {
- /* Addition */
- err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
- if(!err)
- *val = d1 + d2;
- else
- return err;
-
- break;
- }
-
- case EXPR_NODETYPE_SUBTRACT:
- {
- /* Subtraction */
- err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
- if(!err)
- *val = d1 - d2;
- else
- return err;
-
- break;
- }
-
- case EXPR_NODETYPE_MULTIPLY:
- {
- /* Multiplication */
- err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
- if(!err)
- *val = d1 * d2;
- else
- return err;
-
- break;
- }
-
- case EXPR_NODETYPE_DIVIDE:
- {
- /* Division */
- err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
- if(!err)
- {
- if(d2 != 0.0)
- *val = d1 / d2;
- else
- {
-#if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
- return EXPR_ERROR_DIVBYZERO;
-#else
- *val = 0.0;
- return EXPR_ERROR_NOERROR;
-#endif
- }
- }
- else
- return err;
-
- break;
- }
-
- case EXPR_NODETYPE_EXPONENT:
- {
- /* Exponent */
- err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = pow(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
- case EXPR_NODETYPE_NEGATE:
- {
- /* Negative value */
- err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
-
- if(!err)
- *val = -d1;
- else
- return err;
-
- break;
- }
-
-
- case EXPR_NODETYPE_VALUE:
- {
- /* Directly access the value */
- *val = nodes->data.value.value;
- break;
- }
-
- case EXPR_NODETYPE_VARIABLE:
- {
- /* Directly access the variable or constant */
- *val = *(nodes->data.variable.vaddr);
- break;
- }
-
- case EXPR_NODETYPE_ASSIGN:
- {
- /* Evaluate assignment subnode */
- err = exprEvalNode(obj, nodes->data.assign.node, 0, val);
-
- if(!err)
- {
- /* Directly assign the variable */
- *(nodes->data.assign.vaddr) = *val;
- }
- else
- return err;
-
- break;
- }
-
- case EXPR_NODETYPE_FUNCTION:
- {
- /* Evaluate the function */
- if(nodes->data.function.fptr == NULL)
- {
- /* No function pointer means we are not using
- function solvers. See if the function has a
- type to solve directly. */
- switch(nodes->data.function.type)
- {
- /* This is to keep the file from being too crowded.
- See exprilfs.h for the definitions. */
-#include "exprilfs.h"
-
-
- default:
- {
- return EXPR_ERROR_UNKNOWN;
- }
- }
- }
- else
- {
- /* Call the correct function */
- return (*(nodes->data.function.fptr))(obj,
- nodes->data.function.nodes, nodes->data.function.nodecount,
- nodes->data.function.refs, nodes->data.function.refcount, val);
- }
-
- break;
- }
-
- default:
- {
- /* Unknown node type */
- return EXPR_ERROR_UNKNOWN;
- }
- }
-
- return EXPR_ERROR_NOERROR;
- }
-
-
-
+/*
+ File: expreval.c
+ Auth: Brian Allen Vanderburg II
+ Date: Wednesday, April 30, 2003
+ Desc: Evaluation routines for the ExprEval library
+
+ This file is part of ExprEval.
+*/
+
+/* Includes */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+
+/* Defines for error checking */
+#include <errno.h>
+
+#if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
+#define EXPR_RESET_ERR() errno = 0
+#define EXPR_CHECK_ERR() if(errno) return EXPR_ERROR_OUTOFRANGE
+#else
+#define EXPR_RESET_ERR()
+#define EXPR_CHECK_ERR()
+#endif
+
+
+/* This routine will evaluate an expression */
+int exprEval(exprObj *obj, EXPRTYPE *val)
+ {
+ EXPRTYPE dummy;
+
+ if(val == NULL)
+ val = &dummy;
+
+ /* Make sure it was parsed successfully */
+ if(!obj->parsedbad && obj->parsedgood && obj->headnode)
+ {
+ /* Do NOT reset the break count. Let is accumulate
+ between calls until breaker function is called */
+ return exprEvalNode(obj, obj->headnode, 0, val);
+ }
+ else
+ return EXPR_ERROR_BADEXPR;
+ }
+
+/* Evaluate a node */
+int exprEvalNode(exprObj *obj, exprNode *nodes, int curnode, EXPRTYPE *val)
+ {
+ int err;
+ int pos;
+ EXPRTYPE d1, d2;
+
+ if(obj == NULL || nodes == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Update n to point to correct node */
+ nodes += curnode;
+
+ /* Check breaker count */
+ if(obj->breakcur-- <= 0)
+ {
+ /* Reset count before returning */
+ obj->breakcur = obj->breakcount;
+
+ if(exprGetBreakResult(obj))
+ {
+ return EXPR_ERROR_BREAK;
+ }
+ }
+
+ switch(nodes->type)
+ {
+ case EXPR_NODETYPE_MULTI:
+ {
+ /* Multi for multiple expressions in one string */
+ for(pos = 0; pos < nodes->data.oper.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.oper.nodes, pos, val);
+ if(err)
+ return err;
+ }
+ break;
+ }
+
+ case EXPR_NODETYPE_ADD:
+ {
+ /* Addition */
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+ if(!err)
+ *val = d1 + d2;
+ else
+ return err;
+
+ break;
+ }
+
+ case EXPR_NODETYPE_SUBTRACT:
+ {
+ /* Subtraction */
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+ if(!err)
+ *val = d1 - d2;
+ else
+ return err;
+
+ break;
+ }
+
+ case EXPR_NODETYPE_MULTIPLY:
+ {
+ /* Multiplication */
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+ if(!err)
+ *val = d1 * d2;
+ else
+ return err;
+
+ break;
+ }
+
+ case EXPR_NODETYPE_DIVIDE:
+ {
+ /* Division */
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+ if(!err)
+ {
+ if(d2 != 0.0)
+ *val = d1 / d2;
+ else
+ {
+#if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
+ return EXPR_ERROR_DIVBYZERO;
+#else
+ *val = 0.0;
+ return EXPR_ERROR_NOERROR;
+#endif
+ }
+ }
+ else
+ return err;
+
+ break;
+ }
+
+ case EXPR_NODETYPE_EXPONENT:
+ {
+ /* Exponent */
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = pow(d1, d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+ case EXPR_NODETYPE_NEGATE:
+ {
+ /* Negative value */
+ err = exprEvalNode(obj, nodes->data.oper.nodes, 0, &d1);
+
+ if(!err)
+ *val = -d1;
+ else
+ return err;
+
+ break;
+ }
+
+
+ case EXPR_NODETYPE_VALUE:
+ {
+ /* Directly access the value */
+ *val = nodes->data.value.value;
+ break;
+ }
+
+ case EXPR_NODETYPE_VARIABLE:
+ {
+ /* Directly access the variable or constant */
+ *val = *(nodes->data.variable.vaddr);
+ break;
+ }
+
+ case EXPR_NODETYPE_ASSIGN:
+ {
+ /* Evaluate assignment subnode */
+ err = exprEvalNode(obj, nodes->data.assign.node, 0, val);
+
+ if(!err)
+ {
+ /* Directly assign the variable */
+ *(nodes->data.assign.vaddr) = *val;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+ case EXPR_NODETYPE_FUNCTION:
+ {
+ /* Evaluate the function */
+ if(nodes->data.function.fptr == NULL)
+ {
+ /* No function pointer means we are not using
+ function solvers. See if the function has a
+ type to solve directly. */
+ switch(nodes->data.function.type)
+ {
+ /* This is to keep the file from being too crowded.
+ See exprilfs.h for the definitions. */
+#include "exprilfs.h"
+
+
+ default:
+ {
+ return EXPR_ERROR_UNKNOWN;
+ }
+ }
+ }
+ else
+ {
+ /* Call the correct function */
+ return (*(nodes->data.function.fptr))(obj,
+ nodes->data.function.nodes, nodes->data.function.nodecount,
+ nodes->data.function.refs, nodes->data.function.refcount, val);
+ }
+
+ break;
+ }
+
+ default:
+ {
+ /* Unknown node type */
+ return EXPR_ERROR_UNKNOWN;
+ }
+ }
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+
+
Modified: freeswitch/trunk/src/mod/applications/mod_expr/expreval.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/expreval.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/expreval.h Tue Nov 13 15:23:26 2007
@@ -1,127 +1,127 @@
-/*
- File: expreval.h
- Auth: Brian Allen Vanderburg II
- Date: Thursday, April 24, 2003
- Desc: Main include file for ExprEval library
-
- This file is part of ExprEval.
-*/
-
-
-/* Include once */
-#ifndef __BAVII_EXPREVAL_H
-#define __BAVII_EXPREVAL_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Define type of data to use */
-typedef double EXPRTYPE;
-
-/* Defines for various things */
-
-/* Max id size */
-#define EXPR_MAXIDENTSIZE 255
-
-/* Error values */
-enum
- {
- EXPR_ERROR_UNKNOWN = -1, /* Unknown error */
- EXPR_ERROR_NOERROR = 0, /* No Error */
- EXPR_ERROR_MEMORY, /* Memory allocation failed */
- EXPR_ERROR_NULLPOINTER, /* Null pointer passed to function */
- EXPR_ERROR_NOTFOUND, /* Item not found in a list */
- EXPR_ERROR_UNMATCHEDCOMMENT, /* Unmatched comment tags */
- EXPR_ERROR_INVALIDCHAR, /* Invalid characters in expression */
- EXPR_ERROR_ALREADYEXISTS, /* An item already called create */
- EXPR_ERROR_ALREADYPARSEDBAD, /* Expression parsed already, but unsuccessfully. call free or clear */
- EXPR_ERROR_ALREADYPARSEDGOOD, /* Expression parsed already, successfully, call free or clear */
- EXPR_ERROR_EMPTYEXPR, /* Empty expression string passed to parse */
- EXPR_ERROR_UNMATCHEDPAREN, /* Unmatched parenthesis */
- EXPR_ERROR_SYNTAX, /* Syntax error in expression */
- EXPR_ERROR_MISSINGSEMICOLON, /* Missing semicolon at end of expression */
- EXPR_ERROR_BADIDENTIFIER, /* Identifier was to big or not formed right */
- EXPR_ERROR_NOSUCHFUNCTION, /* Function does not exist in function list */
- EXPR_ERROR_BADNUMBERARGUMENTS, /* Bad number of arguments in a function call */
- EXPR_ERROR_BADEXPR, /* This is a bad expression to evaluate. It has not been parsed or has unsuccessfully */
- EXPR_ERROR_UNABLETOASSIGN, /* Unable to do an assignment, maybe no variable list */
- EXPR_ERROR_DIVBYZERO, /* Attempted a division by zero */
- EXPR_ERROR_NOVARLIST, /* No variable list found but one is needed */
- EXPR_ERROR_BREAK, /* Expression was broken by break function */
- EXPR_ERROR_CONSTANTASSIGN, /* Assignment to a constant */
- EXPR_ERROR_REFCONSTANT, /* Constant used as a reference parameter */
- EXPR_ERROR_OUTOFRANGE, /* A bad value was passed to a function */
-
- EXPR_ERROR_USER /* Custom errors should be larger than this */
- };
-
-/* Macros */
-
-/* Forward declarations */
-typedef struct _exprNode exprNode;
-typedef struct _exprFuncList exprFuncList;
-typedef struct _exprValList exprValList;
-typedef struct _exprObj exprObj;
-
-/* Function types */
-typedef int (*exprFuncType)(exprObj *obj, exprNode *nodes, int nodecount, EXPRTYPE **refs, int refcount, EXPRTYPE *val);
-typedef int (*exprBreakFuncType)(exprObj *obj);
-
-
-
-/* Functions */
-
-/* Version information function */
-void exprGetVersion(int *major, int *minor);
-
-/* Functions for function lists */
-int exprFuncListCreate(exprFuncList **flist);
-int exprFuncListAdd(exprFuncList *flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax);
-int exprFuncListFree(exprFuncList *flist);
-int exprFuncListClear(exprFuncList *flist);
-int exprFuncListInit(exprFuncList *flist);
-
-/* Functions for value lists */
-int exprValListCreate(exprValList **vlist);
-int exprValListAdd(exprValList *vlist, char *name, EXPRTYPE val);
-int exprValListSet(exprValList *vlist, char *name, EXPRTYPE val);
-int exprValListGet(exprValList *vlist, char *name, EXPRTYPE *val);
-int exprValListAddAddress(exprValList *vlist, char *name, EXPRTYPE *addr);
-int exprValListGetAddress(exprValList *vlist, char *name, EXPRTYPE **addr);
-void *exprValListGetNext(exprValList *vlist, char **name, EXPRTYPE *value, EXPRTYPE** addr, void *cookie);
-int exprValListFree(exprValList *vlist);
-int exprValListClear(exprValList *vlist);
-int exprValListInit(exprValList *vlist);
-
-/* Functions for expression objects */
-int exprCreate(exprObj **obj, exprFuncList *flist, exprValList *vlist, exprValList *clist,
- exprBreakFuncType breaker, void *userdata);
-int exprFree(exprObj *obj);
-int exprClear(exprObj *obj);
-int exprParse(exprObj *obj, char *expr);
-int exprEval(exprObj *obj, EXPRTYPE *val);
-int exprEvalNode(exprObj *obj, exprNode *nodes, int curnode, EXPRTYPE *val);
-exprFuncList *exprGetFuncList(exprObj *obj);
-exprValList *exprGetVarList(exprObj *obj);
-exprValList *exprGetConstList(exprObj *obj);
-exprBreakFuncType exprGetBreakFunc(exprObj *obj);
-int exprGetBreakResult(exprObj *obj);
-void* exprGetUserData(exprObj *obj);
-void exprSetUserData(exprObj *obj, void *userdata);
-void exprSetBreakCount(exprObj *obj, int count);
-void exprGetErrorPosition(exprObj *obj, int *start, int *end);
-
-/* Other useful routines */
-int exprValidIdent(char *name);
-
-/* Name mangling */
-#ifdef __cplusplus
-}
-#endif
-
-
-
-#endif /* __BAVII_EXPREVAL_H */
+/*
+ File: expreval.h
+ Auth: Brian Allen Vanderburg II
+ Date: Thursday, April 24, 2003
+ Desc: Main include file for ExprEval library
+
+ This file is part of ExprEval.
+*/
+
+
+/* Include once */
+#ifndef __BAVII_EXPREVAL_H
+#define __BAVII_EXPREVAL_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Define type of data to use */
+typedef double EXPRTYPE;
+
+/* Defines for various things */
+
+/* Max id size */
+#define EXPR_MAXIDENTSIZE 255
+
+/* Error values */
+enum
+ {
+ EXPR_ERROR_UNKNOWN = -1, /* Unknown error */
+ EXPR_ERROR_NOERROR = 0, /* No Error */
+ EXPR_ERROR_MEMORY, /* Memory allocation failed */
+ EXPR_ERROR_NULLPOINTER, /* Null pointer passed to function */
+ EXPR_ERROR_NOTFOUND, /* Item not found in a list */
+ EXPR_ERROR_UNMATCHEDCOMMENT, /* Unmatched comment tags */
+ EXPR_ERROR_INVALIDCHAR, /* Invalid characters in expression */
+ EXPR_ERROR_ALREADYEXISTS, /* An item already called create */
+ EXPR_ERROR_ALREADYPARSEDBAD, /* Expression parsed already, but unsuccessfully. call free or clear */
+ EXPR_ERROR_ALREADYPARSEDGOOD, /* Expression parsed already, successfully, call free or clear */
+ EXPR_ERROR_EMPTYEXPR, /* Empty expression string passed to parse */
+ EXPR_ERROR_UNMATCHEDPAREN, /* Unmatched parenthesis */
+ EXPR_ERROR_SYNTAX, /* Syntax error in expression */
+ EXPR_ERROR_MISSINGSEMICOLON, /* Missing semicolon at end of expression */
+ EXPR_ERROR_BADIDENTIFIER, /* Identifier was to big or not formed right */
+ EXPR_ERROR_NOSUCHFUNCTION, /* Function does not exist in function list */
+ EXPR_ERROR_BADNUMBERARGUMENTS, /* Bad number of arguments in a function call */
+ EXPR_ERROR_BADEXPR, /* This is a bad expression to evaluate. It has not been parsed or has unsuccessfully */
+ EXPR_ERROR_UNABLETOASSIGN, /* Unable to do an assignment, maybe no variable list */
+ EXPR_ERROR_DIVBYZERO, /* Attempted a division by zero */
+ EXPR_ERROR_NOVARLIST, /* No variable list found but one is needed */
+ EXPR_ERROR_BREAK, /* Expression was broken by break function */
+ EXPR_ERROR_CONSTANTASSIGN, /* Assignment to a constant */
+ EXPR_ERROR_REFCONSTANT, /* Constant used as a reference parameter */
+ EXPR_ERROR_OUTOFRANGE, /* A bad value was passed to a function */
+
+ EXPR_ERROR_USER /* Custom errors should be larger than this */
+ };
+
+/* Macros */
+
+/* Forward declarations */
+typedef struct _exprNode exprNode;
+typedef struct _exprFuncList exprFuncList;
+typedef struct _exprValList exprValList;
+typedef struct _exprObj exprObj;
+
+/* Function types */
+typedef int (*exprFuncType)(exprObj *obj, exprNode *nodes, int nodecount, EXPRTYPE **refs, int refcount, EXPRTYPE *val);
+typedef int (*exprBreakFuncType)(exprObj *obj);
+
+
+
+/* Functions */
+
+/* Version information function */
+void exprGetVersion(int *major, int *minor);
+
+/* Functions for function lists */
+int exprFuncListCreate(exprFuncList **flist);
+int exprFuncListAdd(exprFuncList *flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax);
+int exprFuncListFree(exprFuncList *flist);
+int exprFuncListClear(exprFuncList *flist);
+int exprFuncListInit(exprFuncList *flist);
+
+/* Functions for value lists */
+int exprValListCreate(exprValList **vlist);
+int exprValListAdd(exprValList *vlist, char *name, EXPRTYPE val);
+int exprValListSet(exprValList *vlist, char *name, EXPRTYPE val);
+int exprValListGet(exprValList *vlist, char *name, EXPRTYPE *val);
+int exprValListAddAddress(exprValList *vlist, char *name, EXPRTYPE *addr);
+int exprValListGetAddress(exprValList *vlist, char *name, EXPRTYPE **addr);
+void *exprValListGetNext(exprValList *vlist, char **name, EXPRTYPE *value, EXPRTYPE** addr, void *cookie);
+int exprValListFree(exprValList *vlist);
+int exprValListClear(exprValList *vlist);
+int exprValListInit(exprValList *vlist);
+
+/* Functions for expression objects */
+int exprCreate(exprObj **obj, exprFuncList *flist, exprValList *vlist, exprValList *clist,
+ exprBreakFuncType breaker, void *userdata);
+int exprFree(exprObj *obj);
+int exprClear(exprObj *obj);
+int exprParse(exprObj *obj, char *expr);
+int exprEval(exprObj *obj, EXPRTYPE *val);
+int exprEvalNode(exprObj *obj, exprNode *nodes, int curnode, EXPRTYPE *val);
+exprFuncList *exprGetFuncList(exprObj *obj);
+exprValList *exprGetVarList(exprObj *obj);
+exprValList *exprGetConstList(exprObj *obj);
+exprBreakFuncType exprGetBreakFunc(exprObj *obj);
+int exprGetBreakResult(exprObj *obj);
+void* exprGetUserData(exprObj *obj);
+void exprSetUserData(exprObj *obj, void *userdata);
+void exprSetBreakCount(exprObj *obj, int count);
+void exprGetErrorPosition(exprObj *obj, int *start, int *end);
+
+/* Other useful routines */
+int exprValidIdent(char *name);
+
+/* Name mangling */
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* __BAVII_EXPREVAL_H */
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprfunc.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprfunc.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprfunc.c Tue Nov 13 15:23:26 2007
@@ -1,329 +1,329 @@
-/*
- File: exprfunc.c
- Auth: Brian Allen Vanderburg II
- Date: Thursday, April 24, 2003
- Desc: Expression function list routines
-
- This file is part of ExprEval.
-*/
-
-
-
-/* Includes */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-#include "exprmem.h"
-
-/* Internal functions */
-static exprFunc *exprCreateFunc(char *name, exprFuncType ptr, int type, int min, int max, int refmin, int refmax);
-static void exprFuncListFreeData(exprFunc *func);
-
-
-/* This function creates the function list, */
-int exprFuncListCreate(exprFuncList **flist)
- {
- exprFuncList *tmp;
-
- if(flist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- *flist = NULL; /* Set to NULL initially */
-
- tmp = exprAllocMem(sizeof(exprFuncList));
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY; /* Could not allocate memory */
-
- /* Update pointer */
- *flist = tmp;
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Add a function to the list */
-int exprFuncListAdd(exprFuncList *flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax)
- {
- exprFunc *tmp;
- exprFunc *cur;
- int result;
-
- if(flist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Make sure the name is valid */
- if(!exprValidIdent(name))
- return EXPR_ERROR_BADIDENTIFIER;
-
- /* Fix values only if none are negative (negative values mean no limit) */
-
- /* if both are neg, no min or max number of args */
- /* if min is neg, max pos, no min number of args but a maximum */
- /* if min is pos, max neg, there is a min number of args, but no max */
- /* if both pos, then a min and max limit. We swap to make sure it works
- right. I.E. Min of 3 and max of 2 would make function unusable */
- if(min >= 0 && max >= 0)
- {
- if(min > max)
- {
- result = min;
- min = max;
- max = result;
- }
- }
-
- if(refmin >= 0 && refmax >= 0)
- {
- if(refmin > refmax)
- {
- result = refmin;
- refmin = max;
- refmax = result;
- }
- }
-
- if(flist->head == NULL)
- {
- /* Create the node right here */
- tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- flist->head = tmp;
- return EXPR_ERROR_NOERROR;
- }
-
- /* See if it already exists */
- cur = flist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->fname);
-
- if(result == 0)
- return EXPR_ERROR_ALREADYEXISTS;
-
- cur = cur->next;
- }
-
- /* It did not exist, so add it at the head */
- tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- tmp->next = flist->head;
- flist->head = tmp;
- return EXPR_ERROR_NOERROR;
- }
-
-/* Add a function node type to the list
- This works pretty much the same way, except the function
- pointer is NULL and the node type specifies the function
- to do. exprEvalNode handles this, instead of calling
- a function solver. */
-int exprFuncListAddType(exprFuncList *flist, char *name, int type, int min, int max, int refmin, int refmax)
- {
- exprFunc *tmp;
- exprFunc *cur;
- int result;
-
- if(flist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Make sure the name is valid */
- if(!exprValidIdent(name))
- return EXPR_ERROR_BADIDENTIFIER;
-
- /* Fix values only if none are negative (negative values mean no limit) */
-
- /* if both are neg, no min or max number of args */
- /* if min is neg, max pos, no min number of args but a maximum */
- /* if min is pos, max neg, there is a min number of args, but no max */
- /* if both pos, then a min and max limit. We swap to make sure it works
- right. I.E. Min of 3 and max of 2 would make function unusable */
- if(min >= 0 && max >= 0)
- {
- if(min > max)
- {
- result = min;
- min = max;
- max = result;
- }
- }
-
- if(refmin >= 0 && refmax >= 0)
- {
- if(refmin > refmax)
- {
- result = refmin;
- refmin = max;
- refmax = result;
- }
- }
-
- if(flist->head == NULL)
- {
- /* Create the node right here */
- tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- flist->head = tmp;
- return EXPR_ERROR_NOERROR;
- }
-
- /* See if it already exists */
- cur = flist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->fname);
-
- if(result == 0)
- return EXPR_ERROR_ALREADYEXISTS;
-
- cur = cur->next;
- }
-
- /* It did not exist, so add it at the head */
- tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- tmp->next = flist->head;
- flist->head = tmp;
- return EXPR_ERROR_NOERROR;
- }
-
-
-/* Get the function from a list along with it's min an max data */
-int exprFuncListGet(exprFuncList *flist, char *name, exprFuncType *ptr, int *type, int *min, int *max, int *refmin, int *refmax)
- {
- exprFunc *cur;
- int result;
-
- if(flist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- if(name == NULL || name[0] == '\0')
- return EXPR_ERROR_NOTFOUND;
-
- /* Search for the item */
- cur = flist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->fname);
-
- if(result == 0)
- {
- /* We found it. */
- *ptr = cur->fptr;
- *min = cur->min;
- *max = cur->max;
- *refmin = cur->refmin;
- *refmax = cur->refmax;
- *type = cur->type;
-
- /* return now */
- return EXPR_ERROR_NOERROR;
- }
-
- cur = cur->next;
- }
-
- /* If we got here, we did not find the item in the list */
- return EXPR_ERROR_NOTFOUND;
- }
-
-/* This routine will free the function list */
-int exprFuncListFree(exprFuncList *flist)
- {
- /* Make sure it exists, if not it is not error */
- if(flist == NULL)
- return EXPR_ERROR_NOERROR;
-
- /* Free the nodes */
- exprFuncListFreeData(flist->head);
-
- /* Free the container */
- exprFreeMem(flist);
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* This routine will clear the function list */
-int exprFuncListClear(exprFuncList *flist)
- {
- if(flist == NULL)
- return EXPR_ERROR_NOERROR;
-
- /* Free the nodes only */
- if(flist->head)
- {
- exprFuncListFreeData(flist->head);
-
- flist->head = NULL;
- }
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* This routine will free any child nodes, and then free itself */
-void exprFuncListFreeData(exprFunc *func)
- {
- exprFunc *next;
-
- while(func)
- {
- /* Remember the next item */
- next = func->next;
-
- /* Free name */
- exprFreeMem(func->fname);
-
- /* Free ourself */
- exprFreeMem(func);
-
- func = next;
- }
- }
-
-/* This routine will create the function object */
-exprFunc *exprCreateFunc(char *name, exprFuncType ptr, int type, int min, int max, int refmin, int refmax)
- {
- exprFunc *tmp;
- char *vtmp;
-
- /* We already checked the name in exprFuncListAdd */
-
- /* Create it */
- tmp = exprAllocMem(sizeof(exprFunc));
- if(tmp == NULL)
- return NULL;
-
- /* Allocate space for the name */
- vtmp = exprAllocMem(strlen(name) + 1);
-
- if(vtmp == NULL)
- {
- exprFreeMem(tmp);
- return NULL;
- }
-
- /* Copy the data over */
- strcpy(vtmp, name);
- tmp->fname = vtmp;
- tmp->fptr = ptr;
- tmp->min = min;
- tmp->max = max;
- tmp->refmin = refmin;
- tmp->refmax = refmax;
- tmp->type = type;
-
- return tmp;
- }
+/*
+ File: exprfunc.c
+ Auth: Brian Allen Vanderburg II
+ Date: Thursday, April 24, 2003
+ Desc: Expression function list routines
+
+ This file is part of ExprEval.
+*/
+
+
+
+/* Includes */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+#include "exprmem.h"
+
+/* Internal functions */
+static exprFunc *exprCreateFunc(char *name, exprFuncType ptr, int type, int min, int max, int refmin, int refmax);
+static void exprFuncListFreeData(exprFunc *func);
+
+
+/* This function creates the function list, */
+int exprFuncListCreate(exprFuncList **flist)
+ {
+ exprFuncList *tmp;
+
+ if(flist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ *flist = NULL; /* Set to NULL initially */
+
+ tmp = exprAllocMem(sizeof(exprFuncList));
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY; /* Could not allocate memory */
+
+ /* Update pointer */
+ *flist = tmp;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Add a function to the list */
+int exprFuncListAdd(exprFuncList *flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax)
+ {
+ exprFunc *tmp;
+ exprFunc *cur;
+ int result;
+
+ if(flist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Make sure the name is valid */
+ if(!exprValidIdent(name))
+ return EXPR_ERROR_BADIDENTIFIER;
+
+ /* Fix values only if none are negative (negative values mean no limit) */
+
+ /* if both are neg, no min or max number of args */
+ /* if min is neg, max pos, no min number of args but a maximum */
+ /* if min is pos, max neg, there is a min number of args, but no max */
+ /* if both pos, then a min and max limit. We swap to make sure it works
+ right. I.E. Min of 3 and max of 2 would make function unusable */
+ if(min >= 0 && max >= 0)
+ {
+ if(min > max)
+ {
+ result = min;
+ min = max;
+ max = result;
+ }
+ }
+
+ if(refmin >= 0 && refmax >= 0)
+ {
+ if(refmin > refmax)
+ {
+ result = refmin;
+ refmin = max;
+ refmax = result;
+ }
+ }
+
+ if(flist->head == NULL)
+ {
+ /* Create the node right here */
+ tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ flist->head = tmp;
+ return EXPR_ERROR_NOERROR;
+ }
+
+ /* See if it already exists */
+ cur = flist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->fname);
+
+ if(result == 0)
+ return EXPR_ERROR_ALREADYEXISTS;
+
+ cur = cur->next;
+ }
+
+ /* It did not exist, so add it at the head */
+ tmp = exprCreateFunc(name, ptr, EXPR_NODETYPE_FUNCTION, min, max, refmin, refmax);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ tmp->next = flist->head;
+ flist->head = tmp;
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Add a function node type to the list
+ This works pretty much the same way, except the function
+ pointer is NULL and the node type specifies the function
+ to do. exprEvalNode handles this, instead of calling
+ a function solver. */
+int exprFuncListAddType(exprFuncList *flist, char *name, int type, int min, int max, int refmin, int refmax)
+ {
+ exprFunc *tmp;
+ exprFunc *cur;
+ int result;
+
+ if(flist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Make sure the name is valid */
+ if(!exprValidIdent(name))
+ return EXPR_ERROR_BADIDENTIFIER;
+
+ /* Fix values only if none are negative (negative values mean no limit) */
+
+ /* if both are neg, no min or max number of args */
+ /* if min is neg, max pos, no min number of args but a maximum */
+ /* if min is pos, max neg, there is a min number of args, but no max */
+ /* if both pos, then a min and max limit. We swap to make sure it works
+ right. I.E. Min of 3 and max of 2 would make function unusable */
+ if(min >= 0 && max >= 0)
+ {
+ if(min > max)
+ {
+ result = min;
+ min = max;
+ max = result;
+ }
+ }
+
+ if(refmin >= 0 && refmax >= 0)
+ {
+ if(refmin > refmax)
+ {
+ result = refmin;
+ refmin = max;
+ refmax = result;
+ }
+ }
+
+ if(flist->head == NULL)
+ {
+ /* Create the node right here */
+ tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ flist->head = tmp;
+ return EXPR_ERROR_NOERROR;
+ }
+
+ /* See if it already exists */
+ cur = flist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->fname);
+
+ if(result == 0)
+ return EXPR_ERROR_ALREADYEXISTS;
+
+ cur = cur->next;
+ }
+
+ /* It did not exist, so add it at the head */
+ tmp = exprCreateFunc(name, NULL, type, min, max, refmin, refmax);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ tmp->next = flist->head;
+ flist->head = tmp;
+ return EXPR_ERROR_NOERROR;
+ }
+
+
+/* Get the function from a list along with it's min an max data */
+int exprFuncListGet(exprFuncList *flist, char *name, exprFuncType *ptr, int *type, int *min, int *max, int *refmin, int *refmax)
+ {
+ exprFunc *cur;
+ int result;
+
+ if(flist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ if(name == NULL || name[0] == '\0')
+ return EXPR_ERROR_NOTFOUND;
+
+ /* Search for the item */
+ cur = flist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->fname);
+
+ if(result == 0)
+ {
+ /* We found it. */
+ *ptr = cur->fptr;
+ *min = cur->min;
+ *max = cur->max;
+ *refmin = cur->refmin;
+ *refmax = cur->refmax;
+ *type = cur->type;
+
+ /* return now */
+ return EXPR_ERROR_NOERROR;
+ }
+
+ cur = cur->next;
+ }
+
+ /* If we got here, we did not find the item in the list */
+ return EXPR_ERROR_NOTFOUND;
+ }
+
+/* This routine will free the function list */
+int exprFuncListFree(exprFuncList *flist)
+ {
+ /* Make sure it exists, if not it is not error */
+ if(flist == NULL)
+ return EXPR_ERROR_NOERROR;
+
+ /* Free the nodes */
+ exprFuncListFreeData(flist->head);
+
+ /* Free the container */
+ exprFreeMem(flist);
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* This routine will clear the function list */
+int exprFuncListClear(exprFuncList *flist)
+ {
+ if(flist == NULL)
+ return EXPR_ERROR_NOERROR;
+
+ /* Free the nodes only */
+ if(flist->head)
+ {
+ exprFuncListFreeData(flist->head);
+
+ flist->head = NULL;
+ }
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* This routine will free any child nodes, and then free itself */
+void exprFuncListFreeData(exprFunc *func)
+ {
+ exprFunc *next;
+
+ while(func)
+ {
+ /* Remember the next item */
+ next = func->next;
+
+ /* Free name */
+ exprFreeMem(func->fname);
+
+ /* Free ourself */
+ exprFreeMem(func);
+
+ func = next;
+ }
+ }
+
+/* This routine will create the function object */
+exprFunc *exprCreateFunc(char *name, exprFuncType ptr, int type, int min, int max, int refmin, int refmax)
+ {
+ exprFunc *tmp;
+ char *vtmp;
+
+ /* We already checked the name in exprFuncListAdd */
+
+ /* Create it */
+ tmp = exprAllocMem(sizeof(exprFunc));
+ if(tmp == NULL)
+ return NULL;
+
+ /* Allocate space for the name */
+ vtmp = exprAllocMem(strlen(name) + 1);
+
+ if(vtmp == NULL)
+ {
+ exprFreeMem(tmp);
+ return NULL;
+ }
+
+ /* Copy the data over */
+ strcpy(vtmp, name);
+ tmp->fname = vtmp;
+ tmp->fptr = ptr;
+ tmp->min = min;
+ tmp->max = max;
+ tmp->refmin = refmin;
+ tmp->refmax = refmax;
+ tmp->type = type;
+
+ return tmp;
+ }
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h Tue Nov 13 15:23:26 2007
@@ -1,1064 +1,1064 @@
-/*
- File: exprilfs.h
- Auth: Brian Allen Vanderburg II
- Date: Tuesday, February 28, 2006
- Desc: Inline Function Solvers for exprEvalNode
-
- This file is part of ExprEval.
-*/
-
-/*
- This is here to help prevent expreval.c from getting
- too crowded.
-
- Provided variables:
- obj: expression object point
- nodes: function node with paramters
- d1, d2: variables
- err: error
- val: value pointer for resuld
- pos: integer
-
- Also EXPR_RESET_ERR() and EXPR_CHECK_ERR()
-
- The chunks below are included inside a statement that looks like this:
-
- switch(nodes->data.function.type)
- {
- #include "exprilfs.h"
-
- default:
- {
- return EXPR_ERROR_UNKNOWN;
- }
- }
-*/
-
-
-
-/* abs */
-case EXPR_NODEFUNC_ABS:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- if(d1 >= 0)
- *val = d1;
- else
- *val = -d1;
- }
- else
- return err;
-
- break;
- }
-
-/* mod */
-case EXPR_NODEFUNC_MOD:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = fmod(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* ipart */
-case EXPR_NODEFUNC_IPART:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- modf(d1, val);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* fpart */
-case EXPR_NODEFUNC_FPART:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = modf(d1, &d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* min */
-case EXPR_NODEFUNC_MIN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- for(pos = 1; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
- if(!err)
- {
- if(d2 < d1)
- d1 = d2;
- }
- else
- return err;
- }
- }
- else
- return err;
-
- *val = d1;
-
- break;
- }
-
-/* max */
-case EXPR_NODEFUNC_MAX:
- {
- int pos;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- for(pos = 1; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
- if(!err)
- {
- if(d2 > d1)
- d1 = d2;
- }
- else
- return err;
- }
- }
- else
- return err;
-
- *val = d1;
-
- break;
- }
-
-/* pow */
-case EXPR_NODEFUNC_POW:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = pow(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* sqrt */
-case EXPR_NODEFUNC_SQRT:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sqrt(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* sin */
-case EXPR_NODEFUNC_SIN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sin(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* sinh */
-case EXPR_NODEFUNC_SINH:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sinh(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* asin */
-case EXPR_NODEFUNC_ASIN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = asin(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* cos */
-case EXPR_NODEFUNC_COS:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = cos(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* cosh */
-case EXPR_NODEFUNC_COSH:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = cosh(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* acos */
-case EXPR_NODEFUNC_ACOS:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = acos(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* tan */
-case EXPR_NODEFUNC_TAN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = tan(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* tanh */
-case EXPR_NODEFUNC_TANH:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = tanh(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* atan */
-case EXPR_NODEFUNC_ATAN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = atan(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* atan2 */
-case EXPR_NODEFUNC_ATAN2:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = atan2(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* log */
-case EXPR_NODEFUNC_LOG:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = log10(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* pow10 */
-case EXPR_NODEFUNC_POW10:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = pow(10.0, d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* ln */
-case EXPR_NODEFUNC_LN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = log(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* exp */
-case EXPR_NODEFUNC_EXP:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = exp(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-case EXPR_NODEFUNC_LOGN:
- {
- EXPRTYPE l1, l2;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- l1 = log(d1);
- EXPR_CHECK_ERR();
- l2 = log(d2);
- EXPR_CHECK_ERR();
-
-
- if(l2 == 0.0)
- {
-#if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
- return EXPR_ERROR_OUTOFRANGE;
-#else
- *val = 0.0;
- return EXPR_ERROR_NOERROR;
-#endif
- }
-
- *val = l1 / l2;
- }
- else
- return err;
-
- break;
- }
-
-/* ceil */
-case EXPR_NODEFUNC_CEIL:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- *val = ceil(d1);
- }
- else
- return err;
-
- break;
- }
-
-/* floor */
-case EXPR_NODEFUNC_FLOOR:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- *val = floor(d1);
- }
- else
- return err;
-
- break;
- }
-
-/* rand */
-case EXPR_NODEFUNC_RAND:
- {
- long a;
-
- /* Perform random routine directly */
- a = ((long)(*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
- *(nodes->data.function.refs[0]) = (EXPRTYPE)a;
-
- *val = (EXPRTYPE)((a >> 16) & 0x7FFF) / (EXPRTYPE)(32768);
- break;
- }
-
-/* random */
-case EXPR_NODEFUNC_RANDOM:
- {
- EXPRTYPE diff, rval;
- long a;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- diff = d2 - d1;
-
- /* Perform random routine directly */
- a = ((long)(*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
- *(nodes->data.function.refs[0]) = (EXPRTYPE)a;
-
- rval = (EXPRTYPE)((a >> 16) & 0x7FFF) / (EXPRTYPE)(32767);
-
- *val = (rval * diff) + d1;
- }
- else
- return err;
-
- break;
- }
-
-/* randomize */
-case EXPR_NODEFUNC_RANDOMIZE:
- {
- static int curcall = 0;
-
- curcall++;
-
- *(nodes->data.function.refs[0]) = (EXPRTYPE)((clock() + 1024 + curcall) * time(NULL));
-
- break;
- }
-
-/* deg */
-case EXPR_NODEFUNC_DEG:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- *val = (180.0 * d1) / M_PI;
- }
- else
- return err;
-
- break;
- }
-
-/* rad */
-case EXPR_NODEFUNC_RAD:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- *val = (M_PI * d1) / 180.0;
- }
- else
- return err;
-
- break;
- }
-
-/* recttopolr */
-case EXPR_NODEFUNC_RECTTOPOLR:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sqrt((d1 * d1) + (d2 * d2));
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* recttopola */
-case EXPR_NODEFUNC_RECTTOPOLA:
- {
- EXPRTYPE tmp;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- tmp = atan2(d2, d1);
- EXPR_CHECK_ERR();
-
- if(tmp < 0.0)
- *val = tmp = (2.0 * M_PI);
- else
- *val = tmp;
- }
- else
- return err;
-
- break;
- }
-
-/* poltorectx */
-case EXPR_NODEFUNC_POLTORECTX:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = d1 * cos(d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* poltorecty */
-case EXPR_NODEFUNC_POLTORECTY:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = d1 * sin(d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
-
- break;
- }
-
-/* if */
-case EXPR_NODEFUNC_IF:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- if(d1 != 0.0)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
- if(err)
- return err;
- }
- else
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
- if(err)
- return err;
- }
- }
- else
- return err;
-
- break;
- }
-
-/* select */
-case EXPR_NODEFUNC_SELECT:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- if(d1 < 0.0)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
- if(err)
- return err;
- }
- else if(d1 == 0.0)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
- if(err)
- return err;
- }
- else
- {
- if(nodes->data.function.nodecount == 3)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
- if(err)
- return err;
- }
- else
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 3, val);
- if(err)
- return err;
- }
- }
- }
- else
- return err;
-
- break;
- }
-
-/* equal */
-case EXPR_NODEFUNC_EQUAL:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- *val = (d1 == d2) ? 1.0 : 0.0;
- }
- else
- return err;
-
- break;
- }
-
-/* above */
-case EXPR_NODEFUNC_ABOVE:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- *val = (d1 > d2) ? 1.0 : 0.0;
- }
- else
- return err;
-
- break;
- }
-
-/* below */
-case EXPR_NODEFUNC_BELOW:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- *val = (d1 < d2) ? 1.0 : 0.0;
- }
- else
- return err;
-
- break;
- }
-
-/* avg */
-case EXPR_NODEFUNC_AVG:
- {
- d2 = 0.0;
-
- for(pos = 0; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d1);
- if(!err)
- {
- d2 += d1;
- }
- else
- return err;
- }
-
- *val = d2 / (EXPRTYPE)(nodes->data.function.nodecount);
-
- break;
- }
-
-/* clip */
-case EXPR_NODEFUNC_CLIP:
- {
- EXPRTYPE v;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- if(v < d1)
- *val = d1;
- else if(v > d2)
- *val = d2;
- else
- *val = v;
- }
- else
- return err;
-
- break;
- }
-
-/* clamp */
-case EXPR_NODEFUNC_CLAMP:
- {
- EXPRTYPE v, tmp;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- tmp = fmod(v - d1, d2 - d1);
- EXPR_CHECK_ERR();
-
- if(tmp < 0.0)
- *val = tmp * d2;
- else
- *val = tmp + d1;
- }
- else
- return err;
-
- break;
- }
-
-/* pntchange */
-case EXPR_NODEFUNC_PNTCHANGE:
- {
- EXPRTYPE n1, n2, pnt;
- EXPRTYPE odiff, ndiff, perc;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, &n1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 3, &n2);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 4, &pnt);
-
- if(!err)
- {
- odiff = d2 - d1;
- ndiff = n2 - n1;
-
- if(odiff == 0.0)
- {
- *val = d1;
- return EXPR_ERROR_NOERROR;
- }
-
- perc = (pnt - d1) / odiff;
-
- *val = n1 + (perc * ndiff);
- }
- else
- return err;
-
- break;
- }
-
-/* poly */
-case EXPR_NODEFUNC_POLY:
- {
- EXPRTYPE total, curpow;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- curpow = (EXPRTYPE)(nodes->data.function.nodecount) - 2.0;
- total = 0.0;
-
- for(pos = 1; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
- if(err)
- return err;
-
- EXPR_RESET_ERR();
- total = total + (d2 * pow(d1, curpow));
- EXPR_CHECK_ERR();
-
- curpow = curpow - 1.0;
- }
- }
- else
- return err;
-
- *val = total;
- break;
- }
-
-/* and */
-case EXPR_NODEFUNC_AND:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- if(d1 == 0.0 || d2 == 0.0)
- *val = 0.0;
- else
- *val = 1.0;
- }
- else
- return err;
-
- break;
- }
-
-/* or */
-case EXPR_NODEFUNC_OR:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- if(d1 != 0.0 || d2 != 0.0)
- *val = 1.0;
- else
- *val = 0.0;
- }
- else
- return err;
-
- break;
- }
-
-/* not */
-case EXPR_NODEFUNC_NOT:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- if(d1 != 0.0)
- *val = 0.0;
- else
- *val = 1.0;
- }
- else
- return err;
-
- break;
- }
-
-/* for */
-case EXPR_NODEFUNC_FOR:
- {
- int pos;
- EXPRTYPE test;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
-
- if(!err)
- {
- while(test != 0.0)
- {
- for(pos = 3; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, val);
- if(err)
- return err;
- }
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, &d1);
- if(err)
- return err;
-
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
- if(err)
- return err;
- }
- }
- else
- return err;
-
- break;
- }
-
-/* many */
-case EXPR_NODEFUNC_MANY:
- {
- for(pos = 0; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, val);
- if(err)
- return err;
- }
-
- break;
- }
-
+/*
+ File: exprilfs.h
+ Auth: Brian Allen Vanderburg II
+ Date: Tuesday, February 28, 2006
+ Desc: Inline Function Solvers for exprEvalNode
+
+ This file is part of ExprEval.
+*/
+
+/*
+ This is here to help prevent expreval.c from getting
+ too crowded.
+
+ Provided variables:
+ obj: expression object point
+ nodes: function node with paramters
+ d1, d2: variables
+ err: error
+ val: value pointer for resuld
+ pos: integer
+
+ Also EXPR_RESET_ERR() and EXPR_CHECK_ERR()
+
+ The chunks below are included inside a statement that looks like this:
+
+ switch(nodes->data.function.type)
+ {
+ #include "exprilfs.h"
+
+ default:
+ {
+ return EXPR_ERROR_UNKNOWN;
+ }
+ }
+*/
+
+
+
+/* abs */
+case EXPR_NODEFUNC_ABS:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ if(d1 >= 0)
+ *val = d1;
+ else
+ *val = -d1;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* mod */
+case EXPR_NODEFUNC_MOD:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = fmod(d1, d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* ipart */
+case EXPR_NODEFUNC_IPART:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ modf(d1, val);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* fpart */
+case EXPR_NODEFUNC_FPART:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = modf(d1, &d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* min */
+case EXPR_NODEFUNC_MIN:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ for(pos = 1; pos < nodes->data.function.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
+ if(!err)
+ {
+ if(d2 < d1)
+ d1 = d2;
+ }
+ else
+ return err;
+ }
+ }
+ else
+ return err;
+
+ *val = d1;
+
+ break;
+ }
+
+/* max */
+case EXPR_NODEFUNC_MAX:
+ {
+ int pos;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ for(pos = 1; pos < nodes->data.function.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
+ if(!err)
+ {
+ if(d2 > d1)
+ d1 = d2;
+ }
+ else
+ return err;
+ }
+ }
+ else
+ return err;
+
+ *val = d1;
+
+ break;
+ }
+
+/* pow */
+case EXPR_NODEFUNC_POW:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = pow(d1, d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* sqrt */
+case EXPR_NODEFUNC_SQRT:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = sqrt(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* sin */
+case EXPR_NODEFUNC_SIN:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = sin(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* sinh */
+case EXPR_NODEFUNC_SINH:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = sinh(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* asin */
+case EXPR_NODEFUNC_ASIN:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = asin(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* cos */
+case EXPR_NODEFUNC_COS:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = cos(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* cosh */
+case EXPR_NODEFUNC_COSH:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = cosh(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* acos */
+case EXPR_NODEFUNC_ACOS:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = acos(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* tan */
+case EXPR_NODEFUNC_TAN:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = tan(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* tanh */
+case EXPR_NODEFUNC_TANH:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = tanh(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* atan */
+case EXPR_NODEFUNC_ATAN:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = atan(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* atan2 */
+case EXPR_NODEFUNC_ATAN2:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = atan2(d1, d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* log */
+case EXPR_NODEFUNC_LOG:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = log10(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* pow10 */
+case EXPR_NODEFUNC_POW10:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = pow(10.0, d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* ln */
+case EXPR_NODEFUNC_LN:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = log(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* exp */
+case EXPR_NODEFUNC_EXP:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = exp(d1);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+case EXPR_NODEFUNC_LOGN:
+ {
+ EXPRTYPE l1, l2;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ l1 = log(d1);
+ EXPR_CHECK_ERR();
+ l2 = log(d2);
+ EXPR_CHECK_ERR();
+
+
+ if(l2 == 0.0)
+ {
+#if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
+ return EXPR_ERROR_OUTOFRANGE;
+#else
+ *val = 0.0;
+ return EXPR_ERROR_NOERROR;
+#endif
+ }
+
+ *val = l1 / l2;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* ceil */
+case EXPR_NODEFUNC_CEIL:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ *val = ceil(d1);
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* floor */
+case EXPR_NODEFUNC_FLOOR:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ *val = floor(d1);
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* rand */
+case EXPR_NODEFUNC_RAND:
+ {
+ long a;
+
+ /* Perform random routine directly */
+ a = ((long)(*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
+ *(nodes->data.function.refs[0]) = (EXPRTYPE)a;
+
+ *val = (EXPRTYPE)((a >> 16) & 0x7FFF) / (EXPRTYPE)(32768);
+ break;
+ }
+
+/* random */
+case EXPR_NODEFUNC_RANDOM:
+ {
+ EXPRTYPE diff, rval;
+ long a;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ diff = d2 - d1;
+
+ /* Perform random routine directly */
+ a = ((long)(*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
+ *(nodes->data.function.refs[0]) = (EXPRTYPE)a;
+
+ rval = (EXPRTYPE)((a >> 16) & 0x7FFF) / (EXPRTYPE)(32767);
+
+ *val = (rval * diff) + d1;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* randomize */
+case EXPR_NODEFUNC_RANDOMIZE:
+ {
+ static int curcall = 0;
+
+ curcall++;
+
+ *(nodes->data.function.refs[0]) = (EXPRTYPE)((clock() + 1024 + curcall) * time(NULL));
+
+ break;
+ }
+
+/* deg */
+case EXPR_NODEFUNC_DEG:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ *val = (180.0 * d1) / M_PI;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* rad */
+case EXPR_NODEFUNC_RAD:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ *val = (M_PI * d1) / 180.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* recttopolr */
+case EXPR_NODEFUNC_RECTTOPOLR:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = sqrt((d1 * d1) + (d2 * d2));
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* recttopola */
+case EXPR_NODEFUNC_RECTTOPOLA:
+ {
+ EXPRTYPE tmp;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ tmp = atan2(d2, d1);
+ EXPR_CHECK_ERR();
+
+ if(tmp < 0.0)
+ *val = tmp = (2.0 * M_PI);
+ else
+ *val = tmp;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* poltorectx */
+case EXPR_NODEFUNC_POLTORECTX:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = d1 * cos(d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* poltorecty */
+case EXPR_NODEFUNC_POLTORECTY:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ *val = d1 * sin(d2);
+ EXPR_CHECK_ERR();
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* if */
+case EXPR_NODEFUNC_IF:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ if(d1 != 0.0)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
+ if(err)
+ return err;
+ }
+ else
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
+ if(err)
+ return err;
+ }
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* select */
+case EXPR_NODEFUNC_SELECT:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ if(d1 < 0.0)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
+ if(err)
+ return err;
+ }
+ else if(d1 == 0.0)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
+ if(err)
+ return err;
+ }
+ else
+ {
+ if(nodes->data.function.nodecount == 3)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
+ if(err)
+ return err;
+ }
+ else
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 3, val);
+ if(err)
+ return err;
+ }
+ }
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* equal */
+case EXPR_NODEFUNC_EQUAL:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ *val = (d1 == d2) ? 1.0 : 0.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* above */
+case EXPR_NODEFUNC_ABOVE:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ *val = (d1 > d2) ? 1.0 : 0.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* below */
+case EXPR_NODEFUNC_BELOW:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ *val = (d1 < d2) ? 1.0 : 0.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* avg */
+case EXPR_NODEFUNC_AVG:
+ {
+ d2 = 0.0;
+
+ for(pos = 0; pos < nodes->data.function.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d1);
+ if(!err)
+ {
+ d2 += d1;
+ }
+ else
+ return err;
+ }
+
+ *val = d2 / (EXPRTYPE)(nodes->data.function.nodecount);
+
+ break;
+ }
+
+/* clip */
+case EXPR_NODEFUNC_CLIP:
+ {
+ EXPRTYPE v;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ if(v < d1)
+ *val = d1;
+ else if(v > d2)
+ *val = d2;
+ else
+ *val = v;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* clamp */
+case EXPR_NODEFUNC_CLAMP:
+ {
+ EXPRTYPE v, tmp;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ EXPR_RESET_ERR();
+ tmp = fmod(v - d1, d2 - d1);
+ EXPR_CHECK_ERR();
+
+ if(tmp < 0.0)
+ *val = tmp * d2;
+ else
+ *val = tmp + d1;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* pntchange */
+case EXPR_NODEFUNC_PNTCHANGE:
+ {
+ EXPRTYPE n1, n2, pnt;
+ EXPRTYPE odiff, ndiff, perc;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 2, &n1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 3, &n2);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 4, &pnt);
+
+ if(!err)
+ {
+ odiff = d2 - d1;
+ ndiff = n2 - n1;
+
+ if(odiff == 0.0)
+ {
+ *val = d1;
+ return EXPR_ERROR_NOERROR;
+ }
+
+ perc = (pnt - d1) / odiff;
+
+ *val = n1 + (perc * ndiff);
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* poly */
+case EXPR_NODEFUNC_POLY:
+ {
+ EXPRTYPE total, curpow;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ curpow = (EXPRTYPE)(nodes->data.function.nodecount) - 2.0;
+ total = 0.0;
+
+ for(pos = 1; pos < nodes->data.function.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
+ if(err)
+ return err;
+
+ EXPR_RESET_ERR();
+ total = total + (d2 * pow(d1, curpow));
+ EXPR_CHECK_ERR();
+
+ curpow = curpow - 1.0;
+ }
+ }
+ else
+ return err;
+
+ *val = total;
+ break;
+ }
+
+/* and */
+case EXPR_NODEFUNC_AND:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ if(d1 == 0.0 || d2 == 0.0)
+ *val = 0.0;
+ else
+ *val = 1.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* or */
+case EXPR_NODEFUNC_OR:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+ if(!err)
+ {
+ if(d1 != 0.0 || d2 != 0.0)
+ *val = 1.0;
+ else
+ *val = 0.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* not */
+case EXPR_NODEFUNC_NOT:
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ {
+ if(d1 != 0.0)
+ *val = 0.0;
+ else
+ *val = 1.0;
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* for */
+case EXPR_NODEFUNC_FOR:
+ {
+ int pos;
+ EXPRTYPE test;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+ if(!err)
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
+
+ if(!err)
+ {
+ while(test != 0.0)
+ {
+ for(pos = 3; pos < nodes->data.function.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, pos, val);
+ if(err)
+ return err;
+ }
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 2, &d1);
+ if(err)
+ return err;
+
+ err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
+ if(err)
+ return err;
+ }
+ }
+ else
+ return err;
+
+ break;
+ }
+
+/* many */
+case EXPR_NODEFUNC_MANY:
+ {
+ for(pos = 0; pos < nodes->data.function.nodecount; pos++)
+ {
+ err = exprEvalNode(obj, nodes->data.function.nodes, pos, val);
+ if(err)
+ return err;
+ }
+
+ break;
+ }
+
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprincl.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprincl.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprincl.h Tue Nov 13 15:23:26 2007
@@ -1,112 +1,112 @@
-/*
- File: exprincl.h
- Auth: Brian Allen Vanderburg II
- Date: Thursday, April 24, 2003
- Desc: Includes, macros, etc needed by this library
-
- This file is part of ExprEval.
-*/
-
-#ifndef __BAVII_EXPRINCL_H
-#define __BAVII_EXPRINCL_H
-
-
-/* Includes and macros and whatnot for building the library */
-
-#ifdef _MSC_VER
-#if (_MSC_VER >= 1400) // VC8+
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-#ifndef _CRT_NONSTDC_NO_DEPRECATE
-#define _CRT_NONSTDC_NO_DEPRECATE
-#endif
-#endif // VC8+
-#endif
-
-/* Memory routines. memory.h for VC++, mem.h for BC++ */
-#ifdef __TURBOC__
-#include <mem.h>
-#else
-#include <memory.h>
-#endif
-
-/* Memory allocation */
-#include <malloc.h>
-
-/* String routines */
-#include <string.h>
-
-/* Character manipulation routines */
-#include <ctype.h>
-
-/* Standard routines */
-#include <stdlib.h>
-
-/* Math routines */
-#include <math.h>
-
-/* Time */
-#include <time.h>
-
-
-/* Math constants. VC++ does not seem to have these */
-#ifndef M_E
-#define M_E 2.7182818284590452354
-#endif
-
-#ifndef M_LOG2E
-#define M_LOG2E 1.4426950408889634074
-#endif
-
-#ifndef M_LOG10E
-#define M_LOG10E 0.43429448190325182765
-#endif
-
-#ifndef M_LN2
-#define M_LN2 0.69314718055994530942
-#endif
-
-#ifndef M_LN10
-#define M_LN10 2.30258509299404568402
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923
-#endif
-
-#ifndef M_PI_4
-#define M_PI_4 0.78539816339744830962
-#endif
-
-#ifndef M_1_PI
-#define M_1_PI 0.31830988618379067154
-#endif
-
-#ifndef M_2_PI
-#define M_2_PI 0.63661977236758134308
-#endif
-
-#ifndef M_1_SQRTPI
-#define M_1_SQRTPI 0.56418958354776
-#endif
-
-#ifndef M_2_SQRTPI
-#define M_2_SQRTPI 1.12837916709551257390
-#endif
-
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880
-#endif
-
-#ifndef M_1_SQRT2
-#define M_1_SQRT2 0.70710678118654752440
-#endif
-
-
-
-#endif /* __BAVII_EXPRINCL_H */
+/*
+ File: exprincl.h
+ Auth: Brian Allen Vanderburg II
+ Date: Thursday, April 24, 2003
+ Desc: Includes, macros, etc needed by this library
+
+ This file is part of ExprEval.
+*/
+
+#ifndef __BAVII_EXPRINCL_H
+#define __BAVII_EXPRINCL_H
+
+
+/* Includes and macros and whatnot for building the library */
+
+#ifdef _MSC_VER
+#if (_MSC_VER >= 1400) // VC8+
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE
+#endif
+#endif // VC8+
+#endif
+
+/* Memory routines. memory.h for VC++, mem.h for BC++ */
+#ifdef __TURBOC__
+#include <mem.h>
+#else
+#include <memory.h>
+#endif
+
+/* Memory allocation */
+#include <malloc.h>
+
+/* String routines */
+#include <string.h>
+
+/* Character manipulation routines */
+#include <ctype.h>
+
+/* Standard routines */
+#include <stdlib.h>
+
+/* Math routines */
+#include <math.h>
+
+/* Time */
+#include <time.h>
+
+
+/* Math constants. VC++ does not seem to have these */
+#ifndef M_E
+#define M_E 2.7182818284590452354
+#endif
+
+#ifndef M_LOG2E
+#define M_LOG2E 1.4426950408889634074
+#endif
+
+#ifndef M_LOG10E
+#define M_LOG10E 0.43429448190325182765
+#endif
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+
+#ifndef M_LN10
+#define M_LN10 2.30258509299404568402
+#endif
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifndef M_PI_2
+#define M_PI_2 1.57079632679489661923
+#endif
+
+#ifndef M_PI_4
+#define M_PI_4 0.78539816339744830962
+#endif
+
+#ifndef M_1_PI
+#define M_1_PI 0.31830988618379067154
+#endif
+
+#ifndef M_2_PI
+#define M_2_PI 0.63661977236758134308
+#endif
+
+#ifndef M_1_SQRTPI
+#define M_1_SQRTPI 0.56418958354776
+#endif
+
+#ifndef M_2_SQRTPI
+#define M_2_SQRTPI 1.12837916709551257390
+#endif
+
+#ifndef M_SQRT2
+#define M_SQRT2 1.41421356237309504880
+#endif
+
+#ifndef M_1_SQRT2
+#define M_1_SQRT2 0.70710678118654752440
+#endif
+
+
+
+#endif /* __BAVII_EXPRINCL_H */
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprinit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprinit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprinit.c Tue Nov 13 15:23:26 2007
@@ -1,115 +1,115 @@
-/*
- File: exprinit.c
- Auth: Brian Allen Vanderburg II
- Date: Thursday, May 1, 2003
- Desc: Extra functions and routines for ExprEval
-
- This file is part of ExprEval.
-*/
-
-/* Include files */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-
-
-/* Macro for adding a function node type */
-#define EXPR_ADDFUNC_TYPE(name, type, argmin, argmax, refmin, refmax) \
-err = exprFuncListAddType(flist, name, type, argmin, argmax, refmin, refmax); \
-if(err != EXPR_ERROR_NOERROR) \
- return err;
-
-/* Macro for adding a constant */
-#define EXPR_ADDCONST(name, val) \
-err = exprValListAdd(vlist, name, val); \
-if(err != EXPR_ERROR_NOERROR) \
- return err;
-
-/* Call this function to initialize these functions into a function list */
-int exprFuncListInit(exprFuncList *flist)
- {
- int err;
-
- if(flist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- EXPR_ADDFUNC_TYPE("abs", EXPR_NODEFUNC_ABS, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("mod", EXPR_NODEFUNC_MOD, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("ipart", EXPR_NODEFUNC_IPART, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("fpart", EXPR_NODEFUNC_FPART, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("min", EXPR_NODEFUNC_MIN, 1, -1, 0, 0);
- EXPR_ADDFUNC_TYPE("max", EXPR_NODEFUNC_MAX, 1, -1, 0, 0);
- EXPR_ADDFUNC_TYPE("pow", EXPR_NODEFUNC_POW, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("sqrt", EXPR_NODEFUNC_SQRT, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("sin", EXPR_NODEFUNC_SIN, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("sinh", EXPR_NODEFUNC_SINH, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("asin", EXPR_NODEFUNC_ASIN, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("cos", EXPR_NODEFUNC_COS, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("cosh", EXPR_NODEFUNC_COSH, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("acos", EXPR_NODEFUNC_ACOS, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("tan", EXPR_NODEFUNC_TAN, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("tanh", EXPR_NODEFUNC_TANH, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("atan", EXPR_NODEFUNC_ATAN, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("atan2", EXPR_NODEFUNC_ATAN2, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("log", EXPR_NODEFUNC_LOG, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("pow10", EXPR_NODEFUNC_POW10, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("ln", EXPR_NODEFUNC_LN, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("exp", EXPR_NODEFUNC_EXP, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("logn", EXPR_NODEFUNC_LOGN, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("ceil", EXPR_NODEFUNC_CEIL, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("floor", EXPR_NODEFUNC_FLOOR, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("rand", EXPR_NODEFUNC_RAND, 0, 0, 1, 1);
- EXPR_ADDFUNC_TYPE("random", EXPR_NODEFUNC_RANDOM, 2, 2, 1, 1);
- EXPR_ADDFUNC_TYPE("randomize", EXPR_NODEFUNC_RANDOMIZE, 0, 0, 1, 1);
- EXPR_ADDFUNC_TYPE("deg", EXPR_NODEFUNC_DEG, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("rad", EXPR_NODEFUNC_RAD, 1, 1, 0, 0);
- EXPR_ADDFUNC_TYPE("recttopolr", EXPR_NODEFUNC_RECTTOPOLR, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("recttopola", EXPR_NODEFUNC_RECTTOPOLA, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("poltorectx", EXPR_NODEFUNC_POLTORECTX, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("poltorecty", EXPR_NODEFUNC_POLTORECTY, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("if", EXPR_NODEFUNC_IF, 3, 3, 0, 0);
- EXPR_ADDFUNC_TYPE("select", EXPR_NODEFUNC_SELECT, 3, 4, 0, 0);
- EXPR_ADDFUNC_TYPE("equal", EXPR_NODEFUNC_EQUAL, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("above", EXPR_NODEFUNC_ABOVE, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("below", EXPR_NODEFUNC_BELOW, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("avg", EXPR_NODEFUNC_AVG, 1, -1, 0, 0);
- EXPR_ADDFUNC_TYPE("clip", EXPR_NODEFUNC_CLIP, 3, 3, 0, 0);
- EXPR_ADDFUNC_TYPE("clamp", EXPR_NODEFUNC_CLAMP, 3, 3, 0, 0);
- EXPR_ADDFUNC_TYPE("pntchange", EXPR_NODEFUNC_PNTCHANGE, 5, 5, 0, 0);
- EXPR_ADDFUNC_TYPE("poly", EXPR_NODEFUNC_POLY, 2, -1, 0, 0);
- EXPR_ADDFUNC_TYPE("and", EXPR_NODEFUNC_AND, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("or", EXPR_NODEFUNC_OR, 2, 2, 0, 0);
- EXPR_ADDFUNC_TYPE("not", EXPR_NODEFUNC_NOT, 1 ,1, 0, 0);
- EXPR_ADDFUNC_TYPE("for", EXPR_NODEFUNC_FOR, 4, -1, 0, 0);
- EXPR_ADDFUNC_TYPE("many", EXPR_NODEFUNC_MANY, 1, -1, 0, 0);
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Call this function to initialize some constants into a value list */
-int exprValListInit(exprValList *vlist)
- {
- int err;
-
- if(vlist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- EXPR_ADDCONST("M_E", M_E);
- EXPR_ADDCONST("M_LOG2E", M_LOG2E);
- EXPR_ADDCONST("M_LOG10E", M_LOG10E);
- EXPR_ADDCONST("M_LN2", M_LN2);
- EXPR_ADDCONST("M_LN10", M_LN10);
- EXPR_ADDCONST("M_PI", M_PI);
- EXPR_ADDCONST("M_PI_2", M_PI_2);
- EXPR_ADDCONST("M_PI_4", M_PI_4);
- EXPR_ADDCONST("M_1_PI", M_1_PI);
- EXPR_ADDCONST("M_2_PI", M_2_PI);
- EXPR_ADDCONST("M_1_SQRTPI", M_1_SQRTPI);
- EXPR_ADDCONST("M_2_SQRTPI", M_2_SQRTPI);
- EXPR_ADDCONST("M_SQRT2", M_SQRT2);
- EXPR_ADDCONST("M_1_SQRT2", M_1_SQRT2);
-
- return EXPR_ERROR_NOERROR;
- }
-
-
+/*
+ File: exprinit.c
+ Auth: Brian Allen Vanderburg II
+ Date: Thursday, May 1, 2003
+ Desc: Extra functions and routines for ExprEval
+
+ This file is part of ExprEval.
+*/
+
+/* Include files */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+
+
+/* Macro for adding a function node type */
+#define EXPR_ADDFUNC_TYPE(name, type, argmin, argmax, refmin, refmax) \
+err = exprFuncListAddType(flist, name, type, argmin, argmax, refmin, refmax); \
+if(err != EXPR_ERROR_NOERROR) \
+ return err;
+
+/* Macro for adding a constant */
+#define EXPR_ADDCONST(name, val) \
+err = exprValListAdd(vlist, name, val); \
+if(err != EXPR_ERROR_NOERROR) \
+ return err;
+
+/* Call this function to initialize these functions into a function list */
+int exprFuncListInit(exprFuncList *flist)
+ {
+ int err;
+
+ if(flist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ EXPR_ADDFUNC_TYPE("abs", EXPR_NODEFUNC_ABS, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("mod", EXPR_NODEFUNC_MOD, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("ipart", EXPR_NODEFUNC_IPART, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("fpart", EXPR_NODEFUNC_FPART, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("min", EXPR_NODEFUNC_MIN, 1, -1, 0, 0);
+ EXPR_ADDFUNC_TYPE("max", EXPR_NODEFUNC_MAX, 1, -1, 0, 0);
+ EXPR_ADDFUNC_TYPE("pow", EXPR_NODEFUNC_POW, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("sqrt", EXPR_NODEFUNC_SQRT, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("sin", EXPR_NODEFUNC_SIN, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("sinh", EXPR_NODEFUNC_SINH, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("asin", EXPR_NODEFUNC_ASIN, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("cos", EXPR_NODEFUNC_COS, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("cosh", EXPR_NODEFUNC_COSH, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("acos", EXPR_NODEFUNC_ACOS, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("tan", EXPR_NODEFUNC_TAN, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("tanh", EXPR_NODEFUNC_TANH, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("atan", EXPR_NODEFUNC_ATAN, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("atan2", EXPR_NODEFUNC_ATAN2, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("log", EXPR_NODEFUNC_LOG, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("pow10", EXPR_NODEFUNC_POW10, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("ln", EXPR_NODEFUNC_LN, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("exp", EXPR_NODEFUNC_EXP, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("logn", EXPR_NODEFUNC_LOGN, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("ceil", EXPR_NODEFUNC_CEIL, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("floor", EXPR_NODEFUNC_FLOOR, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("rand", EXPR_NODEFUNC_RAND, 0, 0, 1, 1);
+ EXPR_ADDFUNC_TYPE("random", EXPR_NODEFUNC_RANDOM, 2, 2, 1, 1);
+ EXPR_ADDFUNC_TYPE("randomize", EXPR_NODEFUNC_RANDOMIZE, 0, 0, 1, 1);
+ EXPR_ADDFUNC_TYPE("deg", EXPR_NODEFUNC_DEG, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("rad", EXPR_NODEFUNC_RAD, 1, 1, 0, 0);
+ EXPR_ADDFUNC_TYPE("recttopolr", EXPR_NODEFUNC_RECTTOPOLR, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("recttopola", EXPR_NODEFUNC_RECTTOPOLA, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("poltorectx", EXPR_NODEFUNC_POLTORECTX, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("poltorecty", EXPR_NODEFUNC_POLTORECTY, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("if", EXPR_NODEFUNC_IF, 3, 3, 0, 0);
+ EXPR_ADDFUNC_TYPE("select", EXPR_NODEFUNC_SELECT, 3, 4, 0, 0);
+ EXPR_ADDFUNC_TYPE("equal", EXPR_NODEFUNC_EQUAL, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("above", EXPR_NODEFUNC_ABOVE, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("below", EXPR_NODEFUNC_BELOW, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("avg", EXPR_NODEFUNC_AVG, 1, -1, 0, 0);
+ EXPR_ADDFUNC_TYPE("clip", EXPR_NODEFUNC_CLIP, 3, 3, 0, 0);
+ EXPR_ADDFUNC_TYPE("clamp", EXPR_NODEFUNC_CLAMP, 3, 3, 0, 0);
+ EXPR_ADDFUNC_TYPE("pntchange", EXPR_NODEFUNC_PNTCHANGE, 5, 5, 0, 0);
+ EXPR_ADDFUNC_TYPE("poly", EXPR_NODEFUNC_POLY, 2, -1, 0, 0);
+ EXPR_ADDFUNC_TYPE("and", EXPR_NODEFUNC_AND, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("or", EXPR_NODEFUNC_OR, 2, 2, 0, 0);
+ EXPR_ADDFUNC_TYPE("not", EXPR_NODEFUNC_NOT, 1 ,1, 0, 0);
+ EXPR_ADDFUNC_TYPE("for", EXPR_NODEFUNC_FOR, 4, -1, 0, 0);
+ EXPR_ADDFUNC_TYPE("many", EXPR_NODEFUNC_MANY, 1, -1, 0, 0);
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Call this function to initialize some constants into a value list */
+int exprValListInit(exprValList *vlist)
+ {
+ int err;
+
+ if(vlist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ EXPR_ADDCONST("M_E", M_E);
+ EXPR_ADDCONST("M_LOG2E", M_LOG2E);
+ EXPR_ADDCONST("M_LOG10E", M_LOG10E);
+ EXPR_ADDCONST("M_LN2", M_LN2);
+ EXPR_ADDCONST("M_LN10", M_LN10);
+ EXPR_ADDCONST("M_PI", M_PI);
+ EXPR_ADDCONST("M_PI_2", M_PI_2);
+ EXPR_ADDCONST("M_PI_4", M_PI_4);
+ EXPR_ADDCONST("M_1_PI", M_1_PI);
+ EXPR_ADDCONST("M_2_PI", M_2_PI);
+ EXPR_ADDCONST("M_1_SQRTPI", M_1_SQRTPI);
+ EXPR_ADDCONST("M_2_SQRTPI", M_2_SQRTPI);
+ EXPR_ADDCONST("M_SQRT2", M_SQRT2);
+ EXPR_ADDCONST("M_1_SQRT2", M_1_SQRT2);
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprmem.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprmem.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprmem.c Tue Nov 13 15:23:26 2007
@@ -1,39 +1,39 @@
-/*
- File: exprmem.c
- Auth: Brian Allen Vanderburg II
- Date: Wednesday, April 30, 2003
- Desc: Memory functions for ExprEval
-
- This file is part of ExprEval.
-*/
-
-/* Includes */
-#include "exprincl.h"
-
-#include "exprmem.h"
-
-/* Allocate memory and zero it */
-void* exprAllocMem(size_t size)
- {
- void *data = malloc(size);
-
- if(data)
- {
- memset(data, 0, size);
- }
-
- return data;
- }
-
-/* Free memory */
-void exprFreeMem(void *data)
- {
- if(data)
- free(data);
- }
-
-/* Allocate a list of nodes */
-exprNode *exprAllocNodes(size_t count)
- {
- return exprAllocMem(count * sizeof(exprNode));
- }
+/*
+ File: exprmem.c
+ Auth: Brian Allen Vanderburg II
+ Date: Wednesday, April 30, 2003
+ Desc: Memory functions for ExprEval
+
+ This file is part of ExprEval.
+*/
+
+/* Includes */
+#include "exprincl.h"
+
+#include "exprmem.h"
+
+/* Allocate memory and zero it */
+void* exprAllocMem(size_t size)
+ {
+ void *data = malloc(size);
+
+ if(data)
+ {
+ memset(data, 0, size);
+ }
+
+ return data;
+ }
+
+/* Free memory */
+void exprFreeMem(void *data)
+ {
+ if(data)
+ free(data);
+ }
+
+/* Allocate a list of nodes */
+exprNode *exprAllocNodes(size_t count)
+ {
+ return exprAllocMem(count * sizeof(exprNode));
+ }
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h Tue Nov 13 15:23:26 2007
@@ -1,21 +1,21 @@
-/*
- File: exprmem.h
- Auth: Brian Allen Vanderburg II
- Date: Wednesday, April 30, 2003
- Desc: Memory functions for ExprEval
-
- This file is part of ExprEval.
-*/
-
-#ifndef __BAVII_EXPRMEM_H
-#define __BAVII_EXPRMEM_H
-
-/* Needed for exprNode */
-#include "exprpriv.h"
-
-void* exprAllocMem(size_t size);
-void exprFreeMem(void *data);
-exprNode *exprAllocNodes(size_t count);
-
-
-#endif /* __BAVII_EXPRMEM_H */
+/*
+ File: exprmem.h
+ Auth: Brian Allen Vanderburg II
+ Date: Wednesday, April 30, 2003
+ Desc: Memory functions for ExprEval
+
+ This file is part of ExprEval.
+*/
+
+#ifndef __BAVII_EXPRMEM_H
+#define __BAVII_EXPRMEM_H
+
+/* Needed for exprNode */
+#include "exprpriv.h"
+
+void* exprAllocMem(size_t size);
+void exprFreeMem(void *data);
+exprNode *exprAllocNodes(size_t count);
+
+
+#endif /* __BAVII_EXPRMEM_H */
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprobj.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprobj.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprobj.c Tue Nov 13 15:23:26 2007
@@ -1,237 +1,237 @@
-/*
- File: exprobj.c
- Auth: Brian Allen Vanderburg II
- Date: Tuesday, April 29, 2003
- Desc: Functions for the exprObj type
-
- This file is part of ExprEval.
-*/
-
-/* Includes */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-#include "exprmem.h"
-
-/* Internal functions */
-static void exprFreeNodeData(exprNode *node);
-
-
-/* Function to create an expression object */
-int exprCreate(exprObj **obj, exprFuncList *flist, exprValList *vlist, exprValList *clist,
- exprBreakFuncType breaker, void *userdata)
- {
- exprObj *tmp;
-
- /* Allocate memory for the object */
- tmp = exprAllocMem(sizeof(exprObj));
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
-
- /* Assign data */
- tmp->flist = flist;
- tmp->vlist = vlist;
- tmp->clist = clist;
- tmp->breakerfunc = breaker;
- tmp->userdata = userdata;
- tmp->breakcount = 100000; /* Default breaker count setting */
- tmp->breakcur = 0;
-
- /* Update pointer */
- *obj = tmp;
-
- return EXPR_ERROR_NOERROR;
- }
-
-
-/* Free the expression */
-int exprFree(exprObj *obj)
- {
- if(obj == NULL)
- return EXPR_ERROR_NOERROR;
-
- /* First free the node data */
- exprFreeNodeData(obj->headnode);
- exprFreeMem(obj->headnode);
-
- /* Free ourself */
- exprFreeMem(obj);
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Clear expression, keep lists, etc */
-int exprClear(exprObj *obj)
- {
- if(obj == NULL)
- return EXPR_ERROR_NOERROR;
-
- /* Free the node data only, keep function, variable, constant lists */
- exprFreeNodeData(obj->headnode);
- exprFreeMem(obj->headnode);
-
- obj->headnode = NULL;
- obj->parsedbad = 0;
- obj->parsedgood = 0;
-
- return EXPR_ERROR_NOERROR;
- }
-
-
-/* Get functions to get information about the expression object */
-
-/* Get the function list */
-exprFuncList *exprGetFuncList(exprObj *obj)
- {
- return (obj == NULL) ? NULL : obj->flist;
- }
-
-/* Get the variable list */
-exprValList *exprGetVarList(exprObj *obj)
- {
- return (obj == NULL) ? NULL : obj->vlist;
- }
-
-/* Get the constant list */
-exprValList *exprGetConstList(exprObj *obj)
- {
- return (obj == NULL) ? NULL : obj->clist;
- }
-
-/* Get the breaker function */
-exprBreakFuncType exprGetBreakFunc(exprObj *obj)
- {
- return (obj == NULL) ? NULL : obj->breakerfunc;
- }
-
-/* Check for break status */
-int exprGetBreakResult(exprObj *obj)
- {
- if(obj == NULL)
- return 0;
-
- if(obj->breakerfunc == NULL)
- return 0;
-
- return (*(obj->breakerfunc))(obj);
- }
-
-/* Get the user data */
-void *exprGetUserData(exprObj *obj)
- {
- return (obj == NULL) ? NULL : obj->userdata;
- }
-
-
-/* Set functions to set certain data */
-
-/* Set user data */
-void exprSetUserData(exprObj *obj, void *userdata)
- {
- if(obj)
- obj->userdata = userdata;
- }
-
-
-/* Set breaker count */
-void exprSetBreakCount(exprObj *obj, int count)
- {
- if(obj)
- {
- /* If count is negative, make it positive */
- if(count < 0)
- count = -count;
-
- obj->breakcount = count;
-
- /* Make sure the current value is not bigger than count */
- if(obj->breakcur > count)
- obj->breakcur = count;
- }
- }
-
-/* Get error position */
-void exprGetErrorPosition(exprObj *obj, int *start, int *end)
- {
- if(obj)
- {
- if(start)
- *start = obj->starterr;
-
- if(end)
- *end = obj->enderr;
- }
- }
-
-/* This function will free a node's data */
-static void exprFreeNodeData(exprNode *node)
- {
- int pos;
-
- if(node == NULL)
- return;
-
- /* free data based on type */
- switch(node->type)
- {
- case EXPR_NODETYPE_ADD:
- case EXPR_NODETYPE_SUBTRACT:
- case EXPR_NODETYPE_MULTIPLY:
- case EXPR_NODETYPE_DIVIDE:
- case EXPR_NODETYPE_EXPONENT:
- case EXPR_NODETYPE_NEGATE:
- case EXPR_NODETYPE_MULTI:
- /* Free operation data */
- if(node->data.oper.nodes)
- {
- for(pos = 0; pos < node->data.oper.nodecount; pos++)
- exprFreeNodeData(&(node->data.oper.nodes[pos]));
-
- exprFreeMem(node->data.oper.nodes);
- }
-
- break;
-
-
- case EXPR_NODETYPE_VALUE:
- /* Nothing to free for value */
- break;
-
- case EXPR_NODETYPE_VARIABLE:
- /* Nothing to free for variable */
- break;
-
- case EXPR_NODETYPE_FUNCTION:
- /* Free data of each subnode */
- if(node->data.function.nodes)
- {
- for(pos = 0; pos < node->data.function.nodecount; pos++)
- exprFreeNodeData(&(node->data.function.nodes[pos]));
-
- /* Free the subnode array */
- exprFreeMem(node->data.function.nodes);
- }
-
- /* Free reference variable list */
- if(node->data.function.refs)
- exprFreeMem(node->data.function.refs);
-
- break;
-
- case EXPR_NODETYPE_ASSIGN:
- /* Free subnode data */
- if(node->data.assign.node)
- {
- exprFreeNodeData(node->data.assign.node);
-
- /* Free the subnode */
- exprFreeMem(node->data.assign.node);
- }
-
- break;
- }
- }
-
-
+/*
+ File: exprobj.c
+ Auth: Brian Allen Vanderburg II
+ Date: Tuesday, April 29, 2003
+ Desc: Functions for the exprObj type
+
+ This file is part of ExprEval.
+*/
+
+/* Includes */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+#include "exprmem.h"
+
+/* Internal functions */
+static void exprFreeNodeData(exprNode *node);
+
+
+/* Function to create an expression object */
+int exprCreate(exprObj **obj, exprFuncList *flist, exprValList *vlist, exprValList *clist,
+ exprBreakFuncType breaker, void *userdata)
+ {
+ exprObj *tmp;
+
+ /* Allocate memory for the object */
+ tmp = exprAllocMem(sizeof(exprObj));
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+
+ /* Assign data */
+ tmp->flist = flist;
+ tmp->vlist = vlist;
+ tmp->clist = clist;
+ tmp->breakerfunc = breaker;
+ tmp->userdata = userdata;
+ tmp->breakcount = 100000; /* Default breaker count setting */
+ tmp->breakcur = 0;
+
+ /* Update pointer */
+ *obj = tmp;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+
+/* Free the expression */
+int exprFree(exprObj *obj)
+ {
+ if(obj == NULL)
+ return EXPR_ERROR_NOERROR;
+
+ /* First free the node data */
+ exprFreeNodeData(obj->headnode);
+ exprFreeMem(obj->headnode);
+
+ /* Free ourself */
+ exprFreeMem(obj);
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Clear expression, keep lists, etc */
+int exprClear(exprObj *obj)
+ {
+ if(obj == NULL)
+ return EXPR_ERROR_NOERROR;
+
+ /* Free the node data only, keep function, variable, constant lists */
+ exprFreeNodeData(obj->headnode);
+ exprFreeMem(obj->headnode);
+
+ obj->headnode = NULL;
+ obj->parsedbad = 0;
+ obj->parsedgood = 0;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+
+/* Get functions to get information about the expression object */
+
+/* Get the function list */
+exprFuncList *exprGetFuncList(exprObj *obj)
+ {
+ return (obj == NULL) ? NULL : obj->flist;
+ }
+
+/* Get the variable list */
+exprValList *exprGetVarList(exprObj *obj)
+ {
+ return (obj == NULL) ? NULL : obj->vlist;
+ }
+
+/* Get the constant list */
+exprValList *exprGetConstList(exprObj *obj)
+ {
+ return (obj == NULL) ? NULL : obj->clist;
+ }
+
+/* Get the breaker function */
+exprBreakFuncType exprGetBreakFunc(exprObj *obj)
+ {
+ return (obj == NULL) ? NULL : obj->breakerfunc;
+ }
+
+/* Check for break status */
+int exprGetBreakResult(exprObj *obj)
+ {
+ if(obj == NULL)
+ return 0;
+
+ if(obj->breakerfunc == NULL)
+ return 0;
+
+ return (*(obj->breakerfunc))(obj);
+ }
+
+/* Get the user data */
+void *exprGetUserData(exprObj *obj)
+ {
+ return (obj == NULL) ? NULL : obj->userdata;
+ }
+
+
+/* Set functions to set certain data */
+
+/* Set user data */
+void exprSetUserData(exprObj *obj, void *userdata)
+ {
+ if(obj)
+ obj->userdata = userdata;
+ }
+
+
+/* Set breaker count */
+void exprSetBreakCount(exprObj *obj, int count)
+ {
+ if(obj)
+ {
+ /* If count is negative, make it positive */
+ if(count < 0)
+ count = -count;
+
+ obj->breakcount = count;
+
+ /* Make sure the current value is not bigger than count */
+ if(obj->breakcur > count)
+ obj->breakcur = count;
+ }
+ }
+
+/* Get error position */
+void exprGetErrorPosition(exprObj *obj, int *start, int *end)
+ {
+ if(obj)
+ {
+ if(start)
+ *start = obj->starterr;
+
+ if(end)
+ *end = obj->enderr;
+ }
+ }
+
+/* This function will free a node's data */
+static void exprFreeNodeData(exprNode *node)
+ {
+ int pos;
+
+ if(node == NULL)
+ return;
+
+ /* free data based on type */
+ switch(node->type)
+ {
+ case EXPR_NODETYPE_ADD:
+ case EXPR_NODETYPE_SUBTRACT:
+ case EXPR_NODETYPE_MULTIPLY:
+ case EXPR_NODETYPE_DIVIDE:
+ case EXPR_NODETYPE_EXPONENT:
+ case EXPR_NODETYPE_NEGATE:
+ case EXPR_NODETYPE_MULTI:
+ /* Free operation data */
+ if(node->data.oper.nodes)
+ {
+ for(pos = 0; pos < node->data.oper.nodecount; pos++)
+ exprFreeNodeData(&(node->data.oper.nodes[pos]));
+
+ exprFreeMem(node->data.oper.nodes);
+ }
+
+ break;
+
+
+ case EXPR_NODETYPE_VALUE:
+ /* Nothing to free for value */
+ break;
+
+ case EXPR_NODETYPE_VARIABLE:
+ /* Nothing to free for variable */
+ break;
+
+ case EXPR_NODETYPE_FUNCTION:
+ /* Free data of each subnode */
+ if(node->data.function.nodes)
+ {
+ for(pos = 0; pos < node->data.function.nodecount; pos++)
+ exprFreeNodeData(&(node->data.function.nodes[pos]));
+
+ /* Free the subnode array */
+ exprFreeMem(node->data.function.nodes);
+ }
+
+ /* Free reference variable list */
+ if(node->data.function.refs)
+ exprFreeMem(node->data.function.refs);
+
+ break;
+
+ case EXPR_NODETYPE_ASSIGN:
+ /* Free subnode data */
+ if(node->data.assign.node)
+ {
+ exprFreeNodeData(node->data.assign.node);
+
+ /* Free the subnode */
+ exprFreeMem(node->data.assign.node);
+ }
+
+ break;
+ }
+ }
+
+
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprpars.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprpars.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprpars.c Tue Nov 13 15:23:26 2007
@@ -1,1558 +1,1558 @@
-/*
- File: exprpars.c
- Auth: Brian Allen Vanderburg II
- Date: Wednesday, April 30, 2003
- Desc: Actual parsing routines for this library
-
- This file is part of ExprEval.
-*/
-
-/* Includes */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-#include "exprmem.h"
-
-/* Data structure used by parser */
-typedef struct _exprToken
- {
- int type; /* token type */
- int start; /* token start position */
- int end; /* token end position */
-
- union _tdata
- {
- char *str; /* string data */
- EXPRTYPE val; /* value data */
- } data;
- } exprToken;
-
-/* Defines for token types */
-#define EXPR_TOKEN_UNKNOWN 0
-#define EXPR_TOKEN_OPAREN 1
-#define EXPR_TOKEN_CPAREN 2
-#define EXPR_TOKEN_IDENTIFIER 3
-#define EXPR_TOKEN_VALUE 4
-#define EXPR_TOKEN_PLUS 5
-#define EXPR_TOKEN_HYPHEN 6
-#define EXPR_TOKEN_ASTERISK 7
-#define EXPR_TOKEN_FSLASH 8
-#define EXPR_TOKEN_AMPERSAND 9
-#define EXPR_TOKEN_SEMICOLON 10
-#define EXPR_TOKEN_COMMA 11
-#define EXPR_TOKEN_EQUAL 12
-#define EXPR_TOKEN_HAT 13
-
-/* Internal functions */
-int exprMultiParse(exprObj *obj, exprNode *node, exprToken *tokens, int count);
-int exprInternalParse(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end);
-int exprInternalParseAssign(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseAdd(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseSub(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseMul(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseDiv(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParsePosNeg(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseExp(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
-int exprInternalParseFunction(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int p1, int p2);
-int exprInternalParseVarVal(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end);
-int exprStringToTokenList(exprObj *obj, char *expr, exprToken **tokens, int *count);
-void exprFreeTokenList(exprToken *tokens, int count);
-
-/* This frees a token list */
-void exprFreeTokenList(exprToken *tokens, int count)
- {
- int pos;
-
- if(tokens == NULL)
- return;
-
- for(pos = 0; pos < count; pos++)
- {
- if(tokens[pos].type == EXPR_TOKEN_IDENTIFIER)
- exprFreeMem(tokens[pos].data.str);
- }
-
- exprFreeMem(tokens);
- }
-
-/* This converts an expression string to a token list */
-int exprStringToTokenList(exprObj *obj, char *expr, exprToken **tokens, int *count)
- {
- int found;
- exprToken *list;
- int pass;
- int pos, len;
- int tpos;
- int comment; /* Is a comment active */
- int start, ilen;
- char buf[EXPR_MAXIDENTSIZE + 1];
-
- /* Set initial variables */
- found = 0;
- tpos = 0;
- list = NULL;
- comment = 0;
- *tokens = NULL;
- *count = 0;
-
-
- /* Check string length */
- len = (int)strlen(expr);
- if(len == 0)
- return EXPR_ERROR_EMPTYEXPR;
-
- /* Two passes, one to count, one to tokenize */
- for(pass = 0; pass <= 1; pass++)
- {
- for(pos = 0; pos < len; pos++)
- {
- switch(expr[pos])
- {
- /* Comment */
- case '#':
- {
- /* Only set it if a comment is not already active */
- if(!comment)
- comment = 1;
-
- break;
- }
-
- /* Newline characters turn off comments */
- case '\r':
- case '\n':
- {
- /* If a comment is active, unset it */
- if(comment)
- comment = 0;
-
- break;
- }
-
- /* Open parenthesis */
- case '(':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_OPAREN;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Close parenthesis */
- case ')':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_CPAREN;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Plus */
- case '+':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_PLUS;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Hyphen */
- case '-':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_HYPHEN;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Asterisk */
- case '*':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_ASTERISK;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Forward slash */
- case '/':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_FSLASH;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Hat */
- case '^':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_HAT;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Ampersand */
- case '&':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_AMPERSAND;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Semicolon */
- case ';':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_SEMICOLON;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Comma */
- case ',':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_COMMA;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Equal sign */
- case '=':
- {
- if(!comment)
- {
- if(pass == 0)
- found++;
- else
- {
- list[tpos].type = EXPR_TOKEN_EQUAL;
- list[tpos].start = pos;
- list[tpos].end = pos;
- tpos++;
- }
- }
-
- break;
- }
-
- /* Identifiers and values */
- default:
- {
- if(!comment)
- {
- if(expr[pos] == '.' || isdigit(expr[pos]))
- {
- /* Value */
- start = pos;
-
- /* Find digits before a period */
- while(isdigit(expr[pos]))
- pos++;
-
- /* Find a period */
- if(expr[pos] == '.')
- pos++;
-
- /* Find digits after a period */
- while(isdigit(expr[pos]))
- pos++;
-
- /* pos is AFTER last item, back up */
- pos--;
-
- if(pass == 0)
- found++;
- else
- {
- ilen = pos - start + 1;
-
- /* Is the value to large */
- if(ilen > EXPR_MAXIDENTSIZE)
- {
- obj->starterr = start;
- obj->enderr = pos;
- exprFreeTokenList(list, found);
- return EXPR_ERROR_BADIDENTIFIER;
- }
-
- /* Create value token */
- strncpy(buf, expr + start, ilen);
- buf[ilen] = '\0';
-
- list[tpos].type = EXPR_TOKEN_VALUE;
- list[tpos].start = start;
- list[tpos].end = pos;
- list[tpos].data.val = (EXPRTYPE)atof(buf);
- tpos++;
- }
- }
- else if(expr[pos] == '_' || isalpha(expr[pos]))
- {
- /* Identifier */
- start = pos;
-
- /* Find rest of identifier */
- while(expr[pos] == '_' || isalnum(expr[pos]))
- pos++;
-
- /* pos is AFTER last item, back up */
- pos--;
-
- if(pass == 0)
- found++;
- else
- {
- ilen = pos - start + 1;
-
- /* Is the value to large */
- if(ilen > EXPR_MAXIDENTSIZE)
- {
- obj->starterr = start;
- obj->enderr = pos;
- exprFreeTokenList(list, found);
- return EXPR_ERROR_BADIDENTIFIER;
- }
-
- /* Create value token */
- strncpy(buf, expr + start, ilen);
- buf[ilen] = '\0';
-
- /* Allocate memory for identifier */
- list[tpos].data.str = exprAllocMem(ilen + 1);
- if(list[tpos].data.str == NULL)
- {
- exprFreeTokenList(list, found);
- return EXPR_ERROR_MEMORY;
- }
-
- list[tpos].type = EXPR_TOKEN_IDENTIFIER;
- list[tpos].start = start;
- list[tpos].end = pos;
- strcpy(list[tpos].data.str, buf);
- tpos++;
- }
- }
- else if(isspace(expr[pos]))
- {
- /* Spaces are ignored, do nothing */
- }
- else
- {
- /* Unknown */
- obj->starterr = obj->enderr = pos;
- exprFreeTokenList(list, found);
- return EXPR_ERROR_INVALIDCHAR;
- }
- }
-
- break;
- }
- }
- }
-
- /* If pass is 0, allocate memory for next pass */
- if(pass == 0)
- {
- /* First, make sure all comments were ended */
- if(comment)
- comment = 0;
-
- /* Make sure the expression is not empty */
- if(found == 0)
- return EXPR_ERROR_EMPTYEXPR;
-
- /* Allocate memory for token list */
- list = exprAllocMem(found * sizeof(exprToken));
- if(list == NULL)
- return EXPR_ERROR_MEMORY;
-
- tpos = 0;
- }
- }
-
- *count = found;
- *tokens = list;
- return EXPR_ERROR_NOERROR;
- }
-
-
-/* This is the main parsing routine */
-int exprParse(exprObj *obj, char *expr)
- {
- exprToken *tokens;
- int count;
- int err;
- exprNode *tmp;
-
- /* Make sure an object was passed */
- if(obj == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Clear expression error position */
- obj->starterr = obj->enderr = -1;
-
- /* Have we already been parsed? */
- if(obj->parsedbad != 0)
- return EXPR_ERROR_ALREADYPARSEDBAD;
-
- if(obj->parsedgood != 0)
- return EXPR_ERROR_ALREADYPARSEDGOOD;
-
- /* Make sure an expression was passed */
- if(expr == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Create token list */
- err = exprStringToTokenList(obj, expr, &tokens, &count);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* Create head pointer */
- tmp = exprAllocNodes(1);
- if(tmp == NULL)
- {
- exprFreeTokenList(tokens, count);
- return EXPR_ERROR_MEMORY;
- }
-
- obj->headnode = tmp;
-
- /* Call the multiparse routine to parse subexpressions */
- err = exprMultiParse(obj, tmp, tokens, count);
-
- /* Free the token list */
- exprFreeTokenList(tokens, count);
-
- /* successful parse? */
- if(err == EXPR_ERROR_NOERROR)
- {
- obj->parsedgood = 1;
- obj->parsedbad = 0;
- }
- else
- {
- obj->parsedbad = 1;
- obj->parsedgood = 0;
- }
-
- return err;
- }
-
-
-/* Parse the subexpressions, each ending with semicolons */
-int exprMultiParse(exprObj *obj, exprNode *node, exprToken *tokens, int count)
- {
- int pos, plevel, last;
- int num, cur, err;
- exprNode *tmp;
-
- plevel = 0;
- num = 0;
- last = -1;
-
- /* First count the number of arguments */
- for(pos = 0; pos < count; pos++)
- {
- switch(tokens[pos].type)
- {
- case EXPR_TOKEN_OPAREN:
- /* increase plevel */
- plevel++;
- break;
-
- case EXPR_TOKEN_CPAREN:
- /* decrease plevel */
- plevel--;
-
- if(plevel < 0)
- {
- obj->starterr = tokens[pos].start;
- obj->enderr = tokens[pos].end;
- return EXPR_ERROR_UNMATCHEDPAREN;
- }
-
- break;
-
- case EXPR_TOKEN_SEMICOLON:
- if(plevel == 0)
- {
- if(last == pos - 1 || pos == 0)
- {
- /* last semicolon is before us or we are at the start */
- obj->starterr = tokens[pos].start;
- obj->enderr = tokens[pos].end;
- return EXPR_ERROR_SYNTAX;
- }
- else
- {
- /* last semicolon is not right before us */
- num++;
- }
- }
- else
- {
- /* Semicolon should not be in a parenthesis */
- obj->starterr = tokens[pos].start;
- obj->enderr = tokens[pos].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- last = pos; /* update position of last semicolon */
- break;
- }
- }
-
- /* plevel should be zero now */
- if(plevel != 0)
- return EXPR_ERROR_UNMATCHEDPAREN;
-
- /* the last character should be a semicolon */
- if(last != pos - 1)
- return EXPR_ERROR_MISSINGSEMICOLON;
-
- /* Now we know how many arguments there are */
-
- /* Allocate array of subnodes */
- tmp = exprAllocNodes(num);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- /* Set the current node's data */
- node->type = EXPR_NODETYPE_MULTI;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = num;
-
- /* now we parse each subexpression */
- last = 0; /* Not for last semicolon, but for first char of subexpr */
- cur = 0;
-
- for(pos = 0; pos < count; pos++)
- {
- if(tokens[pos].type == EXPR_TOKEN_SEMICOLON)
- {
- /* Everything from last up to pos - 1 is a parameter */
- err = exprInternalParse(obj, &(tmp[cur]), tokens, last, pos - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* Update last position and current argument */
- last = pos + 1;
- cur++;
- }
- }
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* This function parses each subnode and recurses if needed */
-int exprInternalParse(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end)
- {
- int pos;
- int plevel = 0; /* Paren level */
- int fgopen = -1; /* First paren group open index */
- int fgclose = -1; /* First paren group close index */
- int assignindex = -1; /* First = at plevel 0 for assignment */
- int addsubindex = -1; /* Last + or - at plevel 0 for adding or subtracting */
- int muldivindex = -1; /* Last * or / at plevel 0 for multiplying or dividing */
- int expindex = -1; /* Last ^ fount at plevel 0 for exponents */
- int posnegindex = -1; /* First +,- at plevel 0 for positive,negative */
-
- /* Make sure some conditions are right */
- if(start > end)
- return EXPR_ERROR_UNKNOWN;
-
- /* Scan the string for certain characters */
- for(pos = start; pos <= end; pos++)
- {
- switch(tokens[pos].type)
- {
- case EXPR_TOKEN_OPAREN:
- plevel++;
-
- /* First group open? */
- if(plevel == 1 && fgopen == -1)
- fgopen = pos;
- break;
-
- case EXPR_TOKEN_CPAREN:
- plevel--;
-
- /* First group close? */
- if(plevel == 0 && fgclose == -1)
- fgclose = pos;
-
- if(plevel < 0)
- {
- obj->starterr = tokens[pos].start;
- obj->enderr = tokens[pos].end;
- return EXPR_ERROR_UNMATCHEDPAREN;
- }
- break;
-
- case EXPR_TOKEN_EQUAL:
- /* Assignment found */
- if(plevel == 0)
- {
- if(assignindex == -1)
- assignindex = pos;
- }
- break;
-
- case EXPR_TOKEN_ASTERISK:
- case EXPR_TOKEN_FSLASH:
- /* Multiplication or division */
- if(plevel == 0)
- muldivindex = pos;
- break;
-
- case EXPR_TOKEN_HAT:
- /* Exponent */
- if(plevel == 0)
- expindex = pos;
- break;
-
-
- case EXPR_TOKEN_PLUS:
- case EXPR_TOKEN_HYPHEN:
- /* Addition or positive or subtraction or negative*/
- if(plevel == 0)
- {
- if(pos == start)
- {
- /* At the start area, positive/negative */
- if(posnegindex == -1)
- posnegindex = pos;
- }
- else
- {
- /* Not at start, check item in front */
- switch(tokens[pos - 1].type)
- {
- case EXPR_TOKEN_EQUAL: /* Equal sign */
- case EXPR_TOKEN_PLUS: /* Add/positive sign */
- case EXPR_TOKEN_HYPHEN: /* Subtract/negative sign */
- case EXPR_TOKEN_ASTERISK: /* Multiply sign */
- case EXPR_TOKEN_FSLASH: /* Divide sign */
- case EXPR_TOKEN_HAT: /* Exponent sign */
-
- /* After theses, it is positive/negative */
- if(posnegindex == -1)
- posnegindex = pos;
-
- break;
-
- default:
- /* Otherwise it is addition/subtraction */
- addsubindex = pos;
- break;
- }
- }
- }
- break;
-
- }
- }
-
- /* plevel should now be zero */
- if(plevel != 0)
- return EXPR_ERROR_UNMATCHEDPAREN;
-
- /* We must parse the data in a certain order to maintain the
- correct order of operators at evaluation time */
-
- /* First, take care of assignment */
- if(assignindex != -1)
- return exprInternalParseAssign(obj, node, tokens, start, end, assignindex);
-
- /* Addition or subtraction is next */
- if(addsubindex != -1)
- {
- if(tokens[addsubindex].type == EXPR_TOKEN_PLUS)
- return exprInternalParseAdd(obj, node, tokens, start, end, addsubindex);
- else
- return exprInternalParseSub(obj, node, tokens, start, end, addsubindex);
- }
-
-
- /* Multiplycation or division */
- if(muldivindex != -1)
- {
- if(tokens[muldivindex].type == EXPR_TOKEN_ASTERISK)
- return exprInternalParseMul(obj, node, tokens, start, end, muldivindex);
- else
- return exprInternalParseDiv(obj, node, tokens, start, end, muldivindex);
- }
-
- /* Exponent */
- if(expindex != -1)
- return exprInternalParseExp(obj, node, tokens, start, end, expindex);
-
- /* Negation */
- if(posnegindex != -1)
- return exprInternalParsePosNeg(obj, node, tokens, start, end, posnegindex);
-
-
- /* Grouped parenthesis */
- if(fgopen == start)
- {
- /* Closing paren. should be at the end */
- if(fgclose == end)
- {
- /* Anything between them */
- if(fgclose > fgopen + 1)
- {
- return exprInternalParse(obj, node, tokens, fgopen + 1, fgclose - 1);
- }
- else
- {
- /* Nothing between them */
- obj->starterr = tokens[fgopen].start;
- obj->enderr = tokens[fgclose].end;
- return EXPR_ERROR_SYNTAX;
- }
- }
- else /* Closing paren not at the end */
- return EXPR_ERROR_SYNTAX;
- }
-
- /* Functions */
- if(fgopen > start)
- {
- /* Closing paren should be at end */
- if(fgclose == end)
- {
- return exprInternalParseFunction(obj, node, tokens, start, end, fgopen, fgclose);
- }
- else /* Closing paren not at end */
- return EXPR_ERROR_SYNTAX;
- }
-
- /* If it was none of the above, it must be a variable or value */
- return exprInternalParseVarVal(obj, node, tokens, start, end);
- }
-
-/* Function to parse an assignment node */
-int exprInternalParseAssign(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
- exprValList *l;
- EXPRTYPE *addr;
-
- /* Make sure the equal sign is not at the start or end */
- if(index != start + 1 || index >= end)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* Make sure item before equal sign is an identifier */
- if(tokens[index - 1].type != EXPR_TOKEN_IDENTIFIER)
- {
- obj->starterr = tokens[index - 1].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* Create expression subnode */
- tmp = exprAllocNodes(1);
- if(tmp == NULL)
- {
- return EXPR_ERROR_MEMORY;
- }
-
-
- /* Set the data */
- node->type = EXPR_NODETYPE_ASSIGN;
- node->data.assign.node = tmp;
-
-
- /*
- The fast access method directly accesses the memory address
- of the variable's value at evaluation time. Because of this,
- we must make sure the variable does exists in the variable list.
- */
-
- /* Make sure name is not a constant name */
- l = exprGetConstList(obj);
- if(l)
- {
- exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
- if(addr)
- {
- obj->starterr = tokens[index - 1].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_CONSTANTASSIGN;
- }
- }
-
- /* Get the variable list */
- l = exprGetVarList(obj);
- if(l == NULL)
- return EXPR_ERROR_NOVARLIST;
-
- /* Get variable address if already in the list */
- exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
- if(addr == NULL) /* Variable not in the list, add it */
- {
- exprValListAdd(l, tokens[index - 1].data.str, 0.0);
-
- /* Try to get address again */
- exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
- if(addr == NULL) /* Could not add variable */
- return EXPR_ERROR_MEMORY; /* Could not add variable to list */
- }
-
- node->data.assign.vaddr = addr;
-
- /* Parse the subnode */
- return exprInternalParse(obj, tmp, tokens, index + 1, end);
- }
-
-/* Function to parse an addition operator */
-int exprInternalParseAdd(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
- int err;
-
- /* Make sure plus sign is at a good place */
- if(index <= start || index >= end)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* Allocate space for 2 subnodes */
- tmp = exprAllocNodes(2);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
-
- /* Set the data */
- node->type = EXPR_NODETYPE_ADD;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = 2;
-
- /* parse the left side */
- err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* parse the right side */
- return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
- }
-
-/* Function to parse a subtraction operator */
-int exprInternalParseSub(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
- int err;
-
- /* Make sure minus sign is at a good place */
- if(index <= start || index >= end)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* Allocate space for 2 subnodes */
- tmp = exprAllocNodes(2);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
-
- /* Set the data */
- node->type = EXPR_NODETYPE_SUBTRACT;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = 2;
-
- /* parse the left side */
- err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* parse the right side */
- return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
- }
-
-/* Function to parse a multiplication operator */
-int exprInternalParseMul(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
- int err;
-
- /* Make sure times sign is at a good place */
- if(index <= start || index >= end)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
-
- /* Allocate space for 2 subnodes */
- tmp = exprAllocNodes(2);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
-
- /* Set the data */
- node->type = EXPR_NODETYPE_MULTIPLY;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = 2;
-
- /* parse the left side */
- err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* parse the right side */
- return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
- }
-
-/* Function to parse a division operator */
-int exprInternalParseDiv(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
- int err;
-
- /* Make sure slash sign is at a good place */
- if(index <= start || index >= end)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
-
- /* Allocate space for 2 subnodes */
- tmp = exprAllocNodes(2);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
-
- /* Set the data */
- node->type = EXPR_NODETYPE_DIVIDE;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = 2;
-
- /* parse the left side */
- err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* parse the right side */
- return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
- }
-
-/* Function to parse an exponent operator */
-int exprInternalParseExp(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
- int err;
-
- /* Make sure exponent sign is at a good place */
- if(index <= start || index >= end)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_SYNTAX;
- }
-
-
- /* Allocate space for 2 subnodes */
- tmp = exprAllocNodes(2);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
-
- /* Set the data */
- node->type = EXPR_NODETYPE_EXPONENT;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = 2;
-
- /* parse the left side */
- err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* parse the right side */
- return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
- }
-
-/* Function to parse for positive and negative */
-int exprInternalParsePosNeg(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
- {
- exprNode *tmp;
-
- /* Position should be the same as start */
- if(index != start)
- {
- obj->starterr = tokens[index].start;
- obj->enderr = tokens[index].end;
- return EXPR_ERROR_UNKNOWN;
- }
-
- /* If it is a positive, just parse the internal of it */
- if(tokens[index].type == EXPR_TOKEN_PLUS)
- return exprInternalParse(obj, node, tokens, index + 1, end);
- else
- {
- /* Allocate subnode */
- tmp = exprAllocNodes(1);
- if(tmp == NULL)
- return EXPR_ERROR_NOERROR;
-
-
- /* Set data */
- node->type = EXPR_NODETYPE_NEGATE;
- node->data.oper.nodes = tmp;
- node->data.oper.nodecount = 1;
-
- /* Parse the subnode */
- return exprInternalParse(obj, tmp, tokens, index + 1, end);
- }
- }
-
-/* Function will parse a call to a function */
-int exprInternalParseFunction(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int p1, int p2)
- {
- int pos;
- int num, cur;
- int refnum, refcur;
- int plevel = 0;
- int lv, err;
- exprNode *tmp;
- exprFuncType fptr;
- int argmin, argmax;
- int refargmin, refargmax;
- int type;
- exprFuncList *l;
- exprValList *vars;
- EXPRTYPE *addr;
- EXPRTYPE **reftmp;
-
- /* We should have a function list */
- l = exprGetFuncList(obj);
- if(l == NULL)
- return EXPR_ERROR_NOSUCHFUNCTION;
-
- /* check paren. location */
- if(p2 <= p1)
- return EXPR_ERROR_SYNTAX;
-
- /* second paren. should not be after the end */
- if(p2 > end)
- return EXPR_ERROR_SYNTAX;
-
- /* Item before parenthesis should be an identifier */
- if(tokens[p1 - 1].type != EXPR_TOKEN_IDENTIFIER)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p1].end;
- return EXPR_ERROR_SYNTAX;
- }
-
-
- /* Look up the function */
- err = exprFuncListGet(l, tokens[p1 - 1].data.str, &fptr, &type, &argmin, &argmax, &refargmin, &refargmax);
- if(err != EXPR_ERROR_NOERROR)
- {
- if(err == EXPR_ERROR_NOTFOUND)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p1 - 1].end;
- return EXPR_ERROR_NOSUCHFUNCTION;
- }
- else
- return err;
- }
-
- /* Make sure the function exists */
- if(fptr == NULL && type == 0)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p1 - 1].end;
- return EXPR_ERROR_NOSUCHFUNCTION;
- }
-
- /* Count arguments */
- if(p2 == p1 + 1)
- {
- num = 0;
- refnum = 0;
- }
- else
- {
- num = 1;
- refnum = 0;
-
-
- /* count commas */
- for(pos = p1 + 1; pos < p2; pos++)
- {
- switch(tokens[pos].type)
- {
- case EXPR_TOKEN_OPAREN:
- plevel++;
- break;
-
- case EXPR_TOKEN_CPAREN:
- plevel--;
- if(plevel < 0)
- {
- obj->starterr = tokens[pos].start;
- obj->enderr = tokens[pos].end;
- return EXPR_ERROR_UNMATCHEDPAREN;
- }
- break;
-
- case EXPR_TOKEN_COMMA:
- /* Found comma */
- if(plevel == 0)
- num++;
- break;
-
- case EXPR_TOKEN_AMPERSAND:
- /* Found reference mark */
- if(plevel == 0)
- {
- /* This may only occur after the open parenthesis or comma */
- if(tokens[pos - 1].type == EXPR_TOKEN_OPAREN || tokens[pos - 1].type == EXPR_TOKEN_COMMA)
- refnum++;
- else
- return EXPR_ERROR_SYNTAX;
- }
- break;
- }
- }
-
- /* plevel should be zero */
- if(plevel != 0)
- return EXPR_ERROR_UNMATCHEDPAREN;
- }
-
- /* We now have the number of total arguments and
- number of ref arguments. Get number of normal
- arguments */
- num = num - refnum;
-
- /* Make sure number of arguments is correct */
- /* Here we make sure the limits are greater
- or equal to zero because any negative number
- could be used to specify no limit */
- if(argmin >= 0 && num < argmin)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p2].end;
- return EXPR_ERROR_BADNUMBERARGUMENTS;
- }
-
- if(argmax >= 0 && num > argmax)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p2].end;
- return EXPR_ERROR_BADNUMBERARGUMENTS;
- }
-
- if(refargmin >= 0 && refnum < refargmin)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p2].end;
- return EXPR_ERROR_BADNUMBERARGUMENTS;
- }
-
- if(refargmax >= 0 && refnum > refargmax)
- {
- obj->starterr = tokens[p1 - 1].start;
- obj->enderr = tokens[p2].end;
- return EXPR_ERROR_BADNUMBERARGUMENTS;
- }
-
- /* Set tmp to null in case of no arguments */
- tmp = NULL;
- reftmp = NULL;
-
- if(num > 0)
- {
- /* Allocate subnodes */
- tmp = exprAllocNodes(num);
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
- }
-
- if(refnum > 0)
- {
- /* Allocate ref pointers */
- reftmp = exprAllocMem(sizeof(EXPRTYPE*) * refnum);
- if(reftmp == NULL)
- {
- exprFreeMem(tmp);
- return EXPR_ERROR_MEMORY;
- }
- }
-
-
-
- /* Set this node's data */
- node->type = EXPR_NODETYPE_FUNCTION;
- node->data.function.fptr = fptr;
- node->data.function.nodecount = num;
- node->data.function.nodes = tmp;
- node->data.function.refcount = refnum;
- node->data.function.refs = reftmp;
- node->data.function.type = type;
-
- /* parse each subnode */
- if(num + refnum > 0)
- {
- plevel = 0;
- cur = 0;
- refcur = 0;
- lv = p1 + 1;
-
- /* look for commas if more than 1 arg */
- if(num + refnum > 1)
- {
- for(pos = p1 + 1; pos < p2; pos++)
- {
- switch(tokens[pos].type)
- {
- case EXPR_TOKEN_OPAREN:
- plevel++;
- break;
-
- case EXPR_TOKEN_CPAREN:
- plevel--;
- break; /* Already checked paren nesting above */
-
- case EXPR_TOKEN_COMMA:
- /* Found comma */
- if(plevel == 0)
- {
- /* parse inside */
- if(tokens[lv].type == EXPR_TOKEN_AMPERSAND)
- {
- if(lv != pos - 2)
- {
- obj->starterr = tokens[lv].start;
- obj->enderr = tokens[pos].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* It is a reference */
- if(tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER)
- {
- obj->starterr = tokens[lv].start;
- obj->enderr = tokens[lv + 1].end;
- return EXPR_ERROR_SYNTAX;
- }
-
-
- /* Make sure it is not a constant */
- vars = exprGetConstList(obj);
- if(vars)
- {
- exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
- if(addr)
- {
- obj->starterr = tokens[lv].start;
- obj->enderr = tokens[lv + 1].start;
- return EXPR_ERROR_REFCONSTANT;
- }
- }
-
- /* Get variable list */
- vars = exprGetVarList(obj);
- if(vars == NULL)
- return EXPR_ERROR_NOVARLIST;
-
- /* Get variable address */
- exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
- if(addr == NULL)
- {
- /* Add variable to list */
- exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
-
- /* Try to get address again */
- exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
- if(addr == NULL)
- return EXPR_ERROR_MEMORY; /* Could not add variable */
- }
-
- /* Set reference item */
- reftmp[refcur] = addr;
-
- /* increase ref arg number and lv position*/
- refcur++;
- lv = pos + 1;
- }
- else
- {
- err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, pos - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
-
- /* increase arg number and lv position*/
- lv = pos + 1;
- cur++;
- }
- }
- break;
- }
- }
- }
-
- /* lv should point after the last comma, or open paren. if only 1 arg */
- if(tokens[lv].type == EXPR_TOKEN_AMPERSAND)
- {
- if(lv != p2 - 2)
- {
- obj->starterr = tokens[lv].start;
- obj->enderr = tokens[p2].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* It is a reference */
- if(tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER)
- {
- obj->starterr = tokens[lv].start;
- obj->enderr = tokens[lv + 1].end;
- return EXPR_ERROR_SYNTAX;
- }
-
- /* Make sure it is not a constant */
- vars = exprGetConstList(obj);
- if(vars)
- {
- exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
- if(addr)
- {
- obj->starterr = tokens[lv].start;
- obj->enderr = tokens[lv + 1].start;
- return EXPR_ERROR_REFCONSTANT;
- }
- }
-
- /* Get variable list */
- vars = exprGetVarList(obj);
- if(vars == NULL)
- return EXPR_ERROR_NOVARLIST;
-
- /* Get variable address */
- exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
- if(addr == NULL)
- {
- /* Add variable to list */
- exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
-
- /* Try to get address again */
- exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
- if(addr == NULL)
- return EXPR_ERROR_MEMORY; /* Could not add variable */
- }
-
- /* Set reference item */
- reftmp[refcur] = addr;
- }
- else
- {
- err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, p2 - 1);
- if(err != EXPR_ERROR_NOERROR)
- return err;
- }
- }
-
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Parse a variable or value */
-int exprInternalParseVarVal(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end)
- {
- exprValList *l;
- EXPRTYPE *addr;
-
-
- /* Make sure positions are correct */
- if(start != end)
- {
- return EXPR_ERROR_UNKNOWN;
- }
-
-
- /* Are we an identifier */
- if(tokens[start].type == EXPR_TOKEN_IDENTIFIER)
- {
- /* we are an identifier */
-
- /* check to see if it is a constant */
- l = exprGetConstList(obj);
- if(l != NULL)
- {
- if(exprValListGetAddress(l, tokens[start].data.str, &addr) == EXPR_ERROR_NOERROR)
- {
- /* We found it in the constant list */
-
- /*
- Treat is like a variable node so application can change
- constant value and it will reflect in expression
- */
-
- node->type = EXPR_NODETYPE_VARIABLE;
- node->data.variable.vaddr = addr;
- return EXPR_ERROR_NOERROR;
- }
- }
-
- /* Not found in the constant list, so it must be a variable */
-
- /* Set node type */
- node->type = EXPR_NODETYPE_VARIABLE;
-
- /*
- The fast access method directly accesses the memory address
- of the variable's value at evaluation time. Because of this,
- we must make sure the variable does exists in the variable list.
- */
-
- /* Get the variable list */
- l = exprGetVarList(obj);
- if(l == NULL)
- return EXPR_ERROR_NOVARLIST;
-
- /* Get variable address if already in the list */
- exprValListGetAddress(l, tokens[start].data.str, &addr);
- if(addr == NULL) /* Variable not in the list, add it */
- {
- exprValListAdd(l, tokens[start].data.str, 0.0);
-
- /* Try to get address again */
- exprValListGetAddress(l, tokens[start].data.str, &addr);
- if(addr == NULL) /* Could not add variable */
- return EXPR_ERROR_MEMORY; /* Could not add variable to list */
- }
-
- node->data.variable.vaddr = addr;
-
- return EXPR_ERROR_NOERROR;
- }
- else if(tokens[start].type == EXPR_TOKEN_VALUE)
- {
- /* we are a value */
- node->type = EXPR_NODETYPE_VALUE;
- node->data.value.value = tokens[start].data.val;
- return EXPR_ERROR_NOERROR;
- }
- else
- {
- obj->starterr = tokens[start].start;
- obj->enderr = tokens[end].end;
- return EXPR_ERROR_UNKNOWN;
- }
- }
+/*
+ File: exprpars.c
+ Auth: Brian Allen Vanderburg II
+ Date: Wednesday, April 30, 2003
+ Desc: Actual parsing routines for this library
+
+ This file is part of ExprEval.
+*/
+
+/* Includes */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+#include "exprmem.h"
+
+/* Data structure used by parser */
+typedef struct _exprToken
+ {
+ int type; /* token type */
+ int start; /* token start position */
+ int end; /* token end position */
+
+ union _tdata
+ {
+ char *str; /* string data */
+ EXPRTYPE val; /* value data */
+ } data;
+ } exprToken;
+
+/* Defines for token types */
+#define EXPR_TOKEN_UNKNOWN 0
+#define EXPR_TOKEN_OPAREN 1
+#define EXPR_TOKEN_CPAREN 2
+#define EXPR_TOKEN_IDENTIFIER 3
+#define EXPR_TOKEN_VALUE 4
+#define EXPR_TOKEN_PLUS 5
+#define EXPR_TOKEN_HYPHEN 6
+#define EXPR_TOKEN_ASTERISK 7
+#define EXPR_TOKEN_FSLASH 8
+#define EXPR_TOKEN_AMPERSAND 9
+#define EXPR_TOKEN_SEMICOLON 10
+#define EXPR_TOKEN_COMMA 11
+#define EXPR_TOKEN_EQUAL 12
+#define EXPR_TOKEN_HAT 13
+
+/* Internal functions */
+int exprMultiParse(exprObj *obj, exprNode *node, exprToken *tokens, int count);
+int exprInternalParse(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end);
+int exprInternalParseAssign(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParseAdd(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParseSub(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParseMul(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParseDiv(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParsePosNeg(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParseExp(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index);
+int exprInternalParseFunction(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int p1, int p2);
+int exprInternalParseVarVal(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end);
+int exprStringToTokenList(exprObj *obj, char *expr, exprToken **tokens, int *count);
+void exprFreeTokenList(exprToken *tokens, int count);
+
+/* This frees a token list */
+void exprFreeTokenList(exprToken *tokens, int count)
+ {
+ int pos;
+
+ if(tokens == NULL)
+ return;
+
+ for(pos = 0; pos < count; pos++)
+ {
+ if(tokens[pos].type == EXPR_TOKEN_IDENTIFIER)
+ exprFreeMem(tokens[pos].data.str);
+ }
+
+ exprFreeMem(tokens);
+ }
+
+/* This converts an expression string to a token list */
+int exprStringToTokenList(exprObj *obj, char *expr, exprToken **tokens, int *count)
+ {
+ int found;
+ exprToken *list;
+ int pass;
+ int pos, len;
+ int tpos;
+ int comment; /* Is a comment active */
+ int start, ilen;
+ char buf[EXPR_MAXIDENTSIZE + 1];
+
+ /* Set initial variables */
+ found = 0;
+ tpos = 0;
+ list = NULL;
+ comment = 0;
+ *tokens = NULL;
+ *count = 0;
+
+
+ /* Check string length */
+ len = (int)strlen(expr);
+ if(len == 0)
+ return EXPR_ERROR_EMPTYEXPR;
+
+ /* Two passes, one to count, one to tokenize */
+ for(pass = 0; pass <= 1; pass++)
+ {
+ for(pos = 0; pos < len; pos++)
+ {
+ switch(expr[pos])
+ {
+ /* Comment */
+ case '#':
+ {
+ /* Only set it if a comment is not already active */
+ if(!comment)
+ comment = 1;
+
+ break;
+ }
+
+ /* Newline characters turn off comments */
+ case '\r':
+ case '\n':
+ {
+ /* If a comment is active, unset it */
+ if(comment)
+ comment = 0;
+
+ break;
+ }
+
+ /* Open parenthesis */
+ case '(':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_OPAREN;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Close parenthesis */
+ case ')':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_CPAREN;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Plus */
+ case '+':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_PLUS;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Hyphen */
+ case '-':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_HYPHEN;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Asterisk */
+ case '*':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_ASTERISK;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Forward slash */
+ case '/':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_FSLASH;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Hat */
+ case '^':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_HAT;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Ampersand */
+ case '&':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_AMPERSAND;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Semicolon */
+ case ';':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_SEMICOLON;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Comma */
+ case ',':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_COMMA;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Equal sign */
+ case '=':
+ {
+ if(!comment)
+ {
+ if(pass == 0)
+ found++;
+ else
+ {
+ list[tpos].type = EXPR_TOKEN_EQUAL;
+ list[tpos].start = pos;
+ list[tpos].end = pos;
+ tpos++;
+ }
+ }
+
+ break;
+ }
+
+ /* Identifiers and values */
+ default:
+ {
+ if(!comment)
+ {
+ if(expr[pos] == '.' || isdigit(expr[pos]))
+ {
+ /* Value */
+ start = pos;
+
+ /* Find digits before a period */
+ while(isdigit(expr[pos]))
+ pos++;
+
+ /* Find a period */
+ if(expr[pos] == '.')
+ pos++;
+
+ /* Find digits after a period */
+ while(isdigit(expr[pos]))
+ pos++;
+
+ /* pos is AFTER last item, back up */
+ pos--;
+
+ if(pass == 0)
+ found++;
+ else
+ {
+ ilen = pos - start + 1;
+
+ /* Is the value to large */
+ if(ilen > EXPR_MAXIDENTSIZE)
+ {
+ obj->starterr = start;
+ obj->enderr = pos;
+ exprFreeTokenList(list, found);
+ return EXPR_ERROR_BADIDENTIFIER;
+ }
+
+ /* Create value token */
+ strncpy(buf, expr + start, ilen);
+ buf[ilen] = '\0';
+
+ list[tpos].type = EXPR_TOKEN_VALUE;
+ list[tpos].start = start;
+ list[tpos].end = pos;
+ list[tpos].data.val = (EXPRTYPE)atof(buf);
+ tpos++;
+ }
+ }
+ else if(expr[pos] == '_' || isalpha(expr[pos]))
+ {
+ /* Identifier */
+ start = pos;
+
+ /* Find rest of identifier */
+ while(expr[pos] == '_' || isalnum(expr[pos]))
+ pos++;
+
+ /* pos is AFTER last item, back up */
+ pos--;
+
+ if(pass == 0)
+ found++;
+ else
+ {
+ ilen = pos - start + 1;
+
+ /* Is the value to large */
+ if(ilen > EXPR_MAXIDENTSIZE)
+ {
+ obj->starterr = start;
+ obj->enderr = pos;
+ exprFreeTokenList(list, found);
+ return EXPR_ERROR_BADIDENTIFIER;
+ }
+
+ /* Create value token */
+ strncpy(buf, expr + start, ilen);
+ buf[ilen] = '\0';
+
+ /* Allocate memory for identifier */
+ list[tpos].data.str = exprAllocMem(ilen + 1);
+ if(list[tpos].data.str == NULL)
+ {
+ exprFreeTokenList(list, found);
+ return EXPR_ERROR_MEMORY;
+ }
+
+ list[tpos].type = EXPR_TOKEN_IDENTIFIER;
+ list[tpos].start = start;
+ list[tpos].end = pos;
+ strcpy(list[tpos].data.str, buf);
+ tpos++;
+ }
+ }
+ else if(isspace(expr[pos]))
+ {
+ /* Spaces are ignored, do nothing */
+ }
+ else
+ {
+ /* Unknown */
+ obj->starterr = obj->enderr = pos;
+ exprFreeTokenList(list, found);
+ return EXPR_ERROR_INVALIDCHAR;
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ /* If pass is 0, allocate memory for next pass */
+ if(pass == 0)
+ {
+ /* First, make sure all comments were ended */
+ if(comment)
+ comment = 0;
+
+ /* Make sure the expression is not empty */
+ if(found == 0)
+ return EXPR_ERROR_EMPTYEXPR;
+
+ /* Allocate memory for token list */
+ list = exprAllocMem(found * sizeof(exprToken));
+ if(list == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ tpos = 0;
+ }
+ }
+
+ *count = found;
+ *tokens = list;
+ return EXPR_ERROR_NOERROR;
+ }
+
+
+/* This is the main parsing routine */
+int exprParse(exprObj *obj, char *expr)
+ {
+ exprToken *tokens;
+ int count;
+ int err;
+ exprNode *tmp;
+
+ /* Make sure an object was passed */
+ if(obj == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Clear expression error position */
+ obj->starterr = obj->enderr = -1;
+
+ /* Have we already been parsed? */
+ if(obj->parsedbad != 0)
+ return EXPR_ERROR_ALREADYPARSEDBAD;
+
+ if(obj->parsedgood != 0)
+ return EXPR_ERROR_ALREADYPARSEDGOOD;
+
+ /* Make sure an expression was passed */
+ if(expr == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Create token list */
+ err = exprStringToTokenList(obj, expr, &tokens, &count);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* Create head pointer */
+ tmp = exprAllocNodes(1);
+ if(tmp == NULL)
+ {
+ exprFreeTokenList(tokens, count);
+ return EXPR_ERROR_MEMORY;
+ }
+
+ obj->headnode = tmp;
+
+ /* Call the multiparse routine to parse subexpressions */
+ err = exprMultiParse(obj, tmp, tokens, count);
+
+ /* Free the token list */
+ exprFreeTokenList(tokens, count);
+
+ /* successful parse? */
+ if(err == EXPR_ERROR_NOERROR)
+ {
+ obj->parsedgood = 1;
+ obj->parsedbad = 0;
+ }
+ else
+ {
+ obj->parsedbad = 1;
+ obj->parsedgood = 0;
+ }
+
+ return err;
+ }
+
+
+/* Parse the subexpressions, each ending with semicolons */
+int exprMultiParse(exprObj *obj, exprNode *node, exprToken *tokens, int count)
+ {
+ int pos, plevel, last;
+ int num, cur, err;
+ exprNode *tmp;
+
+ plevel = 0;
+ num = 0;
+ last = -1;
+
+ /* First count the number of arguments */
+ for(pos = 0; pos < count; pos++)
+ {
+ switch(tokens[pos].type)
+ {
+ case EXPR_TOKEN_OPAREN:
+ /* increase plevel */
+ plevel++;
+ break;
+
+ case EXPR_TOKEN_CPAREN:
+ /* decrease plevel */
+ plevel--;
+
+ if(plevel < 0)
+ {
+ obj->starterr = tokens[pos].start;
+ obj->enderr = tokens[pos].end;
+ return EXPR_ERROR_UNMATCHEDPAREN;
+ }
+
+ break;
+
+ case EXPR_TOKEN_SEMICOLON:
+ if(plevel == 0)
+ {
+ if(last == pos - 1 || pos == 0)
+ {
+ /* last semicolon is before us or we are at the start */
+ obj->starterr = tokens[pos].start;
+ obj->enderr = tokens[pos].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+ else
+ {
+ /* last semicolon is not right before us */
+ num++;
+ }
+ }
+ else
+ {
+ /* Semicolon should not be in a parenthesis */
+ obj->starterr = tokens[pos].start;
+ obj->enderr = tokens[pos].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ last = pos; /* update position of last semicolon */
+ break;
+ }
+ }
+
+ /* plevel should be zero now */
+ if(plevel != 0)
+ return EXPR_ERROR_UNMATCHEDPAREN;
+
+ /* the last character should be a semicolon */
+ if(last != pos - 1)
+ return EXPR_ERROR_MISSINGSEMICOLON;
+
+ /* Now we know how many arguments there are */
+
+ /* Allocate array of subnodes */
+ tmp = exprAllocNodes(num);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ /* Set the current node's data */
+ node->type = EXPR_NODETYPE_MULTI;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = num;
+
+ /* now we parse each subexpression */
+ last = 0; /* Not for last semicolon, but for first char of subexpr */
+ cur = 0;
+
+ for(pos = 0; pos < count; pos++)
+ {
+ if(tokens[pos].type == EXPR_TOKEN_SEMICOLON)
+ {
+ /* Everything from last up to pos - 1 is a parameter */
+ err = exprInternalParse(obj, &(tmp[cur]), tokens, last, pos - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* Update last position and current argument */
+ last = pos + 1;
+ cur++;
+ }
+ }
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* This function parses each subnode and recurses if needed */
+int exprInternalParse(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end)
+ {
+ int pos;
+ int plevel = 0; /* Paren level */
+ int fgopen = -1; /* First paren group open index */
+ int fgclose = -1; /* First paren group close index */
+ int assignindex = -1; /* First = at plevel 0 for assignment */
+ int addsubindex = -1; /* Last + or - at plevel 0 for adding or subtracting */
+ int muldivindex = -1; /* Last * or / at plevel 0 for multiplying or dividing */
+ int expindex = -1; /* Last ^ fount at plevel 0 for exponents */
+ int posnegindex = -1; /* First +,- at plevel 0 for positive,negative */
+
+ /* Make sure some conditions are right */
+ if(start > end)
+ return EXPR_ERROR_UNKNOWN;
+
+ /* Scan the string for certain characters */
+ for(pos = start; pos <= end; pos++)
+ {
+ switch(tokens[pos].type)
+ {
+ case EXPR_TOKEN_OPAREN:
+ plevel++;
+
+ /* First group open? */
+ if(plevel == 1 && fgopen == -1)
+ fgopen = pos;
+ break;
+
+ case EXPR_TOKEN_CPAREN:
+ plevel--;
+
+ /* First group close? */
+ if(plevel == 0 && fgclose == -1)
+ fgclose = pos;
+
+ if(plevel < 0)
+ {
+ obj->starterr = tokens[pos].start;
+ obj->enderr = tokens[pos].end;
+ return EXPR_ERROR_UNMATCHEDPAREN;
+ }
+ break;
+
+ case EXPR_TOKEN_EQUAL:
+ /* Assignment found */
+ if(plevel == 0)
+ {
+ if(assignindex == -1)
+ assignindex = pos;
+ }
+ break;
+
+ case EXPR_TOKEN_ASTERISK:
+ case EXPR_TOKEN_FSLASH:
+ /* Multiplication or division */
+ if(plevel == 0)
+ muldivindex = pos;
+ break;
+
+ case EXPR_TOKEN_HAT:
+ /* Exponent */
+ if(plevel == 0)
+ expindex = pos;
+ break;
+
+
+ case EXPR_TOKEN_PLUS:
+ case EXPR_TOKEN_HYPHEN:
+ /* Addition or positive or subtraction or negative*/
+ if(plevel == 0)
+ {
+ if(pos == start)
+ {
+ /* At the start area, positive/negative */
+ if(posnegindex == -1)
+ posnegindex = pos;
+ }
+ else
+ {
+ /* Not at start, check item in front */
+ switch(tokens[pos - 1].type)
+ {
+ case EXPR_TOKEN_EQUAL: /* Equal sign */
+ case EXPR_TOKEN_PLUS: /* Add/positive sign */
+ case EXPR_TOKEN_HYPHEN: /* Subtract/negative sign */
+ case EXPR_TOKEN_ASTERISK: /* Multiply sign */
+ case EXPR_TOKEN_FSLASH: /* Divide sign */
+ case EXPR_TOKEN_HAT: /* Exponent sign */
+
+ /* After theses, it is positive/negative */
+ if(posnegindex == -1)
+ posnegindex = pos;
+
+ break;
+
+ default:
+ /* Otherwise it is addition/subtraction */
+ addsubindex = pos;
+ break;
+ }
+ }
+ }
+ break;
+
+ }
+ }
+
+ /* plevel should now be zero */
+ if(plevel != 0)
+ return EXPR_ERROR_UNMATCHEDPAREN;
+
+ /* We must parse the data in a certain order to maintain the
+ correct order of operators at evaluation time */
+
+ /* First, take care of assignment */
+ if(assignindex != -1)
+ return exprInternalParseAssign(obj, node, tokens, start, end, assignindex);
+
+ /* Addition or subtraction is next */
+ if(addsubindex != -1)
+ {
+ if(tokens[addsubindex].type == EXPR_TOKEN_PLUS)
+ return exprInternalParseAdd(obj, node, tokens, start, end, addsubindex);
+ else
+ return exprInternalParseSub(obj, node, tokens, start, end, addsubindex);
+ }
+
+
+ /* Multiplycation or division */
+ if(muldivindex != -1)
+ {
+ if(tokens[muldivindex].type == EXPR_TOKEN_ASTERISK)
+ return exprInternalParseMul(obj, node, tokens, start, end, muldivindex);
+ else
+ return exprInternalParseDiv(obj, node, tokens, start, end, muldivindex);
+ }
+
+ /* Exponent */
+ if(expindex != -1)
+ return exprInternalParseExp(obj, node, tokens, start, end, expindex);
+
+ /* Negation */
+ if(posnegindex != -1)
+ return exprInternalParsePosNeg(obj, node, tokens, start, end, posnegindex);
+
+
+ /* Grouped parenthesis */
+ if(fgopen == start)
+ {
+ /* Closing paren. should be at the end */
+ if(fgclose == end)
+ {
+ /* Anything between them */
+ if(fgclose > fgopen + 1)
+ {
+ return exprInternalParse(obj, node, tokens, fgopen + 1, fgclose - 1);
+ }
+ else
+ {
+ /* Nothing between them */
+ obj->starterr = tokens[fgopen].start;
+ obj->enderr = tokens[fgclose].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+ }
+ else /* Closing paren not at the end */
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* Functions */
+ if(fgopen > start)
+ {
+ /* Closing paren should be at end */
+ if(fgclose == end)
+ {
+ return exprInternalParseFunction(obj, node, tokens, start, end, fgopen, fgclose);
+ }
+ else /* Closing paren not at end */
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* If it was none of the above, it must be a variable or value */
+ return exprInternalParseVarVal(obj, node, tokens, start, end);
+ }
+
+/* Function to parse an assignment node */
+int exprInternalParseAssign(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+ exprValList *l;
+ EXPRTYPE *addr;
+
+ /* Make sure the equal sign is not at the start or end */
+ if(index != start + 1 || index >= end)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* Make sure item before equal sign is an identifier */
+ if(tokens[index - 1].type != EXPR_TOKEN_IDENTIFIER)
+ {
+ obj->starterr = tokens[index - 1].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* Create expression subnode */
+ tmp = exprAllocNodes(1);
+ if(tmp == NULL)
+ {
+ return EXPR_ERROR_MEMORY;
+ }
+
+
+ /* Set the data */
+ node->type = EXPR_NODETYPE_ASSIGN;
+ node->data.assign.node = tmp;
+
+
+ /*
+ The fast access method directly accesses the memory address
+ of the variable's value at evaluation time. Because of this,
+ we must make sure the variable does exists in the variable list.
+ */
+
+ /* Make sure name is not a constant name */
+ l = exprGetConstList(obj);
+ if(l)
+ {
+ exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
+ if(addr)
+ {
+ obj->starterr = tokens[index - 1].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_CONSTANTASSIGN;
+ }
+ }
+
+ /* Get the variable list */
+ l = exprGetVarList(obj);
+ if(l == NULL)
+ return EXPR_ERROR_NOVARLIST;
+
+ /* Get variable address if already in the list */
+ exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
+ if(addr == NULL) /* Variable not in the list, add it */
+ {
+ exprValListAdd(l, tokens[index - 1].data.str, 0.0);
+
+ /* Try to get address again */
+ exprValListGetAddress(l, tokens[index - 1].data.str, &addr);
+ if(addr == NULL) /* Could not add variable */
+ return EXPR_ERROR_MEMORY; /* Could not add variable to list */
+ }
+
+ node->data.assign.vaddr = addr;
+
+ /* Parse the subnode */
+ return exprInternalParse(obj, tmp, tokens, index + 1, end);
+ }
+
+/* Function to parse an addition operator */
+int exprInternalParseAdd(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+ int err;
+
+ /* Make sure plus sign is at a good place */
+ if(index <= start || index >= end)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* Allocate space for 2 subnodes */
+ tmp = exprAllocNodes(2);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+
+ /* Set the data */
+ node->type = EXPR_NODETYPE_ADD;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = 2;
+
+ /* parse the left side */
+ err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* parse the right side */
+ return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+ }
+
+/* Function to parse a subtraction operator */
+int exprInternalParseSub(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+ int err;
+
+ /* Make sure minus sign is at a good place */
+ if(index <= start || index >= end)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* Allocate space for 2 subnodes */
+ tmp = exprAllocNodes(2);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+
+ /* Set the data */
+ node->type = EXPR_NODETYPE_SUBTRACT;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = 2;
+
+ /* parse the left side */
+ err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* parse the right side */
+ return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+ }
+
+/* Function to parse a multiplication operator */
+int exprInternalParseMul(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+ int err;
+
+ /* Make sure times sign is at a good place */
+ if(index <= start || index >= end)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+
+ /* Allocate space for 2 subnodes */
+ tmp = exprAllocNodes(2);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+
+ /* Set the data */
+ node->type = EXPR_NODETYPE_MULTIPLY;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = 2;
+
+ /* parse the left side */
+ err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* parse the right side */
+ return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+ }
+
+/* Function to parse a division operator */
+int exprInternalParseDiv(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+ int err;
+
+ /* Make sure slash sign is at a good place */
+ if(index <= start || index >= end)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+
+ /* Allocate space for 2 subnodes */
+ tmp = exprAllocNodes(2);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+
+ /* Set the data */
+ node->type = EXPR_NODETYPE_DIVIDE;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = 2;
+
+ /* parse the left side */
+ err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* parse the right side */
+ return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+ }
+
+/* Function to parse an exponent operator */
+int exprInternalParseExp(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+ int err;
+
+ /* Make sure exponent sign is at a good place */
+ if(index <= start || index >= end)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+
+ /* Allocate space for 2 subnodes */
+ tmp = exprAllocNodes(2);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+
+ /* Set the data */
+ node->type = EXPR_NODETYPE_EXPONENT;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = 2;
+
+ /* parse the left side */
+ err = exprInternalParse(obj, &(tmp[0]), tokens, start, index - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* parse the right side */
+ return exprInternalParse(obj, &(tmp[1]), tokens, index + 1, end);
+ }
+
+/* Function to parse for positive and negative */
+int exprInternalParsePosNeg(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int index)
+ {
+ exprNode *tmp;
+
+ /* Position should be the same as start */
+ if(index != start)
+ {
+ obj->starterr = tokens[index].start;
+ obj->enderr = tokens[index].end;
+ return EXPR_ERROR_UNKNOWN;
+ }
+
+ /* If it is a positive, just parse the internal of it */
+ if(tokens[index].type == EXPR_TOKEN_PLUS)
+ return exprInternalParse(obj, node, tokens, index + 1, end);
+ else
+ {
+ /* Allocate subnode */
+ tmp = exprAllocNodes(1);
+ if(tmp == NULL)
+ return EXPR_ERROR_NOERROR;
+
+
+ /* Set data */
+ node->type = EXPR_NODETYPE_NEGATE;
+ node->data.oper.nodes = tmp;
+ node->data.oper.nodecount = 1;
+
+ /* Parse the subnode */
+ return exprInternalParse(obj, tmp, tokens, index + 1, end);
+ }
+ }
+
+/* Function will parse a call to a function */
+int exprInternalParseFunction(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end, int p1, int p2)
+ {
+ int pos;
+ int num, cur;
+ int refnum, refcur;
+ int plevel = 0;
+ int lv, err;
+ exprNode *tmp;
+ exprFuncType fptr;
+ int argmin, argmax;
+ int refargmin, refargmax;
+ int type;
+ exprFuncList *l;
+ exprValList *vars;
+ EXPRTYPE *addr;
+ EXPRTYPE **reftmp;
+
+ /* We should have a function list */
+ l = exprGetFuncList(obj);
+ if(l == NULL)
+ return EXPR_ERROR_NOSUCHFUNCTION;
+
+ /* check paren. location */
+ if(p2 <= p1)
+ return EXPR_ERROR_SYNTAX;
+
+ /* second paren. should not be after the end */
+ if(p2 > end)
+ return EXPR_ERROR_SYNTAX;
+
+ /* Item before parenthesis should be an identifier */
+ if(tokens[p1 - 1].type != EXPR_TOKEN_IDENTIFIER)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p1].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+
+ /* Look up the function */
+ err = exprFuncListGet(l, tokens[p1 - 1].data.str, &fptr, &type, &argmin, &argmax, &refargmin, &refargmax);
+ if(err != EXPR_ERROR_NOERROR)
+ {
+ if(err == EXPR_ERROR_NOTFOUND)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p1 - 1].end;
+ return EXPR_ERROR_NOSUCHFUNCTION;
+ }
+ else
+ return err;
+ }
+
+ /* Make sure the function exists */
+ if(fptr == NULL && type == 0)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p1 - 1].end;
+ return EXPR_ERROR_NOSUCHFUNCTION;
+ }
+
+ /* Count arguments */
+ if(p2 == p1 + 1)
+ {
+ num = 0;
+ refnum = 0;
+ }
+ else
+ {
+ num = 1;
+ refnum = 0;
+
+
+ /* count commas */
+ for(pos = p1 + 1; pos < p2; pos++)
+ {
+ switch(tokens[pos].type)
+ {
+ case EXPR_TOKEN_OPAREN:
+ plevel++;
+ break;
+
+ case EXPR_TOKEN_CPAREN:
+ plevel--;
+ if(plevel < 0)
+ {
+ obj->starterr = tokens[pos].start;
+ obj->enderr = tokens[pos].end;
+ return EXPR_ERROR_UNMATCHEDPAREN;
+ }
+ break;
+
+ case EXPR_TOKEN_COMMA:
+ /* Found comma */
+ if(plevel == 0)
+ num++;
+ break;
+
+ case EXPR_TOKEN_AMPERSAND:
+ /* Found reference mark */
+ if(plevel == 0)
+ {
+ /* This may only occur after the open parenthesis or comma */
+ if(tokens[pos - 1].type == EXPR_TOKEN_OPAREN || tokens[pos - 1].type == EXPR_TOKEN_COMMA)
+ refnum++;
+ else
+ return EXPR_ERROR_SYNTAX;
+ }
+ break;
+ }
+ }
+
+ /* plevel should be zero */
+ if(plevel != 0)
+ return EXPR_ERROR_UNMATCHEDPAREN;
+ }
+
+ /* We now have the number of total arguments and
+ number of ref arguments. Get number of normal
+ arguments */
+ num = num - refnum;
+
+ /* Make sure number of arguments is correct */
+ /* Here we make sure the limits are greater
+ or equal to zero because any negative number
+ could be used to specify no limit */
+ if(argmin >= 0 && num < argmin)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p2].end;
+ return EXPR_ERROR_BADNUMBERARGUMENTS;
+ }
+
+ if(argmax >= 0 && num > argmax)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p2].end;
+ return EXPR_ERROR_BADNUMBERARGUMENTS;
+ }
+
+ if(refargmin >= 0 && refnum < refargmin)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p2].end;
+ return EXPR_ERROR_BADNUMBERARGUMENTS;
+ }
+
+ if(refargmax >= 0 && refnum > refargmax)
+ {
+ obj->starterr = tokens[p1 - 1].start;
+ obj->enderr = tokens[p2].end;
+ return EXPR_ERROR_BADNUMBERARGUMENTS;
+ }
+
+ /* Set tmp to null in case of no arguments */
+ tmp = NULL;
+ reftmp = NULL;
+
+ if(num > 0)
+ {
+ /* Allocate subnodes */
+ tmp = exprAllocNodes(num);
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+ }
+
+ if(refnum > 0)
+ {
+ /* Allocate ref pointers */
+ reftmp = exprAllocMem(sizeof(EXPRTYPE*) * refnum);
+ if(reftmp == NULL)
+ {
+ exprFreeMem(tmp);
+ return EXPR_ERROR_MEMORY;
+ }
+ }
+
+
+
+ /* Set this node's data */
+ node->type = EXPR_NODETYPE_FUNCTION;
+ node->data.function.fptr = fptr;
+ node->data.function.nodecount = num;
+ node->data.function.nodes = tmp;
+ node->data.function.refcount = refnum;
+ node->data.function.refs = reftmp;
+ node->data.function.type = type;
+
+ /* parse each subnode */
+ if(num + refnum > 0)
+ {
+ plevel = 0;
+ cur = 0;
+ refcur = 0;
+ lv = p1 + 1;
+
+ /* look for commas if more than 1 arg */
+ if(num + refnum > 1)
+ {
+ for(pos = p1 + 1; pos < p2; pos++)
+ {
+ switch(tokens[pos].type)
+ {
+ case EXPR_TOKEN_OPAREN:
+ plevel++;
+ break;
+
+ case EXPR_TOKEN_CPAREN:
+ plevel--;
+ break; /* Already checked paren nesting above */
+
+ case EXPR_TOKEN_COMMA:
+ /* Found comma */
+ if(plevel == 0)
+ {
+ /* parse inside */
+ if(tokens[lv].type == EXPR_TOKEN_AMPERSAND)
+ {
+ if(lv != pos - 2)
+ {
+ obj->starterr = tokens[lv].start;
+ obj->enderr = tokens[pos].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* It is a reference */
+ if(tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER)
+ {
+ obj->starterr = tokens[lv].start;
+ obj->enderr = tokens[lv + 1].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+
+ /* Make sure it is not a constant */
+ vars = exprGetConstList(obj);
+ if(vars)
+ {
+ exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+ if(addr)
+ {
+ obj->starterr = tokens[lv].start;
+ obj->enderr = tokens[lv + 1].start;
+ return EXPR_ERROR_REFCONSTANT;
+ }
+ }
+
+ /* Get variable list */
+ vars = exprGetVarList(obj);
+ if(vars == NULL)
+ return EXPR_ERROR_NOVARLIST;
+
+ /* Get variable address */
+ exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+ if(addr == NULL)
+ {
+ /* Add variable to list */
+ exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
+
+ /* Try to get address again */
+ exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+ if(addr == NULL)
+ return EXPR_ERROR_MEMORY; /* Could not add variable */
+ }
+
+ /* Set reference item */
+ reftmp[refcur] = addr;
+
+ /* increase ref arg number and lv position*/
+ refcur++;
+ lv = pos + 1;
+ }
+ else
+ {
+ err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, pos - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+
+ /* increase arg number and lv position*/
+ lv = pos + 1;
+ cur++;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /* lv should point after the last comma, or open paren. if only 1 arg */
+ if(tokens[lv].type == EXPR_TOKEN_AMPERSAND)
+ {
+ if(lv != p2 - 2)
+ {
+ obj->starterr = tokens[lv].start;
+ obj->enderr = tokens[p2].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* It is a reference */
+ if(tokens[lv + 1].type != EXPR_TOKEN_IDENTIFIER)
+ {
+ obj->starterr = tokens[lv].start;
+ obj->enderr = tokens[lv + 1].end;
+ return EXPR_ERROR_SYNTAX;
+ }
+
+ /* Make sure it is not a constant */
+ vars = exprGetConstList(obj);
+ if(vars)
+ {
+ exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+ if(addr)
+ {
+ obj->starterr = tokens[lv].start;
+ obj->enderr = tokens[lv + 1].start;
+ return EXPR_ERROR_REFCONSTANT;
+ }
+ }
+
+ /* Get variable list */
+ vars = exprGetVarList(obj);
+ if(vars == NULL)
+ return EXPR_ERROR_NOVARLIST;
+
+ /* Get variable address */
+ exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+ if(addr == NULL)
+ {
+ /* Add variable to list */
+ exprValListAdd(vars, tokens[lv + 1].data.str, 0.0);
+
+ /* Try to get address again */
+ exprValListGetAddress(vars, tokens[lv + 1].data.str, &addr);
+ if(addr == NULL)
+ return EXPR_ERROR_MEMORY; /* Could not add variable */
+ }
+
+ /* Set reference item */
+ reftmp[refcur] = addr;
+ }
+ else
+ {
+ err = exprInternalParse(obj, &(tmp[cur]), tokens, lv, p2 - 1);
+ if(err != EXPR_ERROR_NOERROR)
+ return err;
+ }
+ }
+
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Parse a variable or value */
+int exprInternalParseVarVal(exprObj *obj, exprNode *node, exprToken *tokens, int start, int end)
+ {
+ exprValList *l;
+ EXPRTYPE *addr;
+
+
+ /* Make sure positions are correct */
+ if(start != end)
+ {
+ return EXPR_ERROR_UNKNOWN;
+ }
+
+
+ /* Are we an identifier */
+ if(tokens[start].type == EXPR_TOKEN_IDENTIFIER)
+ {
+ /* we are an identifier */
+
+ /* check to see if it is a constant */
+ l = exprGetConstList(obj);
+ if(l != NULL)
+ {
+ if(exprValListGetAddress(l, tokens[start].data.str, &addr) == EXPR_ERROR_NOERROR)
+ {
+ /* We found it in the constant list */
+
+ /*
+ Treat is like a variable node so application can change
+ constant value and it will reflect in expression
+ */
+
+ node->type = EXPR_NODETYPE_VARIABLE;
+ node->data.variable.vaddr = addr;
+ return EXPR_ERROR_NOERROR;
+ }
+ }
+
+ /* Not found in the constant list, so it must be a variable */
+
+ /* Set node type */
+ node->type = EXPR_NODETYPE_VARIABLE;
+
+ /*
+ The fast access method directly accesses the memory address
+ of the variable's value at evaluation time. Because of this,
+ we must make sure the variable does exists in the variable list.
+ */
+
+ /* Get the variable list */
+ l = exprGetVarList(obj);
+ if(l == NULL)
+ return EXPR_ERROR_NOVARLIST;
+
+ /* Get variable address if already in the list */
+ exprValListGetAddress(l, tokens[start].data.str, &addr);
+ if(addr == NULL) /* Variable not in the list, add it */
+ {
+ exprValListAdd(l, tokens[start].data.str, 0.0);
+
+ /* Try to get address again */
+ exprValListGetAddress(l, tokens[start].data.str, &addr);
+ if(addr == NULL) /* Could not add variable */
+ return EXPR_ERROR_MEMORY; /* Could not add variable to list */
+ }
+
+ node->data.variable.vaddr = addr;
+
+ return EXPR_ERROR_NOERROR;
+ }
+ else if(tokens[start].type == EXPR_TOKEN_VALUE)
+ {
+ /* we are a value */
+ node->type = EXPR_NODETYPE_VALUE;
+ node->data.value.value = tokens[start].data.val;
+ return EXPR_ERROR_NOERROR;
+ }
+ else
+ {
+ obj->starterr = tokens[start].start;
+ obj->enderr = tokens[end].end;
+ return EXPR_ERROR_UNKNOWN;
+ }
+ }
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h Tue Nov 13 15:23:26 2007
@@ -1,215 +1,215 @@
-/*
- File: exprpriv.h
- Auth: Brian Allen Vanderburg II
- Date: Tuesday, February 28, 2006
- Desc: Private include file for ExprEval library
-
- This file is part of ExprEval.
-*/
-
-
-/* Include once */
-#ifndef __BAVII_EXPRPRIV_H
-#define __BAVII_EXPRPRIV_H
-
-/* Need some definitions, NULL, etc */
-#include <stddef.h>
-
-/* Include config and main expreval header */
-#include "expreval.h"
-#include "exprconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- Version number
-*/
-#define EXPR_VERSIONMAJOR 2
-#define EXPR_VERSIONMINOR 7
-
-/* Node types */
-enum
- {
- EXPR_NODETYPE_UNKNOWN = 0,
- EXPR_NODETYPE_MULTI,
- EXPR_NODETYPE_ADD,
- EXPR_NODETYPE_SUBTRACT,
- EXPR_NODETYPE_MULTIPLY,
- EXPR_NODETYPE_DIVIDE,
- EXPR_NODETYPE_EXPONENT,
- EXPR_NODETYPE_NEGATE,
- EXPR_NODETYPE_VALUE,
- EXPR_NODETYPE_VARIABLE,
- EXPR_NODETYPE_ASSIGN,
- EXPR_NODETYPE_FUNCTION
- };
-
-/* Functions can be evaluated directly in EXPREVAL. If fptr
- is NULL, type is used to determine what the function is */
-enum
- {
- EXPR_NODEFUNC_UNKNOWN = 0,
- EXPR_NODEFUNC_ABS,
- EXPR_NODEFUNC_MOD,
- EXPR_NODEFUNC_IPART,
- EXPR_NODEFUNC_FPART,
- EXPR_NODEFUNC_MIN,
- EXPR_NODEFUNC_MAX,
- EXPR_NODEFUNC_POW,
- EXPR_NODEFUNC_SQRT,
- EXPR_NODEFUNC_SIN,
- EXPR_NODEFUNC_SINH,
- EXPR_NODEFUNC_ASIN,
- EXPR_NODEFUNC_COS,
- EXPR_NODEFUNC_COSH,
- EXPR_NODEFUNC_ACOS,
- EXPR_NODEFUNC_TAN,
- EXPR_NODEFUNC_TANH,
- EXPR_NODEFUNC_ATAN,
- EXPR_NODEFUNC_ATAN2,
- EXPR_NODEFUNC_LOG,
- EXPR_NODEFUNC_POW10,
- EXPR_NODEFUNC_LN,
- EXPR_NODEFUNC_EXP,
- EXPR_NODEFUNC_LOGN,
- EXPR_NODEFUNC_CEIL,
- EXPR_NODEFUNC_FLOOR,
- EXPR_NODEFUNC_RAND,
- EXPR_NODEFUNC_RANDOM,
- EXPR_NODEFUNC_RANDOMIZE,
- EXPR_NODEFUNC_DEG,
- EXPR_NODEFUNC_RAD,
- EXPR_NODEFUNC_RECTTOPOLR,
- EXPR_NODEFUNC_RECTTOPOLA,
- EXPR_NODEFUNC_POLTORECTX,
- EXPR_NODEFUNC_POLTORECTY,
- EXPR_NODEFUNC_IF,
- EXPR_NODEFUNC_SELECT,
- EXPR_NODEFUNC_EQUAL,
- EXPR_NODEFUNC_ABOVE,
- EXPR_NODEFUNC_BELOW,
- EXPR_NODEFUNC_AVG,
- EXPR_NODEFUNC_CLIP,
- EXPR_NODEFUNC_CLAMP,
- EXPR_NODEFUNC_PNTCHANGE,
- EXPR_NODEFUNC_POLY,
- EXPR_NODEFUNC_AND,
- EXPR_NODEFUNC_OR,
- EXPR_NODEFUNC_NOT,
- EXPR_NODEFUNC_FOR,
- EXPR_NODEFUNC_MANY
- };
-
-/* Forward declarations */
-typedef struct _exprFunc exprFunc;
-typedef struct _exprVal exprVal;
-
-/* Expression object */
-struct _exprObj
- {
- struct _exprFuncList *flist; /* Functions */
- struct _exprValList *vlist; /* Variables */
- struct _exprValList *clist; /* Constants */
- struct _exprNode *headnode; /* Head parsed node */
-
- exprBreakFuncType breakerfunc; /* Break function type */
-
- void *userdata; /* User data, can be any 32 bit value */
- int parsedgood; /* non-zero if successfully parsed */
- int parsedbad; /* non-zero if parsed but unsuccessful */
- int breakcount; /* how often to check the breaker function */
- int breakcur; /* do we check the breaker function yet */
- int starterr; /* start position of an error */
- int enderr; /* end position of an error */
- };
-
-/* Object for a function */
-struct _exprFunc
- {
- char *fname; /* Name of the function */
- exprFuncType fptr; /* Function pointer */
- int min, max; /* Min and max args for the function. */
- int refmin, refmax; /* Min and max ref. variables for the function */
- int type; /* Function node type. exprEvalNOde solves the function */
-
- struct _exprFunc *next; /* For linked list */
- };
-
-/* Function list object */
-struct _exprFuncList
- {
- struct _exprFunc *head;
- };
-
-/* Object for values */
-struct _exprVal
- {
- char *vname; /* Name of the value */
- EXPRTYPE vval; /* Value of the value */
- EXPRTYPE *vptr; /* Pointer to a value. Used only if not NULL */
-
- struct _exprVal *next; /* For linked list */
- };
-
-/* Value list */
-struct _exprValList
- {
- struct _exprVal *head;
- };
-
-/* Expression node type */
-struct _exprNode
- {
- int type; /* Node type */
-
- union _data /* Union of info for various types */
- {
- struct _oper
- {
- struct _exprNode *nodes; /* Operation arguments */
- int nodecount; /* Number of arguments */
- } oper;
-
- struct _variable
- {
- EXPRTYPE *vaddr; /* Used if EXPR_FAST_VAR_ACCESS defined */
- } variable;
-
- struct _value
- {
- EXPRTYPE value; /* Value if type is value */
- } value;
-
- struct _assign /* Assignment struct */
- {
- EXPRTYPE *vaddr; /* Used if EXPR_FAST_VAR_ACCESS defined */
- struct _exprNode *node; /* Node to evaluate */
- } assign;
-
- struct _function
- {
- exprFuncType fptr; /* Function pointer */
- struct _exprNode *nodes; /* Array of argument nodes */
- int nodecount; /* Number of argument nodes */
- EXPRTYPE **refs; /* Reference variables */
- int refcount; /* Number of variable references (not a reference counter) */
- int type; /* Type of function for exprEvalNode if fptr is NULL */
- } function;
- } data;
- };
-
-
-
-/* Functions for function lists */
-int exprFuncListAddType(exprFuncList *flist, char *name, int type, int min, int max, int refmin, int refmax);
-int exprFuncListGet(exprFuncList *flist, char *name, exprFuncType *ptr, int *type, int *min, int *max, int *refmin, int *refmax);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __BAVII_EXPRPRIV_H */
-
+/*
+ File: exprpriv.h
+ Auth: Brian Allen Vanderburg II
+ Date: Tuesday, February 28, 2006
+ Desc: Private include file for ExprEval library
+
+ This file is part of ExprEval.
+*/
+
+
+/* Include once */
+#ifndef __BAVII_EXPRPRIV_H
+#define __BAVII_EXPRPRIV_H
+
+/* Need some definitions, NULL, etc */
+#include <stddef.h>
+
+/* Include config and main expreval header */
+#include "expreval.h"
+#include "exprconf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ Version number
+*/
+#define EXPR_VERSIONMAJOR 2
+#define EXPR_VERSIONMINOR 7
+
+/* Node types */
+enum
+ {
+ EXPR_NODETYPE_UNKNOWN = 0,
+ EXPR_NODETYPE_MULTI,
+ EXPR_NODETYPE_ADD,
+ EXPR_NODETYPE_SUBTRACT,
+ EXPR_NODETYPE_MULTIPLY,
+ EXPR_NODETYPE_DIVIDE,
+ EXPR_NODETYPE_EXPONENT,
+ EXPR_NODETYPE_NEGATE,
+ EXPR_NODETYPE_VALUE,
+ EXPR_NODETYPE_VARIABLE,
+ EXPR_NODETYPE_ASSIGN,
+ EXPR_NODETYPE_FUNCTION
+ };
+
+/* Functions can be evaluated directly in EXPREVAL. If fptr
+ is NULL, type is used to determine what the function is */
+enum
+ {
+ EXPR_NODEFUNC_UNKNOWN = 0,
+ EXPR_NODEFUNC_ABS,
+ EXPR_NODEFUNC_MOD,
+ EXPR_NODEFUNC_IPART,
+ EXPR_NODEFUNC_FPART,
+ EXPR_NODEFUNC_MIN,
+ EXPR_NODEFUNC_MAX,
+ EXPR_NODEFUNC_POW,
+ EXPR_NODEFUNC_SQRT,
+ EXPR_NODEFUNC_SIN,
+ EXPR_NODEFUNC_SINH,
+ EXPR_NODEFUNC_ASIN,
+ EXPR_NODEFUNC_COS,
+ EXPR_NODEFUNC_COSH,
+ EXPR_NODEFUNC_ACOS,
+ EXPR_NODEFUNC_TAN,
+ EXPR_NODEFUNC_TANH,
+ EXPR_NODEFUNC_ATAN,
+ EXPR_NODEFUNC_ATAN2,
+ EXPR_NODEFUNC_LOG,
+ EXPR_NODEFUNC_POW10,
+ EXPR_NODEFUNC_LN,
+ EXPR_NODEFUNC_EXP,
+ EXPR_NODEFUNC_LOGN,
+ EXPR_NODEFUNC_CEIL,
+ EXPR_NODEFUNC_FLOOR,
+ EXPR_NODEFUNC_RAND,
+ EXPR_NODEFUNC_RANDOM,
+ EXPR_NODEFUNC_RANDOMIZE,
+ EXPR_NODEFUNC_DEG,
+ EXPR_NODEFUNC_RAD,
+ EXPR_NODEFUNC_RECTTOPOLR,
+ EXPR_NODEFUNC_RECTTOPOLA,
+ EXPR_NODEFUNC_POLTORECTX,
+ EXPR_NODEFUNC_POLTORECTY,
+ EXPR_NODEFUNC_IF,
+ EXPR_NODEFUNC_SELECT,
+ EXPR_NODEFUNC_EQUAL,
+ EXPR_NODEFUNC_ABOVE,
+ EXPR_NODEFUNC_BELOW,
+ EXPR_NODEFUNC_AVG,
+ EXPR_NODEFUNC_CLIP,
+ EXPR_NODEFUNC_CLAMP,
+ EXPR_NODEFUNC_PNTCHANGE,
+ EXPR_NODEFUNC_POLY,
+ EXPR_NODEFUNC_AND,
+ EXPR_NODEFUNC_OR,
+ EXPR_NODEFUNC_NOT,
+ EXPR_NODEFUNC_FOR,
+ EXPR_NODEFUNC_MANY
+ };
+
+/* Forward declarations */
+typedef struct _exprFunc exprFunc;
+typedef struct _exprVal exprVal;
+
+/* Expression object */
+struct _exprObj
+ {
+ struct _exprFuncList *flist; /* Functions */
+ struct _exprValList *vlist; /* Variables */
+ struct _exprValList *clist; /* Constants */
+ struct _exprNode *headnode; /* Head parsed node */
+
+ exprBreakFuncType breakerfunc; /* Break function type */
+
+ void *userdata; /* User data, can be any 32 bit value */
+ int parsedgood; /* non-zero if successfully parsed */
+ int parsedbad; /* non-zero if parsed but unsuccessful */
+ int breakcount; /* how often to check the breaker function */
+ int breakcur; /* do we check the breaker function yet */
+ int starterr; /* start position of an error */
+ int enderr; /* end position of an error */
+ };
+
+/* Object for a function */
+struct _exprFunc
+ {
+ char *fname; /* Name of the function */
+ exprFuncType fptr; /* Function pointer */
+ int min, max; /* Min and max args for the function. */
+ int refmin, refmax; /* Min and max ref. variables for the function */
+ int type; /* Function node type. exprEvalNOde solves the function */
+
+ struct _exprFunc *next; /* For linked list */
+ };
+
+/* Function list object */
+struct _exprFuncList
+ {
+ struct _exprFunc *head;
+ };
+
+/* Object for values */
+struct _exprVal
+ {
+ char *vname; /* Name of the value */
+ EXPRTYPE vval; /* Value of the value */
+ EXPRTYPE *vptr; /* Pointer to a value. Used only if not NULL */
+
+ struct _exprVal *next; /* For linked list */
+ };
+
+/* Value list */
+struct _exprValList
+ {
+ struct _exprVal *head;
+ };
+
+/* Expression node type */
+struct _exprNode
+ {
+ int type; /* Node type */
+
+ union _data /* Union of info for various types */
+ {
+ struct _oper
+ {
+ struct _exprNode *nodes; /* Operation arguments */
+ int nodecount; /* Number of arguments */
+ } oper;
+
+ struct _variable
+ {
+ EXPRTYPE *vaddr; /* Used if EXPR_FAST_VAR_ACCESS defined */
+ } variable;
+
+ struct _value
+ {
+ EXPRTYPE value; /* Value if type is value */
+ } value;
+
+ struct _assign /* Assignment struct */
+ {
+ EXPRTYPE *vaddr; /* Used if EXPR_FAST_VAR_ACCESS defined */
+ struct _exprNode *node; /* Node to evaluate */
+ } assign;
+
+ struct _function
+ {
+ exprFuncType fptr; /* Function pointer */
+ struct _exprNode *nodes; /* Array of argument nodes */
+ int nodecount; /* Number of argument nodes */
+ EXPRTYPE **refs; /* Reference variables */
+ int refcount; /* Number of variable references (not a reference counter) */
+ int type; /* Type of function for exprEvalNode if fptr is NULL */
+ } function;
+ } data;
+ };
+
+
+
+/* Functions for function lists */
+int exprFuncListAddType(exprFuncList *flist, char *name, int type, int min, int max, int refmin, int refmax);
+int exprFuncListGet(exprFuncList *flist, char *name, exprFuncType *ptr, int *type, int *min, int *max, int *refmin, int *refmax);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BAVII_EXPRPRIV_H */
+
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprutil.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprutil.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprutil.c Tue Nov 13 15:23:26 2007
@@ -1,43 +1,43 @@
-/*
- File: exprutil.c
- Auth: Brian Allen Vanderburg II
- Date: Monday, April 28, 2003
- Desc: Utility functions for use by this library
-
- This file is part of ExprEval.
-*/
-
-/* Include files */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-
-
-/* Return the version number */
-void exprGetVersion(int *major, int *minor)
- {
- *major = EXPR_VERSIONMAJOR;
- *minor = EXPR_VERSIONMINOR;
- }
-
-/* This utility function determines if an identifier is valid */
-int exprValidIdent(char *name)
- {
- if(name == NULL) /* Null string */
- return 0;
-
- /* First must be letter or underscore */
- if(isalpha(*name) || *name == '_')
- name++; /* Point to next letter */
- else
- return 0; /* Not letter or underscore, maybe empty*/
-
- /* others can be letter, number, or underscore */
- while(isalnum(*name) || *name == '_')
- name++;
-
- /* When the while breaks out, we should be at the end */
- return (*name == '\0') ? 1 : 0;
- }
-
-
+/*
+ File: exprutil.c
+ Auth: Brian Allen Vanderburg II
+ Date: Monday, April 28, 2003
+ Desc: Utility functions for use by this library
+
+ This file is part of ExprEval.
+*/
+
+/* Include files */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+
+
+/* Return the version number */
+void exprGetVersion(int *major, int *minor)
+ {
+ *major = EXPR_VERSIONMAJOR;
+ *minor = EXPR_VERSIONMINOR;
+ }
+
+/* This utility function determines if an identifier is valid */
+int exprValidIdent(char *name)
+ {
+ if(name == NULL) /* Null string */
+ return 0;
+
+ /* First must be letter or underscore */
+ if(isalpha(*name) || *name == '_')
+ name++; /* Point to next letter */
+ else
+ return 0; /* Not letter or underscore, maybe empty*/
+
+ /* others can be letter, number, or underscore */
+ while(isalnum(*name) || *name == '_')
+ name++;
+
+ /* When the while breaks out, we should be at the end */
+ return (*name == '\0') ? 1 : 0;
+ }
+
+
Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprval.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_expr/exprval.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprval.c Tue Nov 13 15:23:26 2007
@@ -1,395 +1,395 @@
-/*
- File: exprval.c
- Auth: Brian Allen Vanderburg II
- Date: Thursday, April 24, 2003
- Desc: Value lists for variables and constants
-
- This file is part of ExprEval.
-*/
-
-/* Includes */
-#include "exprincl.h"
-
-#include "exprpriv.h"
-#include "exprmem.h"
-
-
-/* Internal functions */
-static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE *addr);
-static void exprValListFreeData(exprVal *val);
-static void exprValListResetData(exprVal *val);
-
-/* This function creates the value list, */
-int exprValListCreate(exprValList **vlist)
- {
- exprValList *tmp;
-
- if(vlist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- *vlist = NULL; /* Set to NULL initially */
-
- tmp = exprAllocMem(sizeof(exprValList));
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY; /* Could not allocate memory */
-
- /* Update pointer */
- *vlist = tmp;
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Add a value to the list */
-int exprValListAdd(exprValList *vlist, char *name, EXPRTYPE val)
- {
- exprVal *tmp;
- exprVal *cur;
- int result;
-
- if(vlist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Make sure the name is valid */
- if(!exprValidIdent(name))
- return EXPR_ERROR_BADIDENTIFIER;
-
- if(vlist->head == NULL)
- {
- /* Create the node right here */
- tmp = exprCreateVal(name, val, NULL);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- vlist->head = tmp;
- return EXPR_ERROR_NOERROR;
- }
-
- /* See if already exists */
- cur = vlist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->vname);
-
- if(result == 0)
- return EXPR_ERROR_ALREADYEXISTS;
-
- cur = cur->next;
- }
-
- /* We did not find it, create it and add it to the beginning */
- tmp = exprCreateVal(name, val, NULL);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- tmp->next = vlist->head;
- vlist->head = tmp;
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Set a value in the list */
-int exprValListSet(exprValList *vlist, char *name, EXPRTYPE val)
- {
- exprVal *cur;
- int result;
-
- if(vlist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- if(name == NULL || name[0] == '\0')
- return EXPR_ERROR_NOTFOUND;
-
- /* Find and set it */
- cur = vlist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->vname);
-
- if(result == 0)
- {
- if(cur->vptr)
- *(cur->vptr) = val;
- else
- cur->vval = val;
-
- return EXPR_ERROR_NOERROR;
- }
-
- cur = cur->next;
- }
-
- return EXPR_ERROR_NOTFOUND;
- }
-
-/* Get the value from a list */
-int exprValListGet(exprValList *vlist, char *name, EXPRTYPE *val)
- {
- exprVal *cur;
- int result;
-
- if(vlist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- if(name == NULL || name[0] == '\0')
- return EXPR_ERROR_NOTFOUND;
-
- /* Search for the item */
- cur = vlist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->vname);
-
- if(result == 0)
- {
- /* We found it. */
- if(cur->vptr)
- *val = *(cur->vptr);
- else
- *val = cur->vval;
-
- /* return now */
- return EXPR_ERROR_NOERROR;
- }
-
- cur = cur->next;
- }
-
- /* If we got here, we did not find the item in the list */
- return EXPR_ERROR_NOTFOUND;
- }
-
-/* Add an address to the list */
-int exprValListAddAddress(exprValList *vlist, char *name, EXPRTYPE *addr)
- {
- exprVal *tmp;
- exprVal *cur;
- int result;
-
- if(vlist == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
- /* Make sure the name is valid */
- if(!exprValidIdent(name))
- return EXPR_ERROR_BADIDENTIFIER;
-
- if(vlist->head == NULL)
- {
- /* Create the node right here */
- tmp = exprCreateVal(name, (EXPRTYPE)0.0, addr);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- vlist->head = tmp;
- return EXPR_ERROR_NOERROR;
- }
-
- /* See if it already exists */
- cur = vlist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->vname);
-
- if(result == 0)
- return EXPR_ERROR_ALREADYEXISTS;
-
- cur = cur->next;
- }
-
- /* Add it to the list */
- tmp = exprCreateVal(name, (EXPRTYPE)0.0, addr);
-
- if(tmp == NULL)
- return EXPR_ERROR_MEMORY;
-
- tmp->next = vlist->head;
- vlist->head = tmp;
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* Get memory address of a variable value in a value list */
-int exprValListGetAddress(exprValList *vlist, char *name, EXPRTYPE **addr)
- {
- exprVal *cur;
- int result;
-
- /* Not found yet */
- *addr = NULL;
-
- if(vlist == NULL || addr == NULL)
- return EXPR_ERROR_NULLPOINTER;
-
-
- if(name == NULL || name[0] == '\0')
- return EXPR_ERROR_NOTFOUND;
-
- /* Search for the item */
- cur = vlist->head;
-
- while(cur)
- {
- result = strcmp(name, cur->vname);
-
- if(result == 0)
- {
- /* We found it. */
- if(cur->vptr)
- *addr = cur->vptr;
- else
- *addr = &(cur->vval);
-
- /* return now */
- return EXPR_ERROR_NOERROR;
- }
-
- cur = cur->next;
- }
-
- /* If we got here, we did not find it in the list */
- return EXPR_ERROR_NOTFOUND;
- }
-
-/* This function is used to enumerate the values in a value list */
-void *exprValListGetNext(exprValList *vlist, char **name, EXPRTYPE *value, EXPRTYPE** addr, void *cookie)
- {
- exprVal *cur;
-
- if(vlist == NULL)
- return NULL;
-
- /* Get the current item */
- cur = (exprVal*)cookie;
-
- /* Find the next item */
- if(cur == NULL)
- cur = vlist->head;
- else
- cur = cur->next;
-
- /* Set up the data */
- if(cur)
- {
- if(name)
- *name = cur->vname;
-
- if(value)
- {
- if(cur->vptr)
- *value = *(cur->vptr);
- else
- *value = cur->vval;
- }
-
- if(addr)
- {
- if(cur->vptr)
- *addr = cur->vptr;
- else
- *addr = &(cur->vval);
- }
- }
-
- /* If there was no value, return NULL, otherwise, return the item */
- return (void*)cur;
- }
-
-/* This routine will free the value list */
-int exprValListFree(exprValList *vlist)
- {
- /* Make sure it exists, if not it is not error */
- if(vlist == NULL)
- return EXPR_ERROR_NOERROR;
-
- /* Free the nodes */
- exprValListFreeData(vlist->head);
-
- /* Freethe container */
- exprFreeMem(vlist);
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* This routine will reset the value list to 0.0 */
-int exprValListClear(exprValList *vlist)
- {
- if(vlist == NULL)
- return EXPR_ERROR_NOERROR;
-
- exprValListResetData(vlist->head);
-
- return EXPR_ERROR_NOERROR;
- }
-
-/* This routine will free any child nodes, and then free itself */
-static void exprValListFreeData(exprVal *val)
- {
- exprVal *next;
-
- while(val)
- {
- /* Remember the next */
- next = val->next;
-
- /* Free name */
- exprFreeMem(val->vname);
-
- /* Free ourself */
- exprFreeMem(val);
-
- val = next;
- }
- }
-
-/* This routine will reset variables to 0.0 */
-static void exprValListResetData(exprVal *val)
- {
- while(val)
- {
- /* Reset data */
- if(val->vptr)
- *(val->vptr) = 0.0;
-
- val->vval = 0.0;
-
- val = val->next;
- }
- }
-
-/* This routine will create the value object */
-static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE *addr)
- {
- exprVal *tmp;
- char *vtmp;
-
- /* Name already tested in exprValListAdd */
-
- /* Create it */
- tmp = exprAllocMem(sizeof(exprVal));
- if(tmp == NULL)
- return NULL;
-
- /* Allocate space for the name */
- vtmp = exprAllocMem(strlen(name) + 1);
-
- if(vtmp == NULL)
- {
- exprFreeMem(tmp);
- return NULL;
- }
-
- /* Copy the data over */
- strcpy(vtmp, name);
- tmp->vname = vtmp;
- tmp->vval = val;
- tmp->vptr = addr;
-
- return tmp;
- }
+/*
+ File: exprval.c
+ Auth: Brian Allen Vanderburg II
+ Date: Thursday, April 24, 2003
+ Desc: Value lists for variables and constants
+
+ This file is part of ExprEval.
+*/
+
+/* Includes */
+#include "exprincl.h"
+
+#include "exprpriv.h"
+#include "exprmem.h"
+
+
+/* Internal functions */
+static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE *addr);
+static void exprValListFreeData(exprVal *val);
+static void exprValListResetData(exprVal *val);
+
+/* This function creates the value list, */
+int exprValListCreate(exprValList **vlist)
+ {
+ exprValList *tmp;
+
+ if(vlist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ *vlist = NULL; /* Set to NULL initially */
+
+ tmp = exprAllocMem(sizeof(exprValList));
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY; /* Could not allocate memory */
+
+ /* Update pointer */
+ *vlist = tmp;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Add a value to the list */
+int exprValListAdd(exprValList *vlist, char *name, EXPRTYPE val)
+ {
+ exprVal *tmp;
+ exprVal *cur;
+ int result;
+
+ if(vlist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Make sure the name is valid */
+ if(!exprValidIdent(name))
+ return EXPR_ERROR_BADIDENTIFIER;
+
+ if(vlist->head == NULL)
+ {
+ /* Create the node right here */
+ tmp = exprCreateVal(name, val, NULL);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ vlist->head = tmp;
+ return EXPR_ERROR_NOERROR;
+ }
+
+ /* See if already exists */
+ cur = vlist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->vname);
+
+ if(result == 0)
+ return EXPR_ERROR_ALREADYEXISTS;
+
+ cur = cur->next;
+ }
+
+ /* We did not find it, create it and add it to the beginning */
+ tmp = exprCreateVal(name, val, NULL);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ tmp->next = vlist->head;
+ vlist->head = tmp;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Set a value in the list */
+int exprValListSet(exprValList *vlist, char *name, EXPRTYPE val)
+ {
+ exprVal *cur;
+ int result;
+
+ if(vlist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ if(name == NULL || name[0] == '\0')
+ return EXPR_ERROR_NOTFOUND;
+
+ /* Find and set it */
+ cur = vlist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->vname);
+
+ if(result == 0)
+ {
+ if(cur->vptr)
+ *(cur->vptr) = val;
+ else
+ cur->vval = val;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+ cur = cur->next;
+ }
+
+ return EXPR_ERROR_NOTFOUND;
+ }
+
+/* Get the value from a list */
+int exprValListGet(exprValList *vlist, char *name, EXPRTYPE *val)
+ {
+ exprVal *cur;
+ int result;
+
+ if(vlist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ if(name == NULL || name[0] == '\0')
+ return EXPR_ERROR_NOTFOUND;
+
+ /* Search for the item */
+ cur = vlist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->vname);
+
+ if(result == 0)
+ {
+ /* We found it. */
+ if(cur->vptr)
+ *val = *(cur->vptr);
+ else
+ *val = cur->vval;
+
+ /* return now */
+ return EXPR_ERROR_NOERROR;
+ }
+
+ cur = cur->next;
+ }
+
+ /* If we got here, we did not find the item in the list */
+ return EXPR_ERROR_NOTFOUND;
+ }
+
+/* Add an address to the list */
+int exprValListAddAddress(exprValList *vlist, char *name, EXPRTYPE *addr)
+ {
+ exprVal *tmp;
+ exprVal *cur;
+ int result;
+
+ if(vlist == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+ /* Make sure the name is valid */
+ if(!exprValidIdent(name))
+ return EXPR_ERROR_BADIDENTIFIER;
+
+ if(vlist->head == NULL)
+ {
+ /* Create the node right here */
+ tmp = exprCreateVal(name, (EXPRTYPE)0.0, addr);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ vlist->head = tmp;
+ return EXPR_ERROR_NOERROR;
+ }
+
+ /* See if it already exists */
+ cur = vlist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->vname);
+
+ if(result == 0)
+ return EXPR_ERROR_ALREADYEXISTS;
+
+ cur = cur->next;
+ }
+
+ /* Add it to the list */
+ tmp = exprCreateVal(name, (EXPRTYPE)0.0, addr);
+
+ if(tmp == NULL)
+ return EXPR_ERROR_MEMORY;
+
+ tmp->next = vlist->head;
+ vlist->head = tmp;
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* Get memory address of a variable value in a value list */
+int exprValListGetAddress(exprValList *vlist, char *name, EXPRTYPE **addr)
+ {
+ exprVal *cur;
+ int result;
+
+ /* Not found yet */
+ *addr = NULL;
+
+ if(vlist == NULL || addr == NULL)
+ return EXPR_ERROR_NULLPOINTER;
+
+
+ if(name == NULL || name[0] == '\0')
+ return EXPR_ERROR_NOTFOUND;
+
+ /* Search for the item */
+ cur = vlist->head;
+
+ while(cur)
+ {
+ result = strcmp(name, cur->vname);
+
+ if(result == 0)
+ {
+ /* We found it. */
+ if(cur->vptr)
+ *addr = cur->vptr;
+ else
+ *addr = &(cur->vval);
+
+ /* return now */
+ return EXPR_ERROR_NOERROR;
+ }
+
+ cur = cur->next;
+ }
+
+ /* If we got here, we did not find it in the list */
+ return EXPR_ERROR_NOTFOUND;
+ }
+
+/* This function is used to enumerate the values in a value list */
+void *exprValListGetNext(exprValList *vlist, char **name, EXPRTYPE *value, EXPRTYPE** addr, void *cookie)
+ {
+ exprVal *cur;
+
+ if(vlist == NULL)
+ return NULL;
+
+ /* Get the current item */
+ cur = (exprVal*)cookie;
+
+ /* Find the next item */
+ if(cur == NULL)
+ cur = vlist->head;
+ else
+ cur = cur->next;
+
+ /* Set up the data */
+ if(cur)
+ {
+ if(name)
+ *name = cur->vname;
+
+ if(value)
+ {
+ if(cur->vptr)
+ *value = *(cur->vptr);
+ else
+ *value = cur->vval;
+ }
+
+ if(addr)
+ {
+ if(cur->vptr)
+ *addr = cur->vptr;
+ else
+ *addr = &(cur->vval);
+ }
+ }
+
+ /* If there was no value, return NULL, otherwise, return the item */
+ return (void*)cur;
+ }
+
+/* This routine will free the value list */
+int exprValListFree(exprValList *vlist)
+ {
+ /* Make sure it exists, if not it is not error */
+ if(vlist == NULL)
+ return EXPR_ERROR_NOERROR;
+
+ /* Free the nodes */
+ exprValListFreeData(vlist->head);
+
+ /* Freethe container */
+ exprFreeMem(vlist);
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* This routine will reset the value list to 0.0 */
+int exprValListClear(exprValList *vlist)
+ {
+ if(vlist == NULL)
+ return EXPR_ERROR_NOERROR;
+
+ exprValListResetData(vlist->head);
+
+ return EXPR_ERROR_NOERROR;
+ }
+
+/* This routine will free any child nodes, and then free itself */
+static void exprValListFreeData(exprVal *val)
+ {
+ exprVal *next;
+
+ while(val)
+ {
+ /* Remember the next */
+ next = val->next;
+
+ /* Free name */
+ exprFreeMem(val->vname);
+
+ /* Free ourself */
+ exprFreeMem(val);
+
+ val = next;
+ }
+ }
+
+/* This routine will reset variables to 0.0 */
+static void exprValListResetData(exprVal *val)
+ {
+ while(val)
+ {
+ /* Reset data */
+ if(val->vptr)
+ *(val->vptr) = 0.0;
+
+ val->vval = 0.0;
+
+ val = val->next;
+ }
+ }
+
+/* This routine will create the value object */
+static exprVal *exprCreateVal(char *name, EXPRTYPE val, EXPRTYPE *addr)
+ {
+ exprVal *tmp;
+ char *vtmp;
+
+ /* Name already tested in exprValListAdd */
+
+ /* Create it */
+ tmp = exprAllocMem(sizeof(exprVal));
+ if(tmp == NULL)
+ return NULL;
+
+ /* Allocate space for the name */
+ vtmp = exprAllocMem(strlen(name) + 1);
+
+ if(vtmp == NULL)
+ {
+ exprFreeMem(tmp);
+ return NULL;
+ }
+
+ /* Copy the data over */
+ strcpy(vtmp, name);
+ tmp->vname = vtmp;
+ tmp->vval = val;
+ tmp->vptr = addr;
+
+ return tmp;
+ }
1
0
Author: mikej
Date: Tue Nov 13 15:06:22 2007
New Revision: 6241
Modified:
freeswitch/trunk/libs/libteletone/src/libteletone_generate.h
Log:
fix sun studio build
Modified: freeswitch/trunk/libs/libteletone/src/libteletone_generate.h
==============================================================================
--- freeswitch/trunk/libs/libteletone/src/libteletone_generate.h (original)
+++ freeswitch/trunk/libs/libteletone/src/libteletone_generate.h Tue Nov 13 15:06:22 2007
@@ -79,10 +79,18 @@
#include <stdio.h>
#include <stdlib.h>
+
+#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#ifndef __inline__
+#define __inline__ inline
+#endif
+#endif
+
#ifdef _MSC_VER
#ifndef __inline__
#define __inline__ __inline
#endif
+
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
1
0