diff options
author | Nathan Angelacos <nangel@alpinelinux.org> | 2011-05-10 01:22:50 +0000 |
---|---|---|
committer | Nathan Angelacos <nangel@alpinelinux.org> | 2011-05-10 01:22:50 +0000 |
commit | 1251e3c4b2b4845fc5a0ee01b56a6c2669437cad (patch) | |
tree | e0b55195cde4d5f2f4844132fdb286e2906c947e /src | |
parent | dd3a2d24cb75eb4c8f9c65dddd79e23546bf36b0 (diff) | |
download | haserl-1251e3c4b2b4845fc5a0ee01b56a6c2669437cad.tar.bz2 haserl-1251e3c4b2b4845fc5a0ee01b56a6c2669437cad.tar.xz |
0.9.29 candidate
Diffstat (limited to 'src')
-rw-r--r-- | src/common.c | 34 | ||||
-rw-r--r-- | src/common.h | 23 | ||||
-rw-r--r-- | src/h_bash.c | 29 | ||||
-rw-r--r-- | src/h_bash.h | 23 | ||||
-rw-r--r-- | src/h_error.c | 41 | ||||
-rw-r--r-- | src/h_error.h | 25 | ||||
-rw-r--r-- | src/h_lua.c | 28 | ||||
-rw-r--r-- | src/h_lua.h | 20 | ||||
-rw-r--r-- | src/h_lua_common.c | 27 | ||||
-rw-r--r-- | src/h_lua_common.h | 20 | ||||
-rw-r--r-- | src/h_luac.c | 41 | ||||
-rw-r--r-- | src/h_luac.h | 20 | ||||
-rw-r--r-- | src/h_script.c | 30 | ||||
-rw-r--r-- | src/h_script.h | 23 | ||||
-rw-r--r-- | src/haserl.c | 27 | ||||
-rw-r--r-- | src/haserl.h | 20 | ||||
-rw-r--r-- | src/haserl_lualib.lua | 39 | ||||
-rw-r--r-- | src/lua2c.c | 104 | ||||
-rw-r--r-- | src/rfc2388.c | 60 | ||||
-rw-r--r-- | src/rfc2388.h | 20 | ||||
-rw-r--r-- | src/sliding_buffer.c | 35 | ||||
-rw-r--r-- | src/sliding_buffer.h | 20 |
22 files changed, 471 insertions, 238 deletions
diff --git a/src/common.c b/src/common.c index 8362171..319891d 100644 --- a/src/common.c +++ b/src/common.c @@ -1,24 +1,22 @@ -/* - * -------------------------------------------------------------------------- - * Common library functions for the haserl suite - * Copyright (c) 2005-2007 Nathan Angelacos (nangel@users.sourceforge.net) +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 2, as published by the - * Free Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - * ------------------------------------------------------------------------- - */ - + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> #endif @@ -186,7 +184,7 @@ argc_argv (char *instr, argv_t ** argv, char *commentstr) ALLOC_CHUNK)); } - if (argv_array == NULL) + if (argv_array == NULL) { return (-1); } diff --git a/src/common.h b/src/common.h index b9ee5f3..1bc8210 100644 --- a/src/common.h +++ b/src/common.h @@ -1,6 +1,23 @@ -/* - * $Id: common.h,v 1.5 2005/11/21 22:05:34 nangel Exp $ - */ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef _COMMON_H #define _COMMON_H 1 diff --git a/src/h_bash.c b/src/h_bash.c index 8c9c64c..e955acd 100644 --- a/src/h_bash.c +++ b/src/h_bash.c @@ -1,21 +1,22 @@ -/*----------------------------------------------------------------- - * haserl functions specific to a bash/ash/dash shell - * Copyright (c) 2003-2007 Nathan Angelacos (nangel@users.sourceforge.net) +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 2, as published by the Free - * Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - ------------------------------------------------------------------------- */ + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> diff --git a/src/h_bash.h b/src/h_bash.h index d827aa6..a9314af 100644 --- a/src/h_bash.h +++ b/src/h_bash.h @@ -1,6 +1,23 @@ -/* - * $Id: haserl.h,v 1.14 2005/11/18 14:43:10 nangel Exp $ - */ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef H_SUBSHELL_H #define H_SUBSHELL_H 1 diff --git a/src/h_error.c b/src/h_error.c index 46bd6e1..0dcd638 100644 --- a/src/h_error.c +++ b/src/h_error.c @@ -1,23 +1,22 @@ -/* - * -------------------------------------------------------------------------- - * Error functions for haserl - * Copyright (c) 2003-2006 Nathan Angelacos (nangel@users.sourceforge.net) +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 2, as published by the Free - * Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - * ------------------------------------------------------------------------- - */ + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> @@ -66,9 +65,9 @@ die_with_error (char *msg) void die_with_message (void *sp, char *where, const char *s, ...) { - #ifndef JUST_LUACSHELL +#ifndef JUST_LUACSHELL script_t *script = sp; - #endif +#endif va_list p; FILE *fo = stderr; @@ -85,14 +84,14 @@ die_with_message (void *sp, char *where, const char *s, ...) va_start (p, s); vfprintf (fo, s, p); va_end (p); - #ifndef JUST_LUACSHELL +#ifndef JUST_LUACSHELL if (where && sp) - { + { fprintf (fo, " near line %d of %s\n", count_lines (script->buf, script->size, where), script->name); } - #endif +#endif printf ("\n"); if (getenv ("REQUEST_METHOD")) diff --git a/src/h_error.h b/src/h_error.h index af8d9aa..76a1496 100644 --- a/src/h_error.h +++ b/src/h_error.h @@ -1,6 +1,25 @@ -/* - * $Id: haserl.h,v 1.14 2005/11/18 14:43:10 nangel Exp $ - */ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + + + #ifndef H_ERROR_H #define H_ERROR_H 1 diff --git a/src/h_lua.c b/src/h_lua.c index 38d318e..e7fb2b4 100644 --- a/src/h_lua.c +++ b/src/h_lua.c @@ -1,21 +1,22 @@ /* -------------------------------------------------------------------------- - * lua language specific functions - * Copyright (c) 2003-2007 Nathan Angelacos (nangel@users.sourceforge.net) + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - ------------------------------------------------------------------------- */ + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> @@ -152,4 +153,3 @@ lua_eval (buffer_t * buf, char *str, size_t len) buffer_add (buf, str, len); buffer_add (buf, end, strlen (end)); } - diff --git a/src/h_lua.h b/src/h_lua.h index 1b1e8af..f85efdc 100644 --- a/src/h_lua.h +++ b/src/h_lua.h @@ -1,3 +1,23 @@ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef H_LUA_H #define H_LUA_H 1 diff --git a/src/h_lua_common.c b/src/h_lua_common.c index e29c97b..4230515 100644 --- a/src/h_lua_common.c +++ b/src/h_lua_common.c @@ -1,21 +1,22 @@ /* -------------------------------------------------------------------------- - * functions shared among both Lua shells - * Copyright (c) 2003-2007 Nathan Angelacos (nangel@users.sourceforge.net) + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - ------------------------------------------------------------------------- */ + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> diff --git a/src/h_lua_common.h b/src/h_lua_common.h index 18b0e68..ba59d92 100644 --- a/src/h_lua_common.h +++ b/src/h_lua_common.h @@ -1,3 +1,23 @@ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef _H_LUA_COMMON_H #define _H_LUA_COMMON_H diff --git a/src/h_luac.c b/src/h_luac.c index 55e4083..f98e0a5 100644 --- a/src/h_luac.c +++ b/src/h_luac.c @@ -1,21 +1,22 @@ /* -------------------------------------------------------------------------- - * lua language specific functions (for compiled Lua chunks) - * Copyright (c) 2003-2007 Nathan Angelacos (nangel@users.sourceforge.net) + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - ------------------------------------------------------------------------- */ + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> @@ -33,23 +34,25 @@ extern lua_State *lua_vm; /* tokenizer was not used, so script is NULL, but name is the filename to process */ void -luac_doscript (buffer_t *script, char *name) +luac_doscript (buffer_t * script, char *name) { - if (luaL_loadfile (lua_vm, name) || lua_pcall(lua_vm, 0, LUA_MULTRET, 0)) + if (luaL_loadfile (lua_vm, name) || lua_pcall (lua_vm, 0, LUA_MULTRET, 0)) { - die_with_message (NULL, NULL, "Cannot load lua and execute chunk: %s", lua_tostring(lua_vm, -1)); + die_with_message (NULL, NULL, "Cannot load lua and execute chunk: %s", + lua_tostring (lua_vm, -1)); } } int -h_luac_loadfile (lua_State *L) +h_luac_loadfile (lua_State * L) { const char *filename = luaL_checkstring (L, 1); if (luaL_loadfile (L, filename)) { - die_with_message (NULL, NULL, "Cannot load file '%s': %s", filename, lua_tostring(L, -1)); - } /* no error: function is on the stack */ + die_with_message (NULL, NULL, "Cannot load file '%s': %s", filename, + lua_tostring (L, -1)); + } /* no error: function is on the stack */ return 1; } diff --git a/src/h_luac.h b/src/h_luac.h index 37c6536..9502fdb 100644 --- a/src/h_luac.h +++ b/src/h_luac.h @@ -1,3 +1,23 @@ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef _H_LUAC_H #define _H_LUAC_H diff --git a/src/h_script.c b/src/h_script.c index 646be6e..534c672 100644 --- a/src/h_script.c +++ b/src/h_script.c @@ -1,22 +1,22 @@ -/*-------------------------------------------------------------------------- - * functions related to opening, tokenizing and parsing a haserl script - * Copyright (c) 2006-2007 Nathan Angelacos (nangel@users.sourceforge.net) +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - * - ------------------------------------------------------------------------- */ + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> diff --git a/src/h_script.h b/src/h_script.h index e1098fe..de49ff5 100644 --- a/src/h_script.h +++ b/src/h_script.h @@ -1,6 +1,23 @@ -/* - * $Id: haserl.h,v 1.14 2005/11/18 14:43:10 nangel Exp $ - */ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef H_SCRIPT_H #define H_SCRIPT_H 1 diff --git a/src/haserl.c b/src/haserl.c index 9d8a30f..22ac396 100644 --- a/src/haserl.c +++ b/src/haserl.c @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- - * core of haserl.cgi - a poor-man's php for embedded/lightweight environments - * Copyright (c) 2003-2011 Nathan Angelacos (nangel@users.sourceforge.net) + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 2, as published by the Free - * Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * * ----- * The x2c() and unescape_url() routines were taken from @@ -269,7 +270,7 @@ myputenv (list_t * cur, char *str, char *prefix) /* if an array, create a new string with this * value added to the end of the old value(s) */ - temp = xmalloc (strlen (cur->buf) + strlen (entry) - len + 1); + temp = xmalloc (strlen (cur->buf) + strlen (entry) - len + 2); memmove (temp, cur->buf, strlen (cur->buf) + 1); strcat (temp, "\n"); strcat (temp, str + keylen + 3); diff --git a/src/haserl.h b/src/haserl.h index 4fcfe8c..6791e74 100644 --- a/src/haserl.h +++ b/src/haserl.h @@ -1,3 +1,23 @@ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef _HASERL_H #define _HASERL_H 1 diff --git a/src/haserl_lualib.lua b/src/haserl_lualib.lua index 5360bd1..b3adfbe 100644 --- a/src/haserl_lualib.lua +++ b/src/haserl_lualib.lua @@ -1,21 +1,24 @@ --- -------------------------------------------------------------------------- --- haserl luascript library --- Copyright (c) 2003-2011 Nathan Angelacos (nangel@users.sourceforge.net) --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License, version 2, --- as published by the Free Software Foundation. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program; if not, write to the Free Software --- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --- --- -------------------------------------------------------------------------- +--[[ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ +]]-- haserl, FORM, ENV, COOKIE, HASERL, GET, POST = {}, {}, {}, {}, {}, {}, {} diff --git a/src/lua2c.c b/src/lua2c.c index f1f7abe..063ac20 100644 --- a/src/lua2c.c +++ b/src/lua2c.c @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- - * a simple lua 2 c function converter - a simple luac + bin2c - * Copyright (c) 2007 Nathan Angelacos (nangel@users.sourceforge.net) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, - * as published by the Free Software Foundation. + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * ------------------------------------------------------------------------- */ - + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ /* This program loads the source file, and then uses lua_dump to output it * to a c const char array. Because lua_dump is used instead of the internal @@ -47,51 +47,59 @@ static void loadit (char *filename) { -lua_vm = luaL_newstate(); -luaL_openlibs (lua_vm); + lua_vm = luaL_newstate (); + luaL_openlibs (lua_vm); + + if (luaL_loadfile (lua_vm, filename)) + { + puts (lua_tostring (lua_vm, -1)); + exit (-1); + } -if (luaL_loadfile(lua_vm, filename)) { - puts (lua_tostring(lua_vm, -1)); - exit (-1); - } - } -static int writer (lua_State* L, const void* p, size_t size, void* u) +static int +writer (lua_State * L, const void *p, size_t size, void *u) { - static int count = 0; - int i; - for (i=0; i < size; i++ ) { - if ((count) && (count % 16) == 0 ) printf ("\n "); - printf ("%3d,", *((unsigned char *) (p+i))); - count++; - } - - return (0); + static int count = 0; + int i; + for (i = 0; i < size; i++) + { + if ((count) && (count % 16) == 0) + printf ("\n "); + printf ("%3d,", *((unsigned char *) (p + i))); + count++; + } + + return (0); } -static void -dumpit() +static void +dumpit () { -lua_dump (lua_vm, writer, NULL); + lua_dump (lua_vm, writer, NULL); } int -main (int argc, char *argv[]) { - if (argc != 3) { - printf("usage: %s varname luasource >output\n", argv[0]); - return (-1); - } +main (int argc, char *argv[]) +{ + if (argc != 3) + { + printf ("usage: %s varname luasource >output\n", argv[0]); + return (-1); + } - loadit (argv[2]); + loadit (argv[2]); - printf ("/* This file was automatically generated from %s. DO NOT EDIT */\n\n", argv[2]); - printf ("static const unsigned char %s[] = { \n ", argv[1]); - dumpit(); - printf ("\n};\n"); + printf + ("/* This file was automatically generated from %s. DO NOT EDIT */\n\n", + argv[2]); + printf ("static const unsigned char %s[] = { \n ", argv[1]); + dumpit (); + printf ("\n};\n"); - return (0); + return (0); } diff --git a/src/rfc2388.c b/src/rfc2388.c index 0548868..32c21df 100644 --- a/src/rfc2388.c +++ b/src/rfc2388.c @@ -1,21 +1,23 @@ /* -------------------------------------------------------------------------- - * multipart/form-data handler functions (obviously, see rfc2388 for info) - * Copyright (c) 2007 Nathan Angelacos (nangel@users.sourceforge.net) + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 2, as published by the Free - * Software Foundation. + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. * - ------------------------------------------------------------------------- */ + * ------------------------------------------------------------------------ */ + #if HAVE_CONFIG_H #include <config.h> @@ -70,6 +72,7 @@ void mime_var_destroy (mime_var_t * obj) { int status; + struct sigaction new_action; if (obj->name) { @@ -94,10 +97,14 @@ mime_var_destroy (mime_var_t * obj) buffer_destroy (&(obj->value)); if (obj->fh) { - close (obj->fh); + close (abs (obj->fh)); if (global.uploadhandler) { wait (&status); + new_action.sa_handler = SIG_DFL; + sigemptyset (&new_action.sa_mask); + new_action.sa_flags = 0; + sigaction (SIGPIPE, &new_action, NULL); } obj->fh = 0; } @@ -205,6 +212,9 @@ mime_exec (mime_var_t * obj, char *fifo) char *type, *filename, *name; char *c; int fh; + struct sigaction new_action; + + pid = fork (); if (pid == -1) @@ -254,7 +264,11 @@ mime_exec (mime_var_t * obj, char *fifo) } else { - /* I'm parent */ + /* I'm parent - ignore SIGPIPE from the child */ + new_action.sa_handler = SIG_IGN; + sigemptyset (&new_action.sa_mask); + new_action.sa_flags = 0; + sigaction (SIGPIPE, &new_action, NULL); } /* control should get to this point only in the parent. @@ -298,7 +312,9 @@ mime_var_open_target (mime_var_t * obj) close (obj->fh); unlink (tmpname); if (mkfifo (tmpname, 0600)) - ok = 0; + { + ok = 0; + } /* you must open the fifo for reading before writing * on non linux systems */ @@ -336,6 +352,8 @@ mime_var_open_target (mime_var_t * obj) void mime_var_writer (mime_var_t * obj, char *str, int len) { + int err; + /* if not a file upload, then just a normal variable */ if (!obj->filename) { @@ -347,9 +365,15 @@ mime_var_writer (mime_var_t * obj, char *str, int len) mime_var_open_target (obj); /* if we have an open file, write the chunk */ - if (obj->fh) + if (obj->fh > 0) { - write (obj->fh, str, len); + err = write (obj->fh, str, len); + /* if there was an error, invert the filehandle; we need the + handle for later when we close it */ + if (err == -1) + { + obj->fh = abs (obj->fh) * -1; + } } } diff --git a/src/rfc2388.h b/src/rfc2388.h index acad1ac..a087960 100644 --- a/src/rfc2388.h +++ b/src/rfc2388.h @@ -1,3 +1,23 @@ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef _RFC2388_H #define _RFC2388_H 1 diff --git a/src/sliding_buffer.c b/src/sliding_buffer.c index 2b5ef33..f93ebe0 100644 --- a/src/sliding_buffer.c +++ b/src/sliding_buffer.c @@ -1,17 +1,22 @@ -/* - * -------------------------------------------------------------------------- - * Sliding Buffer functions for haserl Copyright (c) 2007 Nathan Angelacos - * (nangel@users.sourceforge.net) This program is free software; you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License, version 2, as published by the Free Software Foundation. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * ------------------------------------------------------------------------- - */ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ #if HAVE_CONFIG_H #include <config.h> @@ -100,7 +105,7 @@ s_buffer_read (sliding_buffer_t * sbuf, char *matchstr) else { size_t n = sbuf->maxsize - len; - if ( sbuf->maxread && sbuf->maxread < sbuf->nrread + n) + if (sbuf->maxread && sbuf->maxread < sbuf->nrread + n) n = sbuf->maxread - sbuf->nrread; r = read (sbuf->fh, sbuf->buf + len, n); } diff --git a/src/sliding_buffer.h b/src/sliding_buffer.h index 167e461..34f156b 100644 --- a/src/sliding_buffer.h +++ b/src/sliding_buffer.h @@ -1,3 +1,23 @@ +/* -------------------------------------------------------------------------- + * Copyright 2003-2011 (inclusive) Nathan Angelacos + * (nangel@users.sourceforge.net) + * + * This file is part of haserl. + * + * Haserl is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * Haserl is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with haserl. If not, see <http://www.gnu.org/licenses/>. + * + * ------------------------------------------------------------------------ */ + #ifndef _SLIDING_BUF_H #define _SLIDING_BUF_H 1 |