1999-04-22 00:25:57 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
1999-07-16 13:13:16 +00:00
|
|
|
| PHP version 4.0 |
|
1999-04-22 00:25:57 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2000-01-01 01:32:05 +00:00
|
|
|
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
1999-04-22 00:25:57 +00:00
|
|
|
+----------------------------------------------------------------------+
|
1999-07-16 13:13:16 +00:00
|
|
|
| This source file is subject to version 2.0 of the PHP license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available at through the world-wide-web at |
|
|
|
|
| http://www.php.net/license/2_0.txt. |
|
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
1999-04-22 00:25:57 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Uwe Steinmann <Uwe.Steinmann@fernuni-hagen.de> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/* FdfTk lib 2.0 is a Complete C/C++ FDF Toolkit available from
|
|
|
|
http://beta1.adobe.com/ada/acrosdk/forms.html. */
|
|
|
|
|
|
|
|
/* Note that there is no code from the FdfTk lib in this file */
|
|
|
|
|
|
|
|
#if !PHP_31 && defined(THREAD_SAFE)
|
|
|
|
#undef THREAD_SAFE
|
|
|
|
#endif
|
|
|
|
|
2000-02-17 20:23:59 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if((NULL != SG(request_info).content_type) && (0 == strcmp(SG(request_info).content_type, "application/vnd.fdf"))) {
|
|
|
|
pval *tmp;
|
|
|
|
|
|
|
|
ALLOC_ZVAL(tmp);
|
|
|
|
tmp->value.str.len = SG(request_info).post_data_length;
|
|
|
|
tmp->value.str.val = estrndup(SG(request_info).post_data, SG(request_info).post_data_length);
|
|
|
|
tmp->type = IS_STRING;
|
|
|
|
INIT_PZVAL(tmp);
|
|
|
|
zend_hash_add(&EG(symbol_table), "HTTP_FDF_DATA", sizeof("HTTP_FDF_DATA"), &tmp, sizeof(pval *),NULL);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1999-04-22 00:25:57 +00:00
|
|
|
#include "php.h"
|
1999-07-21 19:55:24 +00:00
|
|
|
#include "ext/standard/head.h"
|
1999-04-22 00:25:57 +00:00
|
|
|
#include <math.h>
|
1999-12-04 19:19:57 +00:00
|
|
|
#include "php_fdf.h"
|
1999-04-22 00:25:57 +00:00
|
|
|
|
|
|
|
#if HAVE_SYS_WAIT_H
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#if WIN32|WINNT
|
|
|
|
# include <io.h>
|
|
|
|
# include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_FDFLIB
|
|
|
|
|
|
|
|
#ifdef THREAD_SAFE
|
|
|
|
DWORD FDFlibTls;
|
|
|
|
static int numthreads=0;
|
|
|
|
|
|
|
|
typedef struct fdflib_global_struct{
|
|
|
|
int le_fdf;
|
|
|
|
} fdflib_global_struct;
|
|
|
|
|
|
|
|
# define FDF_GLOBAL(a) fdflib_globals->a
|
|
|
|
# define FDF_TLS_VARS fdflib_global_struct *fdflib_globals=TlsGetValue(FDFlibTls)
|
|
|
|
|
|
|
|
#else
|
|
|
|
# define FDF_GLOBAL(a) a
|
|
|
|
# define FDF_TLS_VARS
|
|
|
|
int le_fdf_info;
|
|
|
|
int le_fdf;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
function_entry fdf_functions[] = {
|
1999-07-27 19:44:46 +00:00
|
|
|
PHP_FE(fdf_open, NULL)
|
|
|
|
PHP_FE(fdf_create, NULL)
|
|
|
|
PHP_FE(fdf_close, NULL)
|
|
|
|
PHP_FE(fdf_save, NULL)
|
|
|
|
PHP_FE(fdf_get_value, NULL)
|
|
|
|
PHP_FE(fdf_set_value, NULL)
|
|
|
|
PHP_FE(fdf_next_field_name, NULL)
|
|
|
|
PHP_FE(fdf_set_ap, NULL)
|
|
|
|
PHP_FE(fdf_set_status, NULL)
|
|
|
|
PHP_FE(fdf_get_status, NULL)
|
|
|
|
PHP_FE(fdf_set_file, NULL)
|
|
|
|
PHP_FE(fdf_get_file, NULL)
|
1999-08-06 06:52:06 +00:00
|
|
|
PHP_FE(fdf_add_template, NULL)
|
1999-04-22 00:25:57 +00:00
|
|
|
{NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
1999-12-17 20:55:31 +00:00
|
|
|
zend_module_entry fdf_module_entry = {
|
1999-07-27 19:44:46 +00:00
|
|
|
"fdf", fdf_functions, PHP_MINIT(fdf), PHP_MSHUTDOWN(fdf), NULL, NULL,
|
|
|
|
PHP_MINFO(fdf), STANDARD_MODULE_PROPERTIES
|
1999-04-22 00:25:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if COMPILE_DL
|
|
|
|
#include "dl/phpdl.h"
|
1999-12-17 20:55:31 +00:00
|
|
|
DLEXPORT zend_module_entry *get_module(void) { return &fdf_module_entry; }
|
1999-04-22 00:25:57 +00:00
|
|
|
#endif
|
|
|
|
|
1999-08-06 06:52:06 +00:00
|
|
|
static void phpi_FDFClose(FDFDoc fdf) {
|
|
|
|
(void)FDFClose(fdf);
|
|
|
|
}
|
|
|
|
|
1999-07-27 19:44:46 +00:00
|
|
|
PHP_MINIT_FUNCTION(fdf)
|
1999-04-22 00:25:57 +00:00
|
|
|
{
|
|
|
|
FDFErc err;
|
1999-08-06 06:52:06 +00:00
|
|
|
FDF_GLOBAL(le_fdf) = register_list_destructors(phpi_FDFClose, NULL);
|
1999-04-22 00:25:57 +00:00
|
|
|
err = FDFInitialize();
|
|
|
|
if(err == FDFErcOK)
|
1999-08-06 06:52:06 +00:00
|
|
|
return SUCCESS;
|
|
|
|
return FAILURE;
|
1999-04-22 00:25:57 +00:00
|
|
|
}
|
|
|
|
|
1999-07-27 19:44:46 +00:00
|
|
|
PHP_MINFO_FUNCTION(fdf)
|
|
|
|
{
|
1999-04-22 00:25:57 +00:00
|
|
|
/* need to use a PHPAPI function here because it is external module in windows */
|
1999-08-02 19:17:14 +00:00
|
|
|
php_printf("FdfTk Version %s", FDFGetVersion());
|
1999-04-22 00:25:57 +00:00
|
|
|
}
|
|
|
|
|
1999-07-27 19:44:46 +00:00
|
|
|
PHP_MSHUTDOWN_FUNCTION(fdf)
|
|
|
|
{
|
1999-04-22 00:25:57 +00:00
|
|
|
FDFErc err;
|
|
|
|
err = FDFFinalize();
|
|
|
|
if(err == FDFErcOK)
|
1999-08-06 06:52:06 +00:00
|
|
|
return SUCCESS;
|
|
|
|
return FAILURE;
|
1999-04-22 00:25:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* {{{ proto int fdf_open(string filename)
|
|
|
|
Opens a new fdf document */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_open) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **file;
|
2000-02-02 11:18:06 +00:00
|
|
|
int id;
|
1999-04-22 00:25:57 +00:00
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_string_ex(file);
|
1999-04-22 00:25:57 +00:00
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFOpen((*file)->value.str.val, 0, &fdf);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
if(!fdf)
|
|
|
|
RETURN_FALSE;
|
|
|
|
|
1999-12-17 19:51:39 +00:00
|
|
|
id = zend_list_insert(fdf,FDF_GLOBAL(le_fdf));
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_LONG(id);
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_close(int fdfdoc)
|
|
|
|
Closes the fdf document */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_close) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-06 06:52:06 +00:00
|
|
|
/* FDFClose(fdf); */
|
1999-12-17 19:51:39 +00:00
|
|
|
zend_list_delete(id);
|
1999-04-22 00:25:57 +00:00
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_create(void)
|
|
|
|
Creates a new fdf document */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_create) {
|
2000-02-02 11:18:06 +00:00
|
|
|
int id;
|
1999-04-22 00:25:57 +00:00
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
|
|
|
err = FDFCreate(&fdf);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
if(!fdf)
|
|
|
|
RETURN_FALSE;
|
|
|
|
|
1999-12-17 19:51:39 +00:00
|
|
|
id = zend_list_insert(fdf,FDF_GLOBAL(le_fdf));
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_LONG(id);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_get_value(int fdfdoc, string fieldname)
|
|
|
|
Gets the value of a field as string */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_get_value) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
ASInt32 nr;
|
|
|
|
char *buffer;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_string_ex(arg2);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-12-15 15:27:51 +00:00
|
|
|
err = FDFGetValue(fdf, (*arg2)->value.str.val, NULL, 0, &nr);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
1999-10-06 05:23:28 +00:00
|
|
|
/* In the inofficial version of FdfTK 4.0 (as FDFGetVersion says. The
|
|
|
|
library has a name with version 3.0, don't know what adobe has in
|
|
|
|
mind) the number of bytes of the value doesn't include the trailing
|
|
|
|
'\0'. This was not the case in 2.0
|
|
|
|
*/
|
|
|
|
if(strcmp(FDFGetVersion(), "2.0"))
|
|
|
|
nr++;
|
1999-04-22 00:25:57 +00:00
|
|
|
buffer = emalloc(nr);
|
1999-12-15 15:27:51 +00:00
|
|
|
err = FDFGetValue(fdf, (*arg2)->value.str.val, buffer, nr, &nr);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_STRING(buffer, 0);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_set_value(int fdfdoc, string fieldname, string value, int isName)
|
|
|
|
Sets the value of a field */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_set_value) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2, **arg3, **arg4;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 4 || zend_get_parameters_ex(4, &arg1, &arg2,&arg3, &arg4) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_string_ex(arg2);
|
|
|
|
convert_to_string_ex(arg3);
|
|
|
|
convert_to_long_ex(arg4);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFSetValue(fdf, (*arg2)->value.str.val,(*arg3)->value.str.val, (ASBool) (*arg4)->value.lval);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_next_field_name(int fdfdoc [, string fieldname])
|
|
|
|
Gets the name of the next field name or the first field name */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_next_field_name) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **argv[2];
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type, argc;
|
|
|
|
ASInt32 nr;
|
|
|
|
char *buffer, *fieldname;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
|
|
|
argc = ARG_COUNT(ht);
|
|
|
|
if((argc > 2) || (argc < 1))
|
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (zend_get_parameters_array_ex(argc, argv) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(argv[0]);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(argc == 2) {
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_string_ex(argv[1]);
|
|
|
|
fieldname = (*argv[1])->value.str.val;
|
1999-04-22 00:25:57 +00:00
|
|
|
} else {
|
|
|
|
fieldname = NULL;
|
|
|
|
}
|
1999-12-15 05:21:28 +00:00
|
|
|
id=(*argv[0])->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FDFNextFieldName(fdf, fieldname, NULL, 0, &nr);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
if(nr == 0)
|
|
|
|
RETURN_STRING(empty_string, 1);
|
|
|
|
|
|
|
|
buffer = emalloc(nr);
|
|
|
|
err = FDFNextFieldName(fdf, fieldname, buffer, nr, &nr);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_STRING(buffer, 0);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_set_ap(int fdfdoc, string fieldname, int face, string filename, int pagenr)
|
|
|
|
Sets the value of a field */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_set_ap) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2, **arg3, **arg4, **arg5;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDFAppFace face;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 5 || zend_get_parameters_ex(5, &arg1, &arg2,&arg3, &arg4, &arg5) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_string_ex(arg2);
|
|
|
|
convert_to_long_ex(arg3);
|
|
|
|
convert_to_string_ex(arg4);
|
|
|
|
convert_to_long_ex(arg5);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
switch((*arg3)->value.lval) {
|
1999-04-22 00:25:57 +00:00
|
|
|
case 1:
|
|
|
|
face = FDFNormalAP;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
face = FDFRolloverAP;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
face = FDFDownAP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
face = FDFNormalAP;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFSetAP(fdf, (*arg2)->value.str.val, face, NULL,
|
|
|
|
(*arg4)->value.str.val, (ASInt32) (*arg5)->value.lval);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_set_status(int fdfdoc, string status)
|
|
|
|
Sets the value in the /Status key. */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_set_status) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_string_ex(arg2);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFSetStatus(fdf, (*arg2)->value.str.val);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_get_status(int fdfdoc)
|
|
|
|
Gets the value in the /Status key. */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_get_status) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
ASInt32 nr;
|
|
|
|
char *buf;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FDFGetStatus(fdf, NULL, 0, &nr);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
if(nr == 0)
|
|
|
|
RETURN_STRING(empty_string, 1);
|
|
|
|
buf = emalloc(nr);
|
|
|
|
err = FDFGetStatus(fdf, buf, nr, &nr);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_STRING(buf, 0);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_set_file(int fdfdoc, string filename)
|
|
|
|
Sets the value of the FDF's /F key */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_set_file) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_string_ex(arg2);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFSetFile(fdf, (*arg2)->value.str.val);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_get_file(int fdfdoc)
|
|
|
|
Gets the value in the /F key. */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_get_file) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
ASInt32 nr;
|
|
|
|
char *buf;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = FDFGetFile(fdf, NULL, 0, &nr);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
if(nr == 0)
|
|
|
|
RETURN_STRING(empty_string, 1);
|
|
|
|
buf = emalloc(nr);
|
|
|
|
err = FDFGetFile(fdf, buf, nr, &nr);
|
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_STRING(buf, 0);
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto void fdf_save(int fdfdoc, string filename)
|
|
|
|
Writes out an FDF file. */
|
1999-05-21 10:06:25 +00:00
|
|
|
PHP_FUNCTION(fdf_save) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2;
|
1999-04-22 00:25:57 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
|
1999-04-22 00:25:57 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_string_ex(arg2);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-04-22 00:25:57 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFSave(fdf, (*arg2)->value.str.val);
|
1999-04-22 00:25:57 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
} /* }}} */
|
|
|
|
|
1999-08-06 06:52:06 +00:00
|
|
|
/* {{{ proto void fdf_add_template(int fdfdoc, int newpage, string filename, string template, int rename)
|
|
|
|
Adds a template to the FDF*/
|
|
|
|
PHP_FUNCTION(fdf_add_template) {
|
1999-12-15 05:21:28 +00:00
|
|
|
pval **arg1, **arg2, **arg3, **arg4, **arg5;
|
1999-08-06 06:52:06 +00:00
|
|
|
int id, type;
|
|
|
|
FDFDoc fdf;
|
|
|
|
FDFErc err;
|
|
|
|
pdfFileSpecRec filespec;
|
|
|
|
FDF_TLS_VARS;
|
|
|
|
|
1999-12-18 22:40:35 +00:00
|
|
|
if (ARG_COUNT(ht) != 5 || zend_get_parameters_ex(5, &arg1, &arg2,&arg3, &arg4, &arg5) == FAILURE) {
|
1999-08-06 06:52:06 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-15 05:21:28 +00:00
|
|
|
convert_to_long_ex(arg1);
|
|
|
|
convert_to_long_ex(arg2);
|
|
|
|
convert_to_string_ex(arg3);
|
|
|
|
convert_to_string_ex(arg4);
|
|
|
|
convert_to_long_ex(arg5);
|
|
|
|
id=(*arg1)->value.lval;
|
1999-12-17 19:51:39 +00:00
|
|
|
fdf = zend_list_find(id,&type);
|
1999-08-06 06:52:06 +00:00
|
|
|
if(!fdf || type!=FDF_GLOBAL(le_fdf)) {
|
1999-12-17 20:55:31 +00:00
|
|
|
php_error(E_WARNING,"Unable to find file identifier %d",id);
|
1999-08-06 06:52:06 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
filespec.FS = NULL;
|
1999-12-15 15:27:51 +00:00
|
|
|
filespec.F = (*arg3)->value.str.val;
|
1999-08-06 06:52:06 +00:00
|
|
|
filespec.Mac = NULL;
|
|
|
|
filespec.DOS = NULL;
|
|
|
|
filespec.Unix = NULL;
|
|
|
|
filespec.ID[0] = NULL;
|
|
|
|
filespec.ID[1] = NULL;
|
|
|
|
filespec.bVolatile = false;
|
1999-12-15 05:21:28 +00:00
|
|
|
err = FDFAddTemplate(fdf, (*arg2)->value.lval, &filespec,(*arg4)->value.str.val, (*arg5)->value.lval);
|
1999-08-06 06:52:06 +00:00
|
|
|
if(err != FDFErcOK)
|
|
|
|
printf("Aiii, error\n");
|
|
|
|
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
1999-04-22 00:25:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
*/
|