📄 cgimagick.c
字号:
if (getenv("PATH_TRANSLATED") != (char *) NULL) { strcpy(szPathTranslated,getenv("PATH_TRANSLATED")); GetFileMimeType(szPathTranslated, szMimeType,MaxTextExtent); } else strcpy(szMimeType,"application/ocetet-stream"); for (argc_hw=1; argc_hw < argc; argc_hw++) { char *blob_data; size_t blob_length; int mode=0; argv_hw = &argv[argc_hw]; if (LocaleNCompare("-login",argv[argc_hw],8) == 0) { for (i=argc_hw+1; i < argc; i++) { if (LocaleNCompare("login-",argv[i],8) == 0) break; }#if defined(WIN32) if ((i-argc_hw)>3) { char *domain=argv_hw[1], *userid=argv_hw[2], *passwd=argv_hw[3]; HANDLE hToken; BOOL status; status = LogonUser(userid,domain,passwd, LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&hToken); if (status) { status = ImpersonateLoggedOnUser(hToken); if (status) impersonating=True; else errmsg = NTGetLastError(); } else errmsg = NTGetLastError(); }#endif argc_hw = i; argv_hw = &argv[argc_hw]; } if (LocaleNCompare("-convert",argv[argc_hw],8) == 0) { char *option; Image *image; ImageInfo *image_info; image=(Image *) NULL; image_info=(ImageInfo *) NULL; for (i=argc_hw+1; i < argc; i++) { option=argv[i]; if (LocaleNCompare("convert-",option,8) == 0) break; if ((list_position > 0) && (*option != '-') && (*option != '+')) { char *text; text=TranslateText(info_list[list_position-1], imag_list[list_position-1],option); if (text != (char *) NULL) { LiberateMemory((void **) &(argv[i])); argv[i]=text; } } else if (LocaleNCompare("-xbdat",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&blob_data); mode=1; } else if (LocaleNCompare("-xblen",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&blob_length); mode=1; } else if (LocaleNCompare("-xfunc",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *) CGIFifo; mode=2; } else if (LocaleNCompare("-xctxt",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *) NULL; mode=2; } else if (LocaleNCompare("-xinfo",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&image_info); mode=3; } else if (LocaleNCompare("-ximag",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&image); mode=3; } } if (mode==0) { convert_main(i-argc_hw,argv_hw); /* normal case were image was written to a disk file */ } else if (mode==1) { blob_length=8192; convert_main(i-argc_hw,argv_hw); /* returns an a blob and its length */ FormatString(prefix, "HTTP/1.0 200 Ok\nContent-Length: %u\r\nContent-Type: %s\n\n", blob_length,szMimeType); fwrite(prefix,1,strlen(prefix),stdout); fwrite(blob_data,1,blob_length,stdout); } else if (mode==2) { FormatString(prefix, "HTTP/1.0 200 Ok\nContent-Type: %s\n\n",szMimeType); fwrite(prefix,1,strlen(prefix),stdout); convert_main(i-argc_hw,argv_hw); /* returns nothing - image has been stream already */ } else if (mode==3) { convert_main(i-argc_hw,argv_hw); /* returns an image_info and image structure */ if ((list_position >= 0) && (list_position < IMAGELIST_SIZE) && (image != (Image *) NULL) && (image_info != (ImageInfo *) NULL)) { status=WriteImage(image_info,image); if (status == True) { imag_list[list_position]=image; image=(Image *) NULL; info_list[list_position]=image_info; image_info=(ImageInfo *) NULL; list_position++; } } } argc_hw = i; argv_hw = &argv[argc_hw]; } if (LocaleNCompare("-combine",argv[argc_hw],8) == 0) { char *option; Image *image; ImageInfo *image_info; image=(Image *) NULL; image_info=(ImageInfo *) NULL; for (i=argc_hw+1; i < argc; i++) { option=argv[i]; if (LocaleNCompare("combine-",argv[i],8) == 0) break; if ((list_position > 0) && (*option != '-') && (*option != '+')) { char *text; text=TranslateText(info_list[list_position-1], imag_list[list_position-1],option); if (text != (char *) NULL) { LiberateMemory((void **) &(argv[i])); argv[i]=text; } } else if (LocaleNCompare("-xbdat",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&blob_data); mode=1; } else if (LocaleNCompare("-xblen",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&blob_length); mode=1; } else if (LocaleNCompare("-xfunc",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)CGIFifo; mode=2; } else if (LocaleNCompare("-xctxt",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)NULL; mode=2; } else if (LocaleNCompare("-xinfo",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&image_info); mode=3; } else if (LocaleNCompare("-ximag",option,6) == 0) { i++; LiberateMemory((void **) &(argv[i])); argv[i]=(char *)(&image); mode=3; } } if (mode==0) { combine_main(i-argc_hw,argv_hw); /* normal case were image was written to a disk file */ } else if (mode==1) { blob_length=8192; combine_main(i-argc_hw,argv_hw); /* returns an a blob and its length */ FormatString(prefix, "HTTP/1.0 200 Ok\nContent-Length: %u\r\nContent-Type: %s\n\n", blob_length,szMimeType); fwrite(prefix,1,strlen(prefix),stdout); fwrite(blob_data,1,blob_length,stdout); } else if (mode==2) { FormatString(prefix, "HTTP/1.0 200 Ok\nContent-Type: %s\n\n",szMimeType); fwrite(prefix,1,strlen(prefix),stdout); combine_main(i-argc_hw,argv_hw); /* returns nothing - image has been stream already */ } else if (mode==3) { combine_main(i-argc_hw,argv_hw); /* returns an image_info and image structure */ if ((list_position >= 0) && (list_position < IMAGELIST_SIZE) && (image != (Image *) NULL) && (image_info != (ImageInfo *) NULL)) { status=WriteImage(image_info,image); if (status == True) { imag_list[list_position]=image; image=(Image *) NULL; info_list[list_position]=image_info; image_info=(ImageInfo *) NULL; list_position++; } } } argc_hw = i; argv_hw = &argv[argc_hw]; } } } } for (i=0; i < IMAGELIST_SIZE; i++) { if (imag_list[i] != (Image *) NULL) DestroyImage(imag_list[i]); if (info_list[i] != (ImageInfo *) NULL) DestroyImageInfo(info_list[i]); } if (impersonating==True) {#if defined(WIN32) status = RevertToSelf(); if (status) impersonating=False; else errmsg = NTGetLastError();#endif } LiberateMemory((void **) &argv); Exit(0); return(False);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -