CVS update: php3/functions
| From: | thies | Date: | Fri, 08 Jan 1999 17:03:59 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3409@lists.php.net to get a copy of this message | ||
Date: Friday January 8, 1999 @ 12:03
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv1729/functions
Modified Files:
iptc.c
Log Message:
iptcparse would sometimes start in the middle of a tag
iptcembed forgot to send the headers, and forgot to remove an old APP13 marker
Index: php3/functions/iptc.c
diff -c php3/functions/iptc.c:1.12 php3/functions/iptc.c:1.13
*** php3/functions/iptc.c:1.12 Fri Jan 8 09:43:20 1999
--- php3/functions/iptc.c Fri Jan 8 12:03:57 1999
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: iptc.c,v 1.12 1999/01/08 14:43:20 thies Exp $ */
/*
* Functions to parse & compse IPTC data.
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: iptc.c,v 1.13 1999/01/08 17:03:57 thies Exp $ */
/*
* Functions to parse & compse IPTC data.
***************
*** 155,162 ****
/* get marker byte, swallowing possible padding */
do {
! if ((c = php3_iptc_get1(fp,spool,spoolbuf)) == EOF)
return M_EOI; /* we hit EOF */
} while (c == 0xff);
return (unsigned int) c;
--- 155,166 ----
/* get marker byte, swallowing possible padding */
do {
! c = php3_iptc_get1(fp,0,0);
! if (c == EOF)
return M_EOI; /* we hit EOF */
+ else
+ if (c == 0xff)
+ php3_iptc_put1(fp,spool,c,spoolbuf);
} while (c == 0xff);
return (unsigned int) c;
***************
*** 172,179 ****
pval *iptcdata, *jpeg_file, *spool_flag;
FILE *fp;
unsigned int marker;
! unsigned int spool = 0, done = 0, inx, len, nlen;
! unsigned char *spoolbuf,*poi=0;
struct stat sb;
switch(ARG_COUNT(ht)){
--- 176,183 ----
pval *iptcdata, *jpeg_file, *spool_flag;
FILE *fp;
unsigned int marker;
! unsigned int spool = 0, done = 0, inx, len;
! unsigned char *spoolbuf=0,*poi=0;
struct stat sb;
switch(ARG_COUNT(ht)){
***************
*** 208,236 ****
RETURN_FALSE;
}
len = iptcdata->value.str.len;
if (spool < 2) {
fstat(fileno(fp),&sb);
-
- nlen = len + 30 + sb.st_size;
! poi = spoolbuf = emalloc(nlen);
if (! spoolbuf) {
fclose(fp);
RETURN_FALSE;
}
! } else { /* to make gcc happy... */
! nlen = 0;
! spoolbuf = 0;
! }
- if (spool > 0) {
- php3_header();
- }
-
-
if (php3_iptc_get1(fp,spool,poi?&poi:0) != 0xFF) {
fclose(fp);
RETURN_FALSE;
--- 212,240 ----
RETURN_FALSE;
}
+ if (spool > 0)
+ if (!php3_header()){ /* we got a HEAD request. */
+ if (spool == 2){
+ RETURN_TRUE; /* we only wanted to spool - report success. */
+ } else
+ if (spool == 1) {
+ spool = 0; /* we wanted the file to be spooled/returned, just return it */
+ }
+ }
+
len = iptcdata->value.str.len;
if (spool < 2) {
fstat(fileno(fp),&sb);
! poi = spoolbuf = emalloc(len + 30 + sb.st_size);
if (! spoolbuf) {
fclose(fp);
RETURN_FALSE;
}
! }
if (php3_iptc_get1(fp,spool,poi?&poi:0) != 0xFF) {
fclose(fp);
RETURN_FALSE;
***************
*** 243,254 ****
while (!done) {
marker = php3_iptc_nextmarker(fp,spool,poi?&poi:0);
switch (marker) {
! case M_EOI:
done = 1;
break;
case M_APP0:
php3_iptc_skip_variable(fp,spool,poi?&poi:0);
psheader[ 2 ] = (len+28)>>8;
--- 247,269 ----
while (!done) {
marker = php3_iptc_nextmarker(fp,spool,poi?&poi:0);
+
+ if (marker == M_EOI) { /* EOF */
+ break;
+ } else if (marker != M_APP13) {
+ php3_iptc_put1(fp,spool,marker,poi?&poi:0);
+ }
+
switch (marker) {
! case M_APP13:
! /* we are going to write a new APP13 marker, so don't output the old one */
! php3_iptc_skip_variable(fp,0,0);
! php3_iptc_read_remaining(fp,spool,poi?&poi:0);
done = 1;
break;
case M_APP0:
+ /* APP0 is in each and every JPEG, so when we hit APP0 we insert our new APP13! */
php3_iptc_skip_variable(fp,spool,poi?&poi:0);
psheader[ 2 ] = (len+28)>>8;
***************
*** 262,269 ****
--- 277,288 ----
for (inx = 0; inx < len; inx++)
php3_iptc_put1(fp,spool,iptcdata->value.str.val[inx],poi?&poi:0);
+ break;
+ case M_SOS:
+ /* we hit data, no more marker-inserting can be done! */
php3_iptc_read_remaining(fp,spool,poi?&poi:0);
+ done = 1;
break;
default:
***************
*** 275,281 ****
fclose(fp);
if (spool < 2) {
! RETVAL_STRINGL(spoolbuf,nlen,0);
} else {
RETURN_TRUE;
}
--- 294,300 ----
fclose(fp);
if (spool < 2) {
! RETVAL_STRINGL(spoolbuf,poi - spoolbuf,0);
} else {
RETURN_TRUE;
}
***************
*** 303,318 ****
inheader = 0; /* have we already found the IPTC-Header??? */
tagsfound = 0; /* number of tags already found */
! while (inx < length) {
! if (buffer[ inx++ ] != 0x1c) { /* skip all junk */
! if (inheader) {
! break; /* we ran against some data which does not conform to IPTC - stop parsing! */
! } else {
! continue;
! }
} else {
! inheader = 1;
}
if ((inx + 4) >= length)
break;
--- 322,339 ----
inheader = 0; /* have we already found the IPTC-Header??? */
tagsfound = 0; /* number of tags already found */
! while (inx < length) { /* find 1st tag */
! if ((buffer[inx] == 0x1c) && (buffer[inx+1] == 0x02)){
! break;
} else {
! inx++;
}
+ }
+
+ while (inx < length) {
+ if (buffer[ inx++ ] != 0x1c) {
+ break; /* we ran against some data which does not conform to IPTC - stop parsing! */
+ }
if ((inx + 4) >= length)
break;
***************
*** 320,330 ****
dataset = buffer[ inx++ ];
recnum = buffer[ inx++ ];
! if (buffer[ inx ] & (unsigned char) 0x80) {
len = (((long) buffer[ inx + 2 ]) << 24) + (((long) buffer[ inx + 3 ]) << 16) +
(((long) buffer[ inx + 4 ]) << 8) + (((long) buffer[ inx + 5 ]));
inx += 6;
! } else {
len = (((unsigned short) buffer[ inx ])<<8) | (unsigned short)buffer[ inx+1 ];
inx += 2;
}
--- 341,351 ----
dataset = buffer[ inx++ ];
recnum = buffer[ inx++ ];
! if (buffer[ inx ] & (unsigned char) 0x80) { /* long tag */
len = (((long) buffer[ inx + 2 ]) << 24) + (((long) buffer[ inx + 3 ]) << 16) +
(((long) buffer[ inx + 4 ]) << 8) + (((long) buffer[ inx + 5 ]));
inx += 6;
! } else { /* short tag */
len = (((unsigned short) buffer[ inx ])<<8) | (unsigned short)buffer[ inx+1 ];
inx += 2;
}
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net