⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isapimagick.c

📁 下载来的一个看图软件的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                         I S A P I M A G I C K                               %%                                                                             %%                                                                             %%      A shim layer to give command line utilities an ISAPI interface.        %%                                                                             %%                                                                             %%                                                                             %%                              Software Design                                %%                           William T. Radcliffe                              %%                                June 2000                                    %%                                                                             %%                                                                             %%  Copyright (C) 2000 ImageMagick Studio, a non-profit organization dedicated %%  to making software imaging solutions freely available.                     %%                                                                             %%  Permission is hereby granted, free of charge, to any person obtaining a    %%  copy of this software and associated documentation files ("ImageMagick"),  %%  to deal in ImageMagick without restriction, including without limitation   %%  the rights to use, copy, modify, merge, publish, distribute, sublicense,   %%  and/or sell copies of ImageMagick, and to permit persons to whom the       %%  ImageMagick is furnished to do so, subject to the following conditions:    %%                                                                             %%  The above copyright notice and this permission notice shall be included in %%  all copies or substantial portions of ImageMagick.                         %%                                                                             %%  The software is provided "as is", without warranty of any kind, express or %%  implied, including but not limited to the warranties of merchantability,   %%  fitness for a particular purpose and noninfringement.  In no event shall   %%  ImageMagick Studio be liable for any claim, damages or other liability,    %%  whether in an action of contract, tort or otherwise, arising from, out of  %%  or in connection with ImageMagick or the use or other dealings in          %%  ImageMagick.                                                               %%                                                                             %%  Except as contained in this notice, the name of the ImageMagick Studio     %%  shall not be used in advertising or otherwise to promote the sale, use or  %%  other dealings in ImageMagick without prior written authorization from the %%  ImageMagick Studio.                                                        %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  This is a simple shim that provides an ISAPI layer for calling into any of%  the normal command line utilities.*/#include "magick.h"#include "define.h"#include <httpext.h>#include <stdio.h>#include <string.h>#include <stdarg.h>#include <time.h>// A critical section handle is used to protect global// state propertiesCRITICAL_SECTION gCS;// Global path to this DLLTCHAR gszAppPath[MAX_PATH];/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%  D l l M a i n                                                              %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  DllMain - ISAPI / Win32 API method. This the the entry and exit%  point for the extension. It is called when the extension is loaded%  and unloaded by IIS. This is where state properties need to be %  retrieved from and store on persistant storage.%%*/BOOL APIENTRY DllMain( HANDLE hModule,      DWORD ul_reason_for_call, LPVOID lpReserved ){  switch( ul_reason_for_call ) {  case DLL_PROCESS_ATTACH:     {      InitializeCriticalSection(&gCS);      gszAppPath[0]='\0';      if (!GetModuleFileName (hModule, gszAppPath, MAX_PATH))        return FALSE;      InitializeMagick(gszAppPath);      break;    }  case DLL_PROCESS_DETACH:		{		  DeleteCriticalSection(&gCS);		  break;		}  case DLL_THREAD_ATTACH:  case DLL_THREAD_DETACH:  default:    break;  }  return TRUE;}/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%  G e t E x t e n s i o n V e r s i o n                                      %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  GetExtensionVersion - ISAPI / Win32 API method. This method%  is required by IIS. It is called following the process load%  to ensure that the  extension is compatable with the server.%*/BOOL WINAPI GetExtensionVersion( HSE_VERSION_INFO *pVer ){  pVer->dwExtensionVersion = MAKELONG(	HSE_VERSION_MINOR,										HSE_VERSION_MAJOR );  lstrcpyn( pVer->lpszExtensionDesc,            "ISAPIMagick for IIS", HSE_MAX_EXT_DLL_NAME_LEN );  return TRUE;} /*  Include the convert mainline as a subroutine*/#define Usage convert_Usage#define main convert_main#include "utilities\convert.c"#undef Usage#undef main/*  Include the combine mainline as a subroutine*/#define Usage combine_Usage#define main combine_main#include "utilities\composite.c"#undef Usage#undef main/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%  C G I F i f o                                                              %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Method CGIFifo is the default output stream handler for CGI usage. It is%  called by the stream subsystem whenever a buffer of data needs to be sent%  to the output.It receives a pointer to the image as well as the buffer%  of data and its length.%%  The format of the HttpUnescape method is:%%      int CGIFifo(const Image *image,const void *data,const size_t length)%%  A description of each parameter follows:%%    o image:  A pointer to the image being sent to the output stream.%%    o data: A pointer to the buffer of data to be sent.%%    o length: The length of the buffer of data to be sent.%*/int CGIFifo(const Image *image,const void *data,const size_t length){  EXTENSION_CONTROL_BLOCK *pECB;  size_t tlen=length;  pECB = (EXTENSION_CONTROL_BLOCK *)image->client_data;  pECB->WriteClient( pECB->ConnID, (char *)data, &tlen, 0);  return(tlen);}/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%  D e c o d e H e x                                                          %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Method DecodeHex decodes a hexadecimal string. It stops after outmax%  characters or when an invalid hex character is reached. It also sets%  the input pointer to the first unprocessed character.  Returns the%  the result as a binary number.%%  The format of the HttpUnescape method is:%%      int DecodeHex(const char **input,size_t outmax)%%  A description of each parameter follows:%%    o input:  Specifies the string to be converted.%%    o outmax: Specifies the maximum number of characters to process.%*/int DecodeHex(const char **input,size_t outmax){  static char    hex_to_bin [128] = {      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,    /*            */      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,    /*            */      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,    /*            */       0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,    /*   0..9     */      -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,    /*   A..F     */      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,    /*            */      -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,    /*   a..f     */      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };  /*            */  int    nextch;  size_t    index,    result;  assert(input != (const char **) NULL);  assert((*input) != (const char *) NULL);  index  = 0;  result = 0;  while (outmax == 0 || index < outmax)  {    nextch = (*input) [index] & 127;    if (nextch && hex_to_bin [nextch] != -1)    {      result = result * 16 + hex_to_bin [nextch];      index++;    }    else      break;  }  (*input) += index;  return (result);}/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%  H t t p U n e s c a p e                                                    %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Method HttpUnescape removes HTTP escaping from a string. If the result%  string is NULL, it modifies the source string in place, else fills-in%  the result string. This method returns the resulting string. End-of-line%  sequences (%0A%0D) are stored as a single new-line character, i.e.%  carriage-returns (%0D) are not stored.%%  The format of the HttpUnescape method is:%%      char *HttpUnescape(char *string,char *result)%%  A description of each parameter follows:%%    o string:  Specifies the string to be converted.%%    o result:  Specifies the destination for the converted result. A NULL%               indicates that the conversion happens "in-place".%*/char *HttpUnescape(char *string,char *result){  char    *target; /* Where we store the result */  assert(string != (char *) NULL);  if (!result) /* If result string is null, */    result = string; /* modify in place */  target = result;  while (*string)  {    if (*string == '%'  /* Unescape %xx sequence */          && isxdigit(string [1]) && isxdigit(string [2]))      {        string++;        *target = DecodeHex ((const char **) &string, 2);        if (*target != '\r')          target++; /* We do not store CR's */      }    else      {        if (*string == '+') /* Spaces are escaped as '+' */          *target++ = ' ';        else          *target++ = *string; /* Otherwise just copy */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -