php-windows Digest 18 Oct 2002 12:00:37 -0000 Issue 1393
Topics (messages 16427 through 16435):
Re: please remove me from list
16427 by: Uttam
Re: Question about emalloc
16428 by: Brian 'Bex' Huff
16430 by: Mikey
16432 by: Brian 'Bex' Huff
16433 by: Rasmus Lerdorf
Re: [PHP] Re: Need help with HTTP-Authentication
16429 by: Davy Obdam
16434 by: Cam Dunstan
16435 by: Davy Obdam
Re: printer_ functions...
16431 by: Frank M. Kromann
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
pls. send a message to:
[EMAIL PROTECTED]
regds,
-----Original Message-----
From: John Dunn [mailto:newzenithz@;excite.com]
Sent: Thursday, October 17, 2002 03:30
To: [EMAIL PROTECTED]
Subject: please remove me from list
I hope that this is correct for me to get removed from this mailing
list. If not any info on the matter is genuinely appreciated. Thanks
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
--- End Message ---
--- Begin Message ---
Im pretty sure you still need to 'efree' what you 'emalloc'. Every time
I forgot to 'efree' something, I would get a bunch of error messages
about memory leaks. The errors were nice and verbose, tho... as long as
I was running the debug version of the dlls.
So either the documentation is wrong, and you have to efree
everything... or else the error messages about memory leaks that I keep
getting can be ignored...
I'd be curious to know the answer as well...
--
Brian 'Bex' Huff
[EMAIL PROTECTED]
Phone: 952-903-2023
Fax: 952-829-5424
Not too sure if I am in the right place, but here goes...
I am working on writing my own module and so far seem to be doing OK, but I
have one quick question. In the Memory Management section of the manual
(Ch. 26) it says:
"emalloc(), estrdup(), estrndup(), ecalloc(), and erealloc() allocate
internal memory; efree() frees these previously allocated blocks. Memory
handled by the e*() functions is considered local to the current process and
is discarded as soon as the script executed by this process is terminated."
Does this mean that I can emalloc a string and not have to worry about
efree()'ing it at the end? Also, if it is local to the process, how can it
be used to pass values out of a function?
regards,
Mikey
"If you give someone a program, you will frustrate them for a day. If you
teach them how to program, you will frustrate them for a lifetime."
**All Electronic Mail sent from the Stellent, Inc Electronic Communication Network is scanned by Antigen 7.0.**
--- End Message ---
--- Begin Message ---
> Im pretty sure you still need to 'efree' what you 'emalloc'. Every time
> I forgot to 'efree' something, I would get a bunch of error messages
> about memory leaks. The errors were nice and verbose, tho... as long as
> I was running the debug version of the dlls.
Which is what I would have assumed, but for what I read in the manual.
> So either the documentation is wrong, and you have to efree
> everything... or else the error messages about memory leaks that I keep
> getting can be ignored...
>
> I'd be curious to know the answer as well...
Well, I decided to see how the big boys dealt with strings, and had a root
around ext/standard. The following function is from string.c:
PHP_FUNCTION(bin2hex)
{
zval **data;
char *result;
size_t newlen;
if (ZEND_NUM_ARGS() != 1 ||
zend_get_parameters_ex(1, &data) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(data);
result = php_bin2hex(Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen);
if (!result) {
RETURN_FALSE;
}
RETURN_STRINGL(result, newlen, 0);
}
As you can see, result is emalloc()'d, but not efree()'d at the end - looks
like the docs are right. I have since tried using this approach in a test
function and do not get any errors when I compile - what do you use for your
build?
regards,
Mikey
--- End Message ---
--- Begin Message ---
Ok, according to my OReilly "Programming PHP" book by Rasmus Lerdorf,
the emalloc and efree functions work exactly the same as malloc and
free. It says:
-----
if you emalloc() something and forget to efree() it, PHP prints a leak
warning like this if you are running in debug mode (enabled by compiling
PHP with the --enable-debug switch):
foo.c(123) : Freeing 0x0821E5FC (20 bytes), script=foo.php
Last leak reported 1 time
-----
so the docs do not agree... Im more apt to believe the book I have,
since it goes on like this for a few pages about tracking down memory
leaks... plus Rasmus wrote it ;)
The reason why in your code there is no 'efree' is because of the '0'
flag passed to 'RETURN_STRINGL'. If that was a '1', they would have to
efree it.
--
Brian 'Bex' Huff
[EMAIL PROTECTED]
Phone: 952-903-2023
Fax: 952-829-5424
Mikey wrote:
Im pretty sure you still need to 'efree' what you 'emalloc'. Every time
I forgot to 'efree' something, I would get a bunch of error messages
about memory leaks. The errors were nice and verbose, tho... as long as
I was running the debug version of the dlls.
Which is what I would have assumed, but for what I read in the manual.
So either the documentation is wrong, and you have to efree
everything... or else the error messages about memory leaks that I keep
getting can be ignored...
I'd be curious to know the answer as well...
Well, I decided to see how the big boys dealt with strings, and had a root
around ext/standard. The following function is from string.c:
PHP_FUNCTION(bin2hex)
{
zval **data;
char *result;
size_t newlen;
if (ZEND_NUM_ARGS() != 1 ||
zend_get_parameters_ex(1, &data) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(data);
result = php_bin2hex(Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen);
if (!result) {
RETURN_FALSE;
}
RETURN_STRINGL(result, newlen, 0);
}
As you can see, result is emalloc()'d, but not efree()'d at the end - looks
like the docs are right. I have since tried using this approach in a test
function and do not get any errors when I compile - what do you use for your
build?
regards,
Mikey
**All Electronic Mail sent from the Stellent, Inc Electronic Communication Network is scanned by Antigen 7.0.**
--- End Message ---
--- Begin Message ---
> Well, I decided to see how the big boys dealt with strings, and had a root
> around ext/standard. The following function is from string.c:
>
> PHP_FUNCTION(bin2hex)
> {
> zval **data;
> char *result;
> size_t newlen;
>
> if (ZEND_NUM_ARGS() != 1 ||
> zend_get_parameters_ex(1, &data) == FAILURE) {
> WRONG_PARAM_COUNT;
> }
> convert_to_string_ex(data);
>
> result = php_bin2hex(Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen);
>
> if (!result) {
> RETURN_FALSE;
> }
>
> RETURN_STRINGL(result, newlen, 0);
> }
>
> As you can see, result is emalloc()'d, but not efree()'d at the end - looks
> like the docs are right. I have since tried using this approach in a test
> function and do not get any errors when I compile - what do you use for your
> build?
The result is efreed in that case. RETURN_STRINGL is a macro that assigns
result to return_value and return_value is implicitly efreed by PHP.
That's the only reason you are not getting a warning in that case. For
other stuff that you emalloc but don't assign to return_value, you will
get a warning if you do not efree it.
-Rasmus
--- End Message ---
--- Begin Message ---
Hi David,.
> Http authentication is probly not what you would want to
> use. Especially if you want to program in timeouts, you
> would be better off using session based login variables.
> Cookies are even better with an encrypted pasword that has a
> windows of time that you have to goto other pages to renew.
>
> Why HTTP auth?
>
> Is it mandatory?
Well its not mandatory i gues. I just thought that using
HTTP-Authentication was one of the more secure ways of a login system?
But i have heared not thats not the case, so i might go for a login
system with sessions instead, or cookies. What would u use and why? What
excactly do u mean with timeouts?
> I know this hasnt been any help, sorry!
Thats okay;-) Keeps the discusion alive;-)
Best regards,
Davy Obdam,
mailto:info@;davyobdam.com
--- End Message ---
--- Begin Message ---
David and Davy,
My two bobs worth - I like to use sessions myself usually, I suppose because
it means my scripts are controlling access rather than the server or the
operating system. With sessons you can store all sorts of variables such as
exactly what the user can do in a list of tasks rather than just "will we
let him in or not". The user submits a form with his username and password,
I look them up in a database, and if I find him I grab a "task list" of
things he is allowed to do on the site (could be different for every user)
and store them in a session. Everytime he tries to go somewhere on the site
the script first checks if that task is in his list - furthermore, you can
kick him off if he has overstayed or there has been no action for a period
of time - also gives you the opportunity to log or time his total activity
on the site.
I wrap each script in a small "include" routine which does all this so its
no big deal in terms of coding effort or extra overhead. You might like to
go this road rather than the simpler but more restrictive HTTP auth. way.
Cheers CD
----- Original Message -----
From: "Davy Obdam" <[EMAIL PROTECTED]>
To: "'David P Lenk'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, October 18, 2002 3:12 AM
Subject: [PHP-WIN] RE: [PHP] Re: Need help with HTTP-Authentication
> Hi David,.
>
> > Http authentication is probly not what you would want to
> > use. Especially if you want to program in timeouts, you
> > would be better off using session based login variables.
> > Cookies are even better with an encrypted pasword that has a
> > windows of time that you have to goto other pages to renew.
> >
> > Why HTTP auth?
> >
> > Is it mandatory?
>
> Well its not mandatory i gues. I just thought that using
> HTTP-Authentication was one of the more secure ways of a login system?
> But i have heared not thats not the case, so i might go for a login
> system with sessions instead, or cookies. What would u use and why? What
> excactly do u mean with timeouts?
>
> > I know this hasnt been any help, sorry!
>
> Thats okay;-) Keeps the discusion alive;-)
>
> Best regards,
>
> Davy Obdam,
> mailto:info@;davyobdam.com
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi Cam,
Thanks for your reaction. I was wondering if u could send me some
example code maybe;-)
I am a bit new to session based login systems myself;-) Thanks already.
Best regards,
Davy Obdam,
mailto:info@;davyobdam.com
> David and Davy,
>
> My two bobs worth - I like to use sessions myself usually, I
> suppose because it means my scripts are controlling access
> rather than the server or the operating system. With sessons
> you can store all sorts of variables such as exactly what the
> user can do in a list of tasks rather than just "will we let
> him in or not". The user submits a form with his username
> and password, I look them up in a database, and if I find him
> I grab a "task list" of things he is allowed to do on the
> site (could be different for every user) and store them in a
> session. Everytime he tries to go somewhere on the site the
> script first checks if that task is in his list -
> furthermore, you can kick him off if he has overstayed or
> there has been no action for a period of time - also gives
> you the opportunity to log or time his total activity on the site.
>
> I wrap each script in a small "include" routine which does
> all this so its
> no big deal in terms of coding effort or extra overhead.
> You might like to
> go this road rather than the simpler but more restrictive
> HTTP auth. way.
>
> Cheers CD
--- End Message ---
--- Begin Message ---
You could also take a look at the printer extension for PHP
http://php.net/printer
These functions are available for server side printing, when PHP is running on a Win32
box.
- Frank
> it depends on your printer & system.
>
> if you want to use printer commands directly in your code then u must know
> the commands for your printer. the algorithm will be:
>
> 1. Initialize printer ( <ESC>@ is the command for most dot matrix printers)
> .
> 2. Set paper size, tabs (vertical & horizontal) etc. using appropriate
> printer commands
> 3. Send the data including embedded printer commands for advancing paper
> etc.
>
> quite some time back, i made a program in clipper for printing purchase
> orders on dot matrix printer, its still working fine.
>
> the simplest printer commands are of dot matrix printers, for other inkjet /
> laser printers the commands vary from manufacturer to manufacturer.
>
> Alternatively, i think MS-Access is very good for this application, all u
> need is to design a report, where u can specify the paper size, where to
> print data etc. You don't have to worry about printer commands in this
> case.
>
> regds,
> -----Original Message-----
> From: Brian McGarvie [mailto:brian.mcgarvie@;anypurposeloans.co.uk]
> Sent: Wednesday, October 16, 2002 20:18
> To: [EMAIL PROTECTED]
> Subject: printer_ functions...
>
>
> I have a specific problem ;)
>
> I have been asked if it is possible to write a 'simple' application that
> will print onto Bank Cheques - they will be supplied on a continuous
> roll
> aparently, so it'll be one cheque followed by another etc perferated
> inbetween...
>
> So my question is has anyone ever tried this or similar? or even if you
> have'nt has anyone got any pointers to start me off?
>
> Alternativley is there any software already out there?
>
> I have been looking but can only find things like Sage, which ha all the
> stock controll etc etc which is not required, the application will
> simple be
> to take a series name's & ammount's and print the cheques...
>
> Thanks in advance...
>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---