On Mar 10, 2005, at 12:20, D.Walsh wrote:
On Mar 10, 2005, at 10:56, Johannes Schlueter wrote:
Hi,
I don't know why Hartmut (Maintainer of PECL_Gen) wrote only me, so FYI:
---------- Forwarded Message ----------
Subject: Re: [PHP-DEV] LOGO_GUID Date: Thursday 10 March 2005 15:48 From: Hartmut Holzgraefe <[EMAIL PROTECTED]> To: Johannes Schlueter <[EMAIL PROTECTED]>
Johannes Schlueter wrote:D . Walsh wrote:Is there also a utility to generate the the logo in the required text
syntax or should I just create a quick hack to get the job done?
as I wrote in a posting some weeks ago: PECL_Gen has Logo-Support. Even if
you won't use PECL_Gen for your extension you could check and use it's
code.
see member function h_code() in PECL_Gen/Element/Logo.php
http://cvs.php.net/co.php/pecl/PECL_Gen/Element/Logo.php?r=1.1
-- Hartmut Holzgraefe <[EMAIL PROTECTED]>
While I tried to install PECL_Gen as directed, by removing void.c from the xml file and issuing "pear install package.xml", I don't believe it installed properly because it doesn't appear to be working.
I am waiting to install this package from instructions someone can provide to install PECL_Gen on a Macintosh computer and the instructions have been tried and tested and will work without question.
OK so I've looked at the code from the link provided and while it looks like it's suppose to do something, I am unable to verify what it can actually do because I am unable to install a working copy of PECL_Gen in PHP 4.3.10 on a Macintosh computer based on the instructions I have been provided so any reference to anything this package actually does is hearsay because I have no proof it can do anything if I can't install it.
Better yet, I'll just write a small app in C that will take a gif file and make the appropriate text file with the proper information, this would take me considerably less time than playing with a package that doesn't work.
I'll post the source for critique when I'm done, maybe someone else may need it if they can't get PECL_Gen working or want a faster solution.
-- Dale
Here's a working solution, build with the command gcc create_php_logo.c -o create-php-logo
filename: create_php_logo.c
<FILE START>
/ ************************************************************************
*
* Syntax: create_logo_file filename
*
************************************************************************ /
#include <stdio.h> #include <string.h> #include <grp.h> #include <pwd.h>
#define NUM_CHARS 10
/ ************************************************************************ /
void create_logo_file (char * prog_name, char * filename);
/ ************************************************************************ /
main(int argc, char * argv[]) { char *prog_name=argv[0];
if (argc != 2) { printf("\n\t%s syntax:\n\n", argv[0]); printf("\t\t%s filename\n\n", argv[0]); exit(0); } create_logo_file(prog_name, argv[1]); }
/ ************************************************************************
*
* The program proper.
*
************************************************************************ /
void create_logo_file(char * prog_name, char * filename) { /* Open the file */ char *logo_name; char *logo_file_name; char *last_slash; char *stop; /* Make a copy of the string */ logo_name = strdup(filename); last_slash = strrchr (logo_name, '/');
if (last_slash) logo_name = last_slash + 1;
if (!logo_name) { /* !!! Out of RAM */ exit(33); }
/* Find the full-stop */ stop = strrchr (logo_name, '.');
if (!stop || strcmp (stop, ".gif")) { /* !!! Couldn't find .gif */ printf("\nNot a \"gif\" or file: %s not found.\n\n", filename); exit(22); }
/* Truncate the string */ *stop = '\0';
malloc(logo_name); printf("\nProcessing: %s\n\n", filename);
logo_file_name = (char *) malloc (stop - logo_name + 7);
if (!logo_file_name) { /* !!! Out of RAM */ exit(33); }
/* logo_file_name now points to "bad_logo.h" */ strcpy (logo_file_name, logo_name); strcat (logo_file_name, "_logo.h");
int c=' '; /* Character read from the file */
int outfile, i=0, status=0; int lines=3; /* lines wrote to the file */
FILE *ptr; /* Pointer to the file. */
FILE *fileout; /* Pointer to the file. */
printf("opening %s\n", filename); ptr = fopen(filename,"r"); if ( ferror(ptr) ) { printf("%s: Unable to open %s\n\n", prog_name, filename); exit(0); }
printf("creating %s\n", logo_file_name); fileout = fopen(logo_file_name,"w"); /* Open the file */ if (!fileout) { fclose(ptr); fclose(fileout); printf("%s: Unable to create %s\n\n", prog_name, logo_file_name); exit(24); }
printf("writing %s", logo_file_name);
/* little heading. */
fprintf(fileout,"#define CONTEXT_TYPE_IMAGE_GIF \"Content-Type: image/gif\"\n\n", logo_name);
fprintf(fileout,"unsigned char %s_logo[] = {\n\t", logo_name);
/* Read one character at a time checking for the End Of File. */ while ((c = fgetc(ptr)) != EOF ) { if (i == NUM_CHARS){ i= 0; ++lines; printf("."); fprintf(fileout, ",\n\t"); } else { if (i > 0) { fprintf(fileout, ", "); } } i++; fprintf(fileout,"%3ld", c); } /* Display the current line */ printf("\n"); fprintf(fileout," };\n");
/* Close the files. */ fclose(ptr); fclose(fileout);
/* Notify all done. */ printf("Wrote %4d lines to %s\n\n", lines, logo_file_name);
/* Free things up. */
if (chmod(logo_file_name, 0755)) { printf("Unable to set permissions for %s\n", logo_file_name); status = 2; } struct group *grp = getgrnam("wheel"); struct passwd *user = getpwnam("websrvr");
if (chown(logo_file_name, user->pw_uid, grp->gr_gid)) { printf("Unable to set user/group for %s\n", logo_file_name); status = 3; }
free (logo_file_name); free (logo_name); exit(status);
}
<FILE END>
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php