mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
C++ // comments are evil ...
This commit is contained in:
@@ -360,7 +360,7 @@ PHP_FUNCTION(cpdf_set_viewer_preferences) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
// cpdf_setViewerPreferences(pdf, pagemode, 0, 0, 0, 0, 0, 0, pagemode);
|
||||
/* cpdf_setViewerPreferences(pdf, pagemode, 0, 0, 0, 0, 0, 0, pagemode); */
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#if HAVE_MOD_DAV
|
||||
|
||||
#error The DAV support in PHP needs to be completely rewritten. Everything has changed
|
||||
|
||||
# include "mod_dav.h"
|
||||
#include "ext/standard/info.h"
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#if HAVE_DOMXML
|
||||
#include "ext/standard/info.h"
|
||||
//#define newcode
|
||||
/*#define newcode*/
|
||||
|
||||
static int le_domxmldocp;
|
||||
static int le_domxmldtdp;
|
||||
@@ -108,7 +108,7 @@ zend_module_entry php_domxml_module_entry = {
|
||||
};
|
||||
|
||||
void _free_node(xmlNode *tmp) {
|
||||
//fprintf(stderr, "Freeing node: %s\n", tmp->name);
|
||||
/*fprintf(stderr, "Freeing node: %s\n", tmp->name);*/
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(domxml)
|
||||
@@ -129,7 +129,7 @@ PHP_MINIT_FUNCTION(domxml)
|
||||
*/
|
||||
le_domxmlnodep = register_list_destructors(_free_node, NULL);
|
||||
le_domxmlattrp = register_list_destructors(NULL, NULL);
|
||||
// le_domxmlnsp = register_list_destructors(NULL, NULL);
|
||||
/* le_domxmlnsp = register_list_destructors(NULL, NULL); */
|
||||
|
||||
INIT_CLASS_ENTRY(domxmldoc_class_entry, "DomDocument", php_domxmldoc_class_functions);
|
||||
INIT_CLASS_ENTRY(domxmldtd_class_entry, "Dtd", php_domxmldtd_class_functions);
|
||||
@@ -320,7 +320,7 @@ PHP_MINFO_FUNCTION(domxml)
|
||||
/* don't know why that line was commented out in the previous version, so i left it (cmv) */
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "DOM/XML Support", "enabled");
|
||||
// php_info_print_table_row(2, "libmxl Version", LIBXML_VERSION );
|
||||
/* php_info_print_table_row(2, "libmxl Version", LIBXML_VERSION ); */
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ PHP_FUNCTION(domxml_attrname)
|
||||
object_init_ex(pattr, domxmlattr_class_entry_ptr);
|
||||
add_property_resource(pattr, "attribute", ret);
|
||||
add_property_stringl(pattr, "name", (char *) attr->name, strlen(attr->name), 1);
|
||||
// add_property_stringl(pattr, "content", (char *) attr->val->content, strlen(attr->val->content), 1);
|
||||
/* add_property_stringl(pattr, "content", (char *) attr->val->content, strlen(attr->val->content), 1); */
|
||||
zend_hash_next_index_insert(return_value->value.ht, &pattr, sizeof(zval *), NULL);
|
||||
attr = attr->next;
|
||||
}
|
||||
@@ -918,7 +918,7 @@ PHP_FUNCTION(domxml_dumpmem)
|
||||
zval *id, **tmp;
|
||||
int id_to_find;
|
||||
xmlDoc *docp;
|
||||
// char *mem;
|
||||
/* char *mem; */
|
||||
xmlChar *mem;
|
||||
int size;
|
||||
int type;
|
||||
@@ -1181,11 +1181,11 @@ static int node_namespace(zval **attributes, xmlNode *nodep)
|
||||
while(ns) {
|
||||
zval *pattr;
|
||||
MAKE_STD_ZVAL(pattr);
|
||||
// ret = zend_list_insert(attr, le_domxmlattrp);
|
||||
/* ret = zend_list_insert(attr, le_domxmlattrp); */
|
||||
|
||||
/* construct an object with some methods */
|
||||
object_init_ex(pattr, domxmlns_class_entry_ptr);
|
||||
// add_property_resource(pattr, "attribute", ret);
|
||||
/* add_property_resource(pattr, "attribute", ret); */
|
||||
if(ns->href)
|
||||
add_property_stringl(pattr, "href", (char *) ns->href, strlen(ns->href), 1);
|
||||
if(ns->prefix)
|
||||
@@ -1214,7 +1214,7 @@ static int node_attributes(zval **attributes, xmlNode *nodep)
|
||||
}
|
||||
|
||||
/* create an php array for the children */
|
||||
// MAKE_STD_ZVAL(*attributes); // Don't do this if *attributes are the return_value
|
||||
/* MAKE_STD_ZVAL(*attributes); *//* Don't do this if *attributes are the return_value */
|
||||
if (array_init(*attributes) == FAILURE) {
|
||||
return -1;
|
||||
}
|
||||
@@ -1262,7 +1262,7 @@ static int node_children(zval **children, xmlNode *nodep)
|
||||
|
||||
/* Each child is a node object */
|
||||
MAKE_STD_ZVAL(child);
|
||||
// ret = zend_list_insert(last, le_domxmlnodep);
|
||||
/* ret = zend_list_insert(last, le_domxmlnodep); */
|
||||
|
||||
/* construct a node object for each child */
|
||||
object_init_ex(child, domxmlnode_class_entry_ptr);
|
||||
@@ -1275,7 +1275,7 @@ static int node_children(zval **children, xmlNode *nodep)
|
||||
add_property_long(child, "type", last->type);
|
||||
if(last->content)
|
||||
add_property_stringl(child, "content", (char *) last->content, strlen(last->content), 1);
|
||||
// add_property_resource(child, "node", ret);
|
||||
/* add_property_resource(child, "node", ret); */
|
||||
|
||||
/* Get the namespace of the current node and add it as a property */
|
||||
/* if(!node_namespace(&namespace, last))
|
||||
@@ -1283,7 +1283,7 @@ static int node_children(zval **children, xmlNode *nodep)
|
||||
*/
|
||||
|
||||
/* Get the attributes of the current node and add it as a property */
|
||||
MAKE_STD_ZVAL(attributes); // Because it was taken out of node_attributes()
|
||||
MAKE_STD_ZVAL(attributes); /* Because it was taken out of node_attributes() */
|
||||
if(0 <= node_attributes(&attributes, last))
|
||||
zend_hash_update(child->value.obj.properties, "attributes", sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "php_ini.h"
|
||||
#include "php_hyperwave.h"
|
||||
|
||||
//hw_module php_hw_module;
|
||||
/*hw_module php_hw_module;*/
|
||||
|
||||
#define HW_ATTR_NONE 1
|
||||
#define HW_ATTR_LANG 2
|
||||
@@ -375,9 +375,11 @@ int make2_return_array_from_objrec(pval **return_value, char *objrec, zval *sarr
|
||||
attrname = php_strtok_r(NULL, "\n", &strtok_buf);
|
||||
}
|
||||
if(NULL == sarr){
|
||||
// spec_arr->refcount--;
|
||||
// zend_hash_destroy(spec_arr->value.ht);
|
||||
// efree(spec_arr->value.ht);
|
||||
/*
|
||||
spec_arr->refcount--;
|
||||
zend_hash_destroy(spec_arr->value.ht);
|
||||
efree(spec_arr->value.ht);
|
||||
*/
|
||||
zval_dtor(spec_arr);
|
||||
efree(spec_arr);
|
||||
}
|
||||
@@ -546,7 +548,7 @@ static char * make_objrec_from_array(HashTable *lht) {
|
||||
*objrec = '\0';
|
||||
for(i=0; i<count; i++) {
|
||||
keytype = zend_hash_get_current_key(lht, &key, &length);
|
||||
// if(HASH_KEY_IS_STRING == keytype) {
|
||||
/* if(HASH_KEY_IS_STRING == keytype) { */
|
||||
zend_hash_get_current_data(lht, (void **) &keydataptr);
|
||||
keydata = *keydataptr;
|
||||
switch(keydata->type) {
|
||||
@@ -598,7 +600,7 @@ static char * make_objrec_from_array(HashTable *lht) {
|
||||
if(HASH_KEY_IS_STRING == keytype) efree(key);
|
||||
objrec = realloc(objrec, strlen(objrec)+strlen(str)+1);
|
||||
strcat(objrec, str);
|
||||
// }
|
||||
/* } */
|
||||
zend_hash_move_forward(lht);
|
||||
}
|
||||
return objrec;
|
||||
|
||||
@@ -74,7 +74,7 @@ typedef struct {
|
||||
extern PHP_HW_API php_hw_globals hw_globals;
|
||||
#endif
|
||||
|
||||
//extern hw_module php_hw_module;
|
||||
/*extern hw_module php_hw_module;*/
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
|
||||
@@ -272,8 +272,10 @@ PHP_FUNCTION(icap_reopen)
|
||||
flags = options->value.lval;
|
||||
icap_le_struct->flags = cl_flags;
|
||||
}
|
||||
// icap_stream = cal_connect(calendar->value.str.val);
|
||||
// cal_login(icap_stream, calendar->value.str.val);
|
||||
/*
|
||||
icap_stream = cal_connect(calendar->value.str.val);
|
||||
cal_login(icap_stream, calendar->value.str.val);
|
||||
*/
|
||||
if (icap_stream == NULL) {
|
||||
php_error(E_WARNING,"Couldn't re-open stream\n");
|
||||
RETURN_FALSE;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
|
||||
| Chuck Hagenbuch <chuck@horde.org> |
|
||||
| Andrew Skalski <askalski@chekinc.com> |
|
||||
| Hartmut Holzgraefe <hartmut@six.de> |
|
||||
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -1026,6 +1027,8 @@ PHP_FUNCTION(imap_close)
|
||||
}
|
||||
imap_le_struct->flags = flags;
|
||||
}
|
||||
mail_close_it(imap_le_struct);
|
||||
|
||||
zend_list_delete(ind);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
@@ -944,7 +944,9 @@ static void php_msql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
|
||||
add_assoc_stringl(return_value, msql_field->name, data, data_len, should_copy);
|
||||
}
|
||||
} else {
|
||||
//add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr, 1);
|
||||
/*
|
||||
add_get_index_stringl(return_value, i, empty_string, 0, (void **) &pval_ptr, 1);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ inline double ulonglong2double(ulonglong value)
|
||||
#define HAVE_ALLOCA
|
||||
#define HAVE_STRPBRK
|
||||
#define HAVE_STRSTR
|
||||
//#define HAVE_COMPRESS
|
||||
/*#define HAVE_COMPRESS*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef ETIME
|
||||
#define ETIME ETIMEDOUT // For FreeBSD
|
||||
#define ETIME ETIMEDOUT /* For FreeBSD */
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
@@ -102,8 +102,8 @@ void pthread_exit(unsigned A); /* was #define pthread_exit(A) ExitThread(A)*/
|
||||
#define pthread_condattr_init(A)
|
||||
#define pthread_condattr_destroy(A)
|
||||
|
||||
//Irena: compiler does not like this:
|
||||
//#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0)
|
||||
/*Irena: compiler does not like this:*/
|
||||
/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0)*/
|
||||
#define my_pthread_getprio(thread_id) pthread_dummy(0)
|
||||
|
||||
#elif defined(HAVE_UNIXWARE7_THREADS)
|
||||
|
||||
@@ -135,7 +135,7 @@ static char *php_string_from_clsid(CLSID *clsid)
|
||||
char *clsid_str;
|
||||
|
||||
StringFromCLSID(clsid, &ole_clsid);
|
||||
//s_clsid = OLE2A(ole_clsid);
|
||||
/*s_clsid = OLE2A(ole_clsid);*/
|
||||
clsid_str = php_OLECHAR_to_char(ole_clsid, NULL, 0);
|
||||
LocalFree(ole_clsid);
|
||||
|
||||
@@ -270,7 +270,7 @@ PHP_FUNCTION(COM_load)
|
||||
hr=CLSIDFromProgID(ProgID, &clsid);
|
||||
efree(ProgID);
|
||||
|
||||
// obtain CLSID
|
||||
/* obtain CLSID */
|
||||
if (FAILED(hr)) {
|
||||
error_message = php_COM_error_message(hr);
|
||||
php_error(E_WARNING,"Invalid ProgID: %s\n", error_message);
|
||||
@@ -278,7 +278,7 @@ PHP_FUNCTION(COM_load)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
// obtain IDispatch
|
||||
/* obtain IDispatch */
|
||||
if (!server_name) {
|
||||
hr=CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (void **) &i_dispatch);
|
||||
} else {
|
||||
@@ -447,15 +447,15 @@ static void php_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg)
|
||||
case IS_LONG:
|
||||
case IS_BOOL:
|
||||
if (pval_arg->is_ref == 0) {
|
||||
var_arg->vt = VT_I4; // assuming 32-bit platform
|
||||
var_arg->vt = VT_I4; /* assuming 32-bit platform */
|
||||
var_arg->lVal = pval_arg->value.lval;
|
||||
} else {
|
||||
var_arg->vt = VT_I4 | VT_BYREF; // assuming 32-bit platform
|
||||
var_arg->vt = VT_I4 | VT_BYREF; /* assuming 32-bit platform */
|
||||
var_arg->plVal = &(pval_arg->value.lval);
|
||||
}
|
||||
break;
|
||||
case IS_DOUBLE:
|
||||
var_arg->vt = VT_R8; // assuming 64-bit double precision
|
||||
var_arg->vt = VT_R8; /* assuming 64-bit double precision */
|
||||
var_arg->dblVal = pval_arg->value.dval;
|
||||
break;
|
||||
case IS_STRING:
|
||||
@@ -523,7 +523,7 @@ int do_COM_invoke(IDispatch *i_dispatch, pval *function_name, VARIANTARG *var_re
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// variant_args = dispparams.rgvarg;
|
||||
/* variant_args = dispparams.rgvarg; */
|
||||
|
||||
for (current_arg=0; current_arg<arg_count; current_arg++) {
|
||||
current_variant = arg_count - current_arg - 1;
|
||||
@@ -1035,7 +1035,7 @@ static int php_COM_load_typelib(char *typelib_name, int mode)
|
||||
c.flags = mode;
|
||||
|
||||
zend_register_constant(&c ELS_CC);
|
||||
//printf("%s -> %ld\n", ids, pVarDesc->lpvarValue->lVal);
|
||||
/*printf("%s -> %ld\n", ids, pVarDesc->lpvarValue->lVal);*/
|
||||
j++;
|
||||
}
|
||||
TypeInfo->lpVtbl->Release(TypeInfo);
|
||||
|
||||
@@ -201,7 +201,7 @@ void _php3_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) {
|
||||
/* Free the variable bindings that have been allocated.*/
|
||||
SnmpUtilVarBindListFree(&variableBindings);
|
||||
SnmpUtilOidFree(&root);
|
||||
} // end if (operation)
|
||||
} /* end if (operation) */
|
||||
|
||||
|
||||
/* Close SNMP session with the remote agent.*/
|
||||
|
||||
@@ -145,7 +145,7 @@ PHPAPI void php_print_info(int flag)
|
||||
char *zend_version = get_zend_version();
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
// Get build numbers for Windows NT or Win95
|
||||
/* Get build numbers for Windows NT or Win95 */
|
||||
if (dwVersion < 0x80000000){
|
||||
dwBuild = (DWORD)(HIWORD(dwVersion));
|
||||
snprintf(php_windows_uname,255,"%s %d.%d build %d","Windows NT",dwWindowsMajorVersion,dwWindowsMinorVersion,dwBuild);
|
||||
@@ -554,7 +554,7 @@ void register_phpinfo_constants(INIT_FUNC_ARGS)
|
||||
}
|
||||
|
||||
|
||||
/* {{{ proto void phpinfo(void)
|
||||
/* {{{ proto void phpinfo([int what])
|
||||
Output a page of useful information about PHP and the current request */
|
||||
PHP_FUNCTION(phpinfo)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#include <ctype.h>
|
||||
#include "php_string.h"
|
||||
|
||||
static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscated */
|
||||
/* faster, but obfuscated, all operations have a cost of 1 */
|
||||
static int fastest_levdist(const char *s1, const char *s2)
|
||||
{
|
||||
register char *p1,*p2;
|
||||
register int i,j,n;
|
||||
@@ -68,7 +69,7 @@ static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscate
|
||||
|
||||
|
||||
/* fill initial row */
|
||||
n=(*s1!=*s2);
|
||||
n=1;
|
||||
for(i=0,p1=r;i<l1;i++,*p1++=n++,p1++) {/*empty*/}
|
||||
|
||||
/* calc. rowwise */
|
||||
@@ -84,7 +85,7 @@ static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscate
|
||||
for(i=1;i<l1;i++) {
|
||||
if(*p1<n) n=*p1+(*(s1+i)!=*(s2)); /* replace cheaper than delete? */
|
||||
p1++;
|
||||
if(*++p1<n) n=*p1+1; /* insert cheaper then insert ? */
|
||||
if(*++p1<n) n=*p1+1; /* insert cheaper then replace ? */
|
||||
*p2++=n++; /* update field and cost for next col's delete */
|
||||
p2++;
|
||||
}
|
||||
@@ -95,26 +96,157 @@ static int calc_levdist(const char *s1, const char *s2) /* faster, but obfuscate
|
||||
}
|
||||
|
||||
|
||||
static int weighted_levdist( const char *s1
|
||||
, const char *s2
|
||||
, const int cost_ins
|
||||
, const int cost_rep
|
||||
, const int cost_del
|
||||
)
|
||||
{
|
||||
register int *p1,*p2;
|
||||
register int i,j,n,c;
|
||||
int l1=0,l2=0;
|
||||
int r[512];
|
||||
const char *tmp;
|
||||
|
||||
/* skip equal start sequence, if any */
|
||||
while(*s1==*s2) {
|
||||
if(!*s1) break;
|
||||
s1++; s2++;
|
||||
}
|
||||
|
||||
/* if we already used up one string, then
|
||||
the result is the length of the other */
|
||||
if(*s1=='\0') return strlen(s2);
|
||||
if(*s2=='\0') return strlen(s1);
|
||||
|
||||
/* length count */
|
||||
while(*s1++) l1++;
|
||||
while(*s2++) l2++;
|
||||
|
||||
/* cut of equal tail sequence, if any */
|
||||
while(*--s1 == *--s2) {
|
||||
l1--; l2--;
|
||||
}
|
||||
|
||||
|
||||
/* reset pointers, adjust length */
|
||||
s1-=l1++;
|
||||
s2-=l2++;
|
||||
|
||||
|
||||
/* possible dist to great? */
|
||||
if(abs(l1-l2)>=255) return -1;
|
||||
|
||||
/* swap if l2 longer than l1 */
|
||||
if(l1<l2) {
|
||||
tmp=s1; s1=s2; s2=tmp;
|
||||
l1 ^= l2; l2 ^= l1; l1 ^= l2;
|
||||
}
|
||||
|
||||
if((l1==1)&&(l2==1)) {
|
||||
n= cost_del+cost_ins;
|
||||
return n<cost_rep?n:cost_rep;
|
||||
}
|
||||
|
||||
/* fill initial row */
|
||||
n=cost_ins;
|
||||
for(i=0,p1=r;i<l1;i++,*p1++=n,p1++) {n+=cost_ins;}
|
||||
|
||||
/* calc. rowwise */
|
||||
for(j=1;j<l2;j++) {
|
||||
/* init pointers and col#0 */
|
||||
p1 = r + !(j&1);
|
||||
p2 = r + (j&1);
|
||||
n=*p1+cost_del;
|
||||
*p2++=n;p2++;
|
||||
s2++;
|
||||
|
||||
/* foreach column */
|
||||
for(i=1;i<l1;i++) {
|
||||
c = *p1; if(*(s1+i)!=*(s2)) c+=cost_rep;
|
||||
if(c<n) n=c; /* replace cheaper than delete? */
|
||||
p1++;
|
||||
c= *++p1+cost_ins;
|
||||
if(c<n) n=c; /* insert cheaper then replace ? */
|
||||
*p2++=n; /* update field and cost for next col's delete */
|
||||
n+=cost_del; /* update field and cost for next col's delete */
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
|
||||
/* return result */
|
||||
return n-=cost_del;
|
||||
}
|
||||
|
||||
int custom_levdist(char *str1,char *str2,char *callback_name)
|
||||
{
|
||||
php_error(E_WARNING,"the general Levenshtein support is not there yet");
|
||||
/* not there yet */
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* {{{ proto int levenshtein(string str1, string str2)
|
||||
Calculate Levenshtein distance between two strings */
|
||||
PHP_FUNCTION(levenshtein)
|
||||
{
|
||||
zval **str1, **str2;
|
||||
int l;
|
||||
zval **str1, **str2, **cost_ins, **cost_rep, **cost_del,**callback_name;
|
||||
int distance=-1;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &str1, &str2) == FAILURE) {
|
||||
switch(ZEND_NUM_ARGS()) {
|
||||
case 2: /* just two string: use maximum performance version */
|
||||
if (zend_get_parameters_ex(2, &str1, &str2) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(str1);
|
||||
convert_to_string_ex(str2);
|
||||
|
||||
distance = fastest_levdist((*str1)->value.str.val, (*str2)->value.str.val);
|
||||
break;
|
||||
|
||||
case 5: /* more general version: calc cost by ins/rep/del weights */
|
||||
if (zend_get_parameters_ex(5, &str1, &str2, &cost_ins, &cost_rep, &cost_del) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(str1);
|
||||
convert_to_string_ex(str2);
|
||||
convert_to_long_ex(cost_ins);
|
||||
convert_to_long_ex(cost_rep);
|
||||
convert_to_long_ex(cost_del);
|
||||
|
||||
distance = weighted_levdist((*str1)->value.str.val
|
||||
, (*str2)->value.str.val
|
||||
, (*cost_ins)->value.lval
|
||||
, (*cost_rep)->value.lval
|
||||
, (*cost_del)->value.lval
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case 3: /* most general version: calc cost by user-supplied function */
|
||||
if (zend_get_parameters_ex(3, &str1, &str2, &callback_name) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(str1);
|
||||
convert_to_string_ex(str2);
|
||||
convert_to_string_ex(callback_name);
|
||||
|
||||
distance = custom_levdist((*str1)->value.str.val
|
||||
, (*str2)->value.str.val
|
||||
, (*callback_name)->value.str.lval
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(str1);
|
||||
convert_to_string_ex(str2);
|
||||
|
||||
l = calc_levdist((*str1)->value.str.val, (*str2)->value.str.val);
|
||||
}
|
||||
|
||||
if(l<0) {
|
||||
if(distance<0) {
|
||||
php_error(E_WARNING,"levenshtein(): argument string(s) too long");
|
||||
}
|
||||
|
||||
RETURN_LONG(l);
|
||||
|
||||
RETURN_LONG(distance);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
@@ -1296,7 +1296,7 @@ static void retval_grs1 (zval *return_value, Z_GenericRecord *p)
|
||||
eno[level]++;
|
||||
continue;
|
||||
}
|
||||
// eno[level]++;
|
||||
/* eno[level]++; */
|
||||
|
||||
*tag = '\0';
|
||||
for (i = 0; i<=level; i++)
|
||||
|
||||
@@ -822,12 +822,14 @@ PHP_FUNCTION(gzuncompress)
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string_ex(data);
|
||||
|
||||
// zlib::uncompress() wants to know the output data length
|
||||
// if none was given as a parameter
|
||||
// we try from input length * 2 up to input length * 2^8
|
||||
// doubling it whenever it wasn't big enough
|
||||
// that should be eneugh for all real life cases
|
||||
|
||||
/*
|
||||
zlib::uncompress() wants to know the output data length
|
||||
if none was given as a parameter
|
||||
we try from input length * 2 up to input length * 2^8
|
||||
doubling it whenever it wasn't big enough
|
||||
that should be eneugh for all real life cases
|
||||
*/
|
||||
do {
|
||||
length=plength?plength:(*data)->value.str.len*(1<<factor++);
|
||||
s2 = (char *) erealloc(s1,length);
|
||||
|
||||
@@ -518,8 +518,10 @@ static void my_endthread()
|
||||
}
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
// ___except can only call a function, so we have to do this
|
||||
// to retrieve the pointer.
|
||||
/*
|
||||
___except can only call a function, so we have to do this
|
||||
to retrieve the pointer.
|
||||
*/
|
||||
BOOL exceptionhandler(LPEXCEPTION_POINTERS *e,LPEXCEPTION_POINTERS ep)
|
||||
{
|
||||
*e=ep;
|
||||
|
||||
103
win32/sendmail.c
103
win32/sendmail.c
@@ -48,13 +48,13 @@ static char *months[] =
|
||||
#ifndef THREAD_SAFE
|
||||
char Buffer[MAIL_BUFFER_SIZE];
|
||||
|
||||
// socket related data
|
||||
/* socket related data */
|
||||
SOCKET sc;
|
||||
WSADATA Data;
|
||||
struct hostent *adr;
|
||||
SOCKADDR_IN sock_in;
|
||||
int WinsockStarted;
|
||||
// values set by the constructor
|
||||
/* values set by the constructor */
|
||||
char *AppName;
|
||||
char MailHost[HOST_NAME_LEN];
|
||||
char LocalHost[HOST_NAME_LEN];
|
||||
@@ -64,7 +64,7 @@ char *php_mailer = "PHP 3.0 WIN32";
|
||||
|
||||
char *get_header(char *h, char *headers);
|
||||
|
||||
// Error messages
|
||||
/* Error messages */
|
||||
static char *ErrorMessages[] =
|
||||
{
|
||||
{"Success"},
|
||||
@@ -91,7 +91,7 @@ static char *ErrorMessages[] =
|
||||
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: TSendMail
|
||||
// Input: 1) host: Name of the mail host where the SMTP server resides
|
||||
// max accepted length of name = 256
|
||||
@@ -103,7 +103,7 @@ static char *ErrorMessages[] =
|
||||
// SUCCESS otherwise.
|
||||
//
|
||||
// See SendText() for additional args!
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
int TSendMail(char *host, int *error,
|
||||
char *headers, char *Subject, char *mailTo, char *data)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ int TSendMail(char *host, int *error,
|
||||
return 19;
|
||||
}
|
||||
|
||||
// attempt to connect with mail host
|
||||
/* attempt to connect with mail host */
|
||||
*error = MailConnect();
|
||||
if (*error != 0) {
|
||||
if(RPath)efree(RPath);
|
||||
@@ -144,32 +144,33 @@ int TSendMail(char *host, int *error,
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************************
|
||||
/'********************************************************************
|
||||
// Name: TSendMail::~TSendMail
|
||||
// Input:
|
||||
// Output:
|
||||
// Description: DESTRUCTOR
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
void TSMClose()
|
||||
{
|
||||
Post("QUIT\n");
|
||||
Ack();
|
||||
// to guarantee that the cleanup is not made twice and
|
||||
// compomise the rest of the application if sockets are used
|
||||
// elesewhere
|
||||
/* to guarantee that the cleanup is not made twice and
|
||||
compomise the rest of the application if sockets are used
|
||||
elesewhere
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: char *GetSMErrorText
|
||||
// Input: Error index returned by the menber functions
|
||||
// Output: pointer to a string containing the error description
|
||||
// Description:
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//*******************************************************************/
|
||||
char *GetSMErrorText(int index)
|
||||
{
|
||||
|
||||
@@ -180,7 +181,7 @@ char *GetSMErrorText(int index)
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: TSendText
|
||||
// Input: 1) RPath: return path of the message
|
||||
// Is used to fill the "Return-Path" and the
|
||||
@@ -193,14 +194,14 @@ char *GetSMErrorText(int index)
|
||||
// Description:
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//*******************************************************************/
|
||||
int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers)
|
||||
{
|
||||
|
||||
int res, i;
|
||||
char *p;
|
||||
|
||||
// check for NULL parameters
|
||||
/* check for NULL parameters */
|
||||
if (data == NULL)
|
||||
return (BAD_MSG_CONTENTS);
|
||||
if (mailTo == NULL)
|
||||
@@ -208,15 +209,15 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
if (RPath == NULL)
|
||||
return (BAD_MSG_RPATH);
|
||||
|
||||
// simple checks for the mailto address
|
||||
// have ampersand ?
|
||||
/* simple checks for the mailto address */
|
||||
/* have ampersand ? */
|
||||
if (strchr(mailTo, '@') == NULL)
|
||||
return (BAD_MSG_DESTINATION);
|
||||
|
||||
sprintf(Buffer, "HELO %s\n", LocalHost);
|
||||
|
||||
// in the beggining of the dialog
|
||||
// attempt reconnect if the first Post fail
|
||||
/* in the beggining of the dialog */
|
||||
/* attempt reconnect if the first Post fail */
|
||||
if ((res = Post(Buffer)) != SUCCESS) {
|
||||
MailConnect();
|
||||
if ((res = Post(Buffer)) != SUCCESS)
|
||||
@@ -244,7 +245,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
return (res);
|
||||
|
||||
|
||||
// send message header
|
||||
/* send message header */
|
||||
if (Subject == NULL)
|
||||
res = PostHeader(RPath, "No Subject", mailTo, headers);
|
||||
else
|
||||
@@ -253,7 +254,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
return (res);
|
||||
|
||||
|
||||
// send message contents in 1024 chunks
|
||||
/* send message contents in 1024 chunks */
|
||||
if (strlen(data) <= 1024) {
|
||||
if ((res = Post(data)) != SUCCESS)
|
||||
return (res);
|
||||
@@ -267,18 +268,18 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
else
|
||||
i = strlen(p);
|
||||
|
||||
// put next chunk in buffer
|
||||
/* put next chunk in buffer */
|
||||
strncpy(Buffer, p, i);
|
||||
Buffer[i] = '\0';
|
||||
p += i;
|
||||
|
||||
// send chunk
|
||||
/* send chunk */
|
||||
if ((res = Post(Buffer)) != SUCCESS)
|
||||
return (res);
|
||||
}
|
||||
}
|
||||
|
||||
//send termination dot
|
||||
/*send termination dot */
|
||||
if ((res = Post("\r\n.\r\n")) != SUCCESS)
|
||||
return (res);
|
||||
if ((res = Ack()) != SUCCESS)
|
||||
@@ -289,7 +290,7 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: PostHeader
|
||||
// Input: 1) return path
|
||||
// 2) Subject
|
||||
@@ -299,12 +300,12 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
|
||||
// Description:
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
|
||||
{
|
||||
|
||||
// Print message header according to RFC 822
|
||||
// Return-path, Received, Date, From, Subject, Sender, To, cc
|
||||
/* Print message header according to RFC 822 */
|
||||
/* Return-path, Received, Date, From, Subject, Sender, To, cc */
|
||||
|
||||
time_t tNow = time(NULL);
|
||||
struct tm *tm = localtime(&tNow);
|
||||
@@ -350,34 +351,36 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
|
||||
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: MailConnect
|
||||
// Input: None
|
||||
// Output: None
|
||||
// Description: Connect to the mail host and receive the welcome message.
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
int MailConnect()
|
||||
{
|
||||
|
||||
int res;
|
||||
|
||||
// Create Socket
|
||||
/* Create Socket */
|
||||
if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
|
||||
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
|
||||
|
||||
// Get our own host name
|
||||
/* Get our own host name */
|
||||
if (gethostname(LocalHost, HOST_NAME_LEN))
|
||||
return (FAILED_TO_GET_HOSTNAME);
|
||||
|
||||
// Resolve the servers IP
|
||||
//if (!isdigit(MailHost[0])||!gethostbyname(MailHost))
|
||||
//{
|
||||
// return (FAILED_TO_RESOLVE_HOST);
|
||||
//}
|
||||
/* Resolve the servers IP */
|
||||
/*
|
||||
if (!isdigit(MailHost[0])||!gethostbyname(MailHost))
|
||||
{
|
||||
return (FAILED_TO_RESOLVE_HOST);
|
||||
}
|
||||
*/
|
||||
|
||||
// Connect to server
|
||||
/* Connect to server */
|
||||
sock_in.sin_family = AF_INET;
|
||||
sock_in.sin_port = htons(25);
|
||||
sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost);
|
||||
@@ -385,7 +388,7 @@ int MailConnect()
|
||||
if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in)))
|
||||
return (FAILED_TO_CONNECT);
|
||||
|
||||
// receive Server welcome message
|
||||
/* receive Server welcome message */
|
||||
res = Ack();
|
||||
return (res);
|
||||
}
|
||||
@@ -395,14 +398,14 @@ int MailConnect()
|
||||
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: Post
|
||||
// Input:
|
||||
// Output:
|
||||
// Description:
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
int Post(LPCSTR msg)
|
||||
{
|
||||
int len = strlen(msg);
|
||||
@@ -420,7 +423,7 @@ int Post(LPCSTR msg)
|
||||
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: Ack
|
||||
// Input:
|
||||
// Output:
|
||||
@@ -429,7 +432,7 @@ int Post(LPCSTR msg)
|
||||
// last command was successful.
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
int Ack()
|
||||
{
|
||||
static char *buf;
|
||||
@@ -448,13 +451,13 @@ int Ack()
|
||||
|
||||
Received += rlen;
|
||||
buf[Received] = 0;
|
||||
//err_msg fprintf(stderr,"Received: (%d bytes) %s", rlen, buf + Index);
|
||||
/*err_msg fprintf(stderr,"Received: (%d bytes) %s", rlen, buf + Index); */
|
||||
|
||||
// Check for newline
|
||||
/* Check for newline */
|
||||
Index += rlen;
|
||||
if ((buf[Received - 2] != '\r') || (buf[Received - 1] != '\n'))
|
||||
// err_msg fprintf(stderr,"Incomplete server message. Awaiting CRLF\n");
|
||||
goto again; // Incomplete data. Line must be terminated by CRLF
|
||||
/* err_msg fprintf(stderr,"Incomplete server message. Awaiting CRLF\n"); */
|
||||
goto again; /* Incomplete data. Line must be terminated by CRLF */
|
||||
|
||||
if (buf[0] > '3')
|
||||
return (SMTP_SERVER_ERROR);
|
||||
@@ -463,7 +466,7 @@ int Ack()
|
||||
}
|
||||
|
||||
|
||||
//********************************************************************
|
||||
/*********************************************************************
|
||||
// Name: unsigned long GetAddr (LPSTR szHost)
|
||||
// Input:
|
||||
// Output:
|
||||
@@ -474,7 +477,7 @@ int Ack()
|
||||
// WARNING: gethostbyname() is a blocking function
|
||||
// Author/Date: jcar 20/9/96
|
||||
// History:
|
||||
//********************************************************************
|
||||
//********************************************************************/
|
||||
unsigned long GetAddr(LPSTR szHost)
|
||||
{
|
||||
LPHOSTENT lpstHost;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if !defined(sendmail_h) // Sentry, use file only if it's not already included.
|
||||
#if !defined(sendmail_h) /* Sentry, use file only if it's not already included. */
|
||||
#define sendmail_h
|
||||
#include <windows.h>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#define MAX_APPNAME_LENGHT 100
|
||||
#define MAX_ERROR_INDEX 17
|
||||
#define MIN_ERROR_INDEX 0
|
||||
#define MAIL_BUFFER_SIZE (1024*4) // 4k buffer
|
||||
// Return values
|
||||
#define MAIL_BUFFER_SIZE (1024*4) /* 4k buffer */
|
||||
/* Return values */
|
||||
#define SUCCESS 0
|
||||
#define FAILED_TO_PARSE_ARGUMENTS 1
|
||||
#define FAILED_TO_OPEN_MAILFILE 2
|
||||
@@ -43,4 +43,4 @@ unsigned long GetAddr(LPSTR szHost);
|
||||
|
||||
|
||||
|
||||
#endif // sendmail_h
|
||||
#endif /* sendmail_h */
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
|
||||
extern void closelog(void);
|
||||
extern void openlog(const char *, int, int);
|
||||
// setlogmask not implemented
|
||||
//extern int setlogmask (int);
|
||||
/* setlogmask not implemented */
|
||||
/* extern int setlogmask (int); */
|
||||
extern void syslog(int, const char *, ...);
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ char *php_win_err(void)
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
|
||||
(LPTSTR) Win_Error_msg,
|
||||
256,
|
||||
NULL);
|
||||
|
||||
Reference in New Issue
Block a user