/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a g i c k T o M i m e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method MagickToMime returns the officially registered (or de facto) MIME % media-type corresponding to a magick string. If there is no registered % media-type, then the string "image/x-magick" (all lower case) is returned. % The returned string must be deallocated by the user. % % The format of the MagickToMime method is: % % char *MagickToMime(const char *magick) % % A description of each parameter follows. % % o magick: GraphicsMagick format specification "magick" tag. % % */ MagickExport char * MagickToMime(const char *magick) { typedef struct _MediaType { const char *magick, *media; } MediaType; char media[MaxTextExtent]; MediaType *entry; static MediaType MediaTypes[] = { { "avi", "video/avi" }, { "cgm", "image/cgm;Version=4;ProfileId=WebCGM" }, /* W3 WebCGM */ { "dcm", "application/dicom" }, /* Incomplete. See RFC 3240 */ { "epdf", "application/pdf" }, { "epi", "application/postscript" }, { "eps", "application/postscript" }, { "eps2", "application/postscript" }, { "eps3", "application/postscript" }, { "epsf", "application/postscript" }, { "ept", "application/postscript" }, { "fax", "image/g3fax" }, { "fpx", "image/vnd.fpx" }, { "g3", "image/g3fax" }, { "gif", "image/gif" }, { "gif87", "image/gif" }, { "jpeg", "image/jpeg" }, { "mng", "video/x-mng" }, { "mpeg", "video/mpeg" }, { "png", "image/png" }, { "pdf", "application/pdf" }, { "ps", "application/postscript" }, { "ps2", "application/postscript" }, { "ps3", "application/postscript" }, { "svg", "image/svg+xml" }, { "tif", "image/tiff" }, { "tiff", "image/tiff" }, { "wbmp", "image/vnd.wap.wbmp" }, { (char *) NULL, (char *) NULL } }; for (entry=MediaTypes; entry->magick != (char *) NULL; entry++) if (LocaleCompare(entry->magick,magick) == 0) return(AllocateString(entry->media)); FormatString(media,"image/x-%.1024s",magick); LocaleLower(media+8); return(AllocateString(media)); }
Bool LoadBlakodString(FILE *f,int len_str,int string_id) { string_node *snod; /* note: new_str is not a null-terminated string */ if (AllocateString() != string_id) { eprintf("LoadString didn't make string id %i\n",string_id); return False; } snod = GetStringByID(string_id); if (len_str != 0) { snod->data = (char *)AllocateMemory(MALLOC_ID_STRING,len_str+1); if (!fread(snod->data, 1, len_str, f)) return False; snod->data[len_str] = '\0'; } else { snod->data = NULL; } snod->len_data = len_str; return True; }
extern void PrintCurrentArgumentValue(CommandMaster *commandmaster, BaseArgumentType *value) { CHAR *string,*val; string = AllocateString(LINELENGTH); sprintf(string,"Argument: %s = ",value->Name); PrintOutputString(string,commandmaster); switch(value->Type) { case INT_VALUE: sprintf(string,"%d\n",value->Integer_Value); break; case FLOAT_VALUE: sprintf(string,"%f\n",value->Float_Value); break; case STRING_VALUE: case INPUT_FILE_NAME: case OUTPUT_FILE_NAME: val = ConsiderAliases(value->String_Value,commandmaster); sprintf(string,"%s\n",val); Free(val); break; } PrintOutputString(string,commandmaster); Free(string); }
element* AllocateElement(int age, char *name) { element *p = (element *) malloc(sizeof(element)); p->age = age; p->name = AllocateString(name); p->nextAge = NULL; p->nextName = NULL; return p; }
extern CHAR *ProduceFileName(CHAR *directory, CHAR *name, CHAR *suffix) { CHAR *filename; filename = AllocateString(LINELENGTH); sprintf(filename,"%s/%s.%s",directory,name,suffix); EliminateBlanks(filename); return(filename); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t M o n t a g e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method GetMontageInfo initializes the MontageInfo structure. % % The format of the GetMontageInfo method is: % % void GetMontageInfo(MontageInfo *montage_info) % % A description of each parameter follows: % % o montage_info: Specifies a pointer to a MontageInfo structure. % % */ Export void GetMontageInfo(MontageInfo *montage_info) { assert(montage_info != (MontageInfo *) NULL); *montage_info->filename='\0'; montage_info->geometry=AllocateString(DefaultTileGeometry); montage_info->tile=AllocateString("6x4"); (void) QueryColorDatabase("#c0c0c0",&montage_info->background_color); (void) QueryColorDatabase(BorderColor,&montage_info->border_color); (void) QueryColorDatabase("#bdbdbd",&montage_info->matte_color); montage_info->title=(char *) NULL; montage_info->frame=(char *) NULL; montage_info->texture=(char *) NULL; montage_info->pen=(char *) NULL; montage_info->font=(char *) NULL; montage_info->pointsize=atof(DefaultPointSize); montage_info->border_width=0; montage_info->gravity=CenterGravity; montage_info->shadow=False; montage_info->compose=ReplaceCompositeOp; }
//internal creation called once a string and a bitmap font image have been properly //setup LTRESULT CTextureString::InternalCreate(const wchar_t* pszString, CTextureStringImage* pTextureImage) { //first off setup any string data if(!AllocateString(pszString)) return LT_OUTOFMEMORY; // steal the texture image from the other string m_TextureImage = pTextureImage; if(m_TextureImage == NULL) { //we have a null texture image. This is bad if we have any characters if(m_nNumCharacters > 0) { FreeData(); return LT_INVALIDPARAMS; } else { //we have no characters to worry about return LT_OK; } } //now run through and patch each character to the appropriate glyph, we must fail if any glyph is not //found for(uint32 nCurrChar = 0; nCurrChar < m_nNumCharacters; nCurrChar++) { //cache some information wchar_t cChar = pszString[nCurrChar]; CTextureStringChar& TexChar = m_pCharacters[nCurrChar]; //and now setup the texture character to an initial position and associate it with a glyph TexChar.m_nXPos = 0; TexChar.m_nYPos = 0; TexChar.m_pGlyph = m_TextureImage->GetGlyph(cChar); //check for a missing glyph if(TexChar.m_pGlyph == NULL) { FreeData(); return LT_INVALIDPARAMS; } } //so far so good. Now just place the characters if(!ClearFormatting()) { FreeData(); return LT_ERROR; } return LT_OK; }
LPSUBSET Subsets_CopySubset (LPSUBSET sub, BOOL fCreateIfNULL) { LPSUBSET subCopy = NULL; if (sub != NULL) { subCopy = New (SUBSET); memset (subCopy, 0x00, sizeof(SUBSET)); lstrcpy (subCopy->szSubset, sub->szSubset); subCopy->fModified = sub->fModified; size_t cch; if (sub->pszMonitored) { cch = 1; for (LPTSTR psz = sub->pszMonitored; *psz; psz += 1+lstrlen(psz)) cch += 1+lstrlen(psz); subCopy->pszMonitored = AllocateString (cch); memcpy (subCopy->pszMonitored, sub->pszMonitored, sizeof(TCHAR)*cch); } if (sub->pszUnmonitored) { cch = 1; for (LPTSTR psz = sub->pszUnmonitored; *psz; psz += 1+lstrlen(psz)) cch += 1+lstrlen(psz); subCopy->pszUnmonitored = AllocateString (cch); memcpy (subCopy->pszUnmonitored, sub->pszUnmonitored, sizeof(TCHAR)*cch); } } else if (fCreateIfNULL) { subCopy = New (SUBSET); memset (subCopy, 0x00, sizeof(SUBSET)); } return subCopy; }
/*f key = ProduceIndexKeyword(id) ** ** DESCRIPTION ** id: The id of the SetOfKeywords ** key: The key to be used in reading or writing to the database ** ** Given the id of the SetOfKeywords, the DbaseKeyword is ** produced. ** ** REMARKS ** */ static DbaseKeyword *ProduceIndexKeyword(INT id) { CHAR *string; DbaseKeyword *keyword; INT size; string = AllocateString(LINELENGTH); sprintf(string,"%s%d",DBINDEXROOTNAME,id); size = strlen(string) + 1; keyword = AllocateDbaseKeyword; CreateDbaseKeyword(keyword,id,string, size,string); Free(string); return(keyword); }
int CreateStringWithLen(char *buf,int len) { int string_id; string_node *snod; /* note: new_str is NOT null-terminated */ string_id = AllocateString(); snod = GetStringByID(string_id); snod->data = (char *)AllocateMemory(MALLOC_ID_STRING,len+1); memcpy(snod->data,buf,len); snod->len_data = len; snod->data[snod->len_data] = '\0'; return string_id; }
LPSUBSET Subsets_LoadSubset (LPTSTR pszCell, LPTSTR pszSubset) { LPSUBSET sub = NULL; HKEY hk; if ((hk = OpenSubsetsSubKey (pszCell, pszSubset, FALSE)) != NULL) { DWORD dwMonitored; DWORD dwSize; DWORD dwType; dwSize = sizeof(dwMonitored); if (RegQueryValueEx (hk, REGVAL_INCLUSIVE, 0, &dwType, (LPBYTE)&dwMonitored, &dwSize) == 0) { sub = New (SUBSET); memset (sub, 0x00, sizeof(SUBSET)); lstrcpy (sub->szSubset, pszSubset); sub->fModified = FALSE; LPTSTR *ppsz; ppsz = (dwMonitored) ? &sub->pszMonitored : &sub->pszUnmonitored; for (size_t iIndex = 0; ; ++iIndex) { TCHAR szServer[ cchNAME ]; dwSize = sizeof(szServer); if (RegEnumValue (hk, (DWORD)iIndex, szServer, &dwSize, 0, NULL, NULL, NULL) != 0) break; if (szServer[0] && lstrcmpi (szServer, REGVAL_INCLUSIVE)) FormatMultiString (ppsz, FALSE, TEXT("%1"), TEXT("%s"), szServer); } if (dwMonitored && !sub->pszMonitored) { sub->pszMonitored = AllocateString(2); sub->pszMonitored[0] = TEXT('\0'); sub->pszMonitored[1] = TEXT('\0'); } } RegCloseKey (hk); } return sub; }
/*F ReadBinNAME(string,link) ** ** DESCRIPTION ** string: The pointer to the string ** link: the linked list ** See ReadBinSTRING ** ** REMARKS ** ** REFERENCES ** ** SEE ALSO ** ** HEADERFILE ** */ extern INT ReadBinNAME(CHAR **string, DbaseLinkedList *link) { INT length; ReadBinINT(&length,link); if(length == NO_STRUCTURE_CODE) { *string = 0; return(NO_STRUCTURE_CODE); } else { *string = AllocateString(length); ReadBin(*string,length,link); } return(STRUCTURE_READ); }
/*F ret = ReadDBSearchType(id,keys,dinfo) ** ** DESCRIPTION ** id: The id of the SetOfSearchKeys ** keys: The SetOfSearchKeys ** dinfo: The DataBaseInformation ** ** This routine reads in the set of search keywords for ** this database. The particular keywords are identified ** by the id. ** ** REMARKS ** ** REFERENCES ** ** SEE ALSO ** ** HEADERFILE ** */ extern INT ReadDBSearchType(INT id, SetOfSearchKeys *keys, DataBaseInformation *dinfo) { DbaseKeyword *indexkey; datum key, datset; DbaseLinkedList *link; CHAR *string; INT ret; ret = SYSTEM_NORMAL_RETURN; indexkey = ProduceIndexKeyword(id); key.dsize = indexkey->Size; key.dptr = indexkey->KeyWord; datset = gdbm_fetch((GDBM_FILE) dinfo->File, key); if(datset.dsize != 0) { link = AllocateDbaseLinkedList; CreateDbaseLinkedList(link,indexkey->ID,indexkey->Name, datset.dsize, datset.dsize, 0,0,0); memcpy(link->Element,datset.dptr,(unsigned int) datset.dsize); ReadBinSetOfSearchKeys(keys,link); FreeDbaseLinkedList(link); Free(link); } else { string = AllocateString(LINELENGTH); sprintf(string,"No Keys for %s\n",dinfo->Name); Error(0,string); Free(string); ret = SYSTEM_ERROR_RETURN; } return(ret); }
LPCTSTR SnarlInterface::GetAppPath() { HWND hWnd = GetSnarlWindow(); if (hWnd) { HWND hWndPath = FindWindowEx(hWnd, NULL, _T("static"), NULL); if (hWndPath) { TCHAR strTmp[MAX_PATH] = {0}; int nReturn = GetWindowText(hWndPath, strTmp, MAX_PATH-1); if (nReturn > 0) { TCHAR* strReturn = AllocateString(nReturn + 1); _tcsncpy(strReturn, strTmp, nReturn + 1); strReturn[nReturn] = 0; return strReturn; } } } return NULL; }
LPCTSTR SnarlInterface::GetIconsPath() { TCHAR* szIconPath = NULL; LPCTSTR szPath = GetAppPath(); if (!szPath) return NULL; size_t nLen = 0; // TODO: _tcsnlen MAX_PATH if (nLen = _tcslen(szPath)) { nLen += 10 + 1; // etc\\icons\\ + NULL szIconPath = AllocateString(nLen); _tcsncpy(szIconPath, szPath, nLen); _tcsncat(szIconPath, _T("etc\\icons\\"), nLen); } FreeString(szPath); return szIconPath; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % S e t M a g i c k I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method SetMagickInfo allocates a MagickInfo structure and initializes the % members to default values. % % The format of the SetMagickInfo method is: % % MagickInfo *SetMagickInfo(const char *tag) % % A description of each parameter follows: % % o magick_info: Method SetMagickInfo returns the allocated and initialized % MagickInfo structure. % % o tag: a character string that represents the image format associated % with the MagickInfo structure. % % */ Export MagickInfo *SetMagickInfo(const char *tag) { MagickInfo *entry; entry=(MagickInfo *) AllocateMemory(sizeof(MagickInfo)); if (entry == (MagickInfo *) NULL) MagickError(ResourceLimitError,"Unable to allocate image", "Memory allocation failed"); entry->tag=AllocateString(tag); entry->decoder=(Image *(*)(const ImageInfo *)) NULL; entry->encoder=(unsigned int (*)(const ImageInfo *,Image *)) NULL; entry->magick= (unsigned int (*)(const unsigned char *,const unsigned int)) NULL; entry->adjoin=True; entry->blob_support=True; entry->raw=False; entry->description=(char *) NULL; entry->data=(void *) NULL; entry->previous=(MagickInfo *) NULL; entry->next=(MagickInfo *) NULL; return(entry); }
bool SpellCheckSentence() { WORDP D,E; fixedSpell = false; bool lowercase = false; int language = ENGLISH; char* lang = GetUserVariable((char*)"$cs_language"); if (lang && !stricmp(lang,(char*)"spanish")) language = SPANISH; // check for all uppercase for (int i = FindOOBEnd(1) + 1; i <= wordCount; ++i) // skip start of sentence { char* word = wordStarts[i]; size_t len = strlen(word); for (int j = 0; j < (int)len; ++j) { if (IsLowerCase(word[j])) { lowercase = true; i = j = 1000; } } } if (!lowercase && wordCount > 2) // must have several words in uppercase { for (int i = FindOOBEnd(1); i <= wordCount; ++i) { char* word = wordStarts[i]; MakeLowerCase(word); } } int startWord = FindOOBEnd(1); for (int i = startWord; i <= wordCount; ++i) { char* word = wordStarts[i]; if (!word || !word[1] || *word == '"' ) continue; // illegal or single char or quoted thingy size_t len = strlen(word); // dont spell check uppercase not at start or joined word if (IsUpperCase(word[0]) && (i != startWord || strchr(word,'_')) && tokenControl & NO_PROPER_SPELLCHECK) continue; // dont spell check email or other things with @ or . in them if (strchr(word,'@') || strchr(word,'.') || strchr(word,'$')) continue; // dont spell check names of json objects or arrays if (!strnicmp(word,"ja-",3) || !strnicmp(word,"jo-",3)) continue; char* known = ProbableKnownWord(word); if (known && !strcmp(known,word)) continue; // we know it if (known && strcmp(known,word)) { char* tokens[2]; if (!IsUpperCase(*known)) // revised the word to lower case (avoid to upper case like "fields" to "Fields" { WORDP D = FindWord(known,0,LOWERCASE_LOOKUP); if (D) { tokens[1] = D->word; ReplaceWords(i,1,1,tokens); fixedSpell = true; continue; } } else // is uppercase a concept member? then revise upwards { WORDP D = FindWord(known,0,UPPERCASE_LOOKUP); if (IsConceptMember(D)) { tokens[1] = D->word; ReplaceWords(i,1,1,tokens); fixedSpell = true; continue; } } } char* p = word -1; unsigned char c; char* hyphen = 0; while ((c = *++p) != 0) { ++len; if (c == '-') hyphen = p; // note is hyphenated - use trailing } if (len == 0 || GetTemperatureLetter(word)) continue; // bad ignore utf word or llegal length - also no composite words if (c && c != '@' && c != '.') // illegal word character { if (IsDigit(word[0]) || len == 1){;} // probable numeric? // accidental junk on end of word we do know immedately? else if (i > 1 && !IsAlphaUTF8OrDigit(wordStarts[i][len-1]) ) { WORDP entry,canonical; char word[MAX_WORD_SIZE]; strcpy(word,wordStarts[i]); word[len-1] = 0; uint64 sysflags = 0; uint64 cansysflags = 0; WORDP revise; GetPosData(i,word,revise,entry,canonical,sysflags,cansysflags,true,true); // dont create a non-existent word if (entry && entry->properties & PART_OF_SPEECH) { wordStarts[i] = reuseAllocation(wordStarts[i],entry->word); fixedSpell = true; continue; // not a legal word character, leave it alone } } } // see if we know the other case if (!(tokenControl & (ONLY_LOWERCASE|STRICT_CASING)) || (i == startSentence && !(tokenControl & ONLY_LOWERCASE))) { WORDP E = FindWord(word,0,SECONDARY_CASE_ALLOWED); bool useAlternateCase = false; if (E && E->systemFlags & PATTERN_WORD) useAlternateCase = true; if (E && E->properties & (PART_OF_SPEECH|FOREIGN_WORD)) { // if the word we find is UPPER case, and this might be a lower case noun plural, don't change case. size_t len = strlen(word); if (word[len-1] == 's' ) { WORDP F = FindWord(word,len-1); if (!F || !(F->properties & (PART_OF_SPEECH|FOREIGN_WORD))) useAlternateCase = true; else continue; } else useAlternateCase = true; } else if (E) // does it have a member concept fact { if (IsConceptMember(E)) { useAlternateCase = true; break; } } if (useAlternateCase) { char* tokens[2]; tokens[1] = E->word; ReplaceWords(i,1,1,tokens); fixedSpell = true; continue; } } // merge with next token? char join[MAX_WORD_SIZE * 3]; if (i != wordCount && *wordStarts[i+1] != '"' ) { // direct merge as a single word strcpy(join,word); strcat(join,wordStarts[i+1]); WORDP D = FindWord(join,0,(tokenControl & ONLY_LOWERCASE) ? PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP); strcpy(join,word); if (!D || !(D->properties & PART_OF_SPEECH) ) // merge these two, except "going to" or wordnet composites of normal words // merge as a compound word { strcat(join,(char*)"_"); strcat(join,wordStarts[i+1]); D = FindWord(join,0,(tokenControl & ONLY_LOWERCASE) ? PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP); } if (D && D->properties & PART_OF_SPEECH && !(D->properties & AUX_VERB)) // merge these two, except "going to" or wordnet composites of normal words { WORDP P1 = FindWord(word,0,LOWERCASE_LOOKUP); WORDP P2 = FindWord(wordStarts[i+1],0,LOWERCASE_LOOKUP); if (!P1 || !P2 || !(P1->properties & PART_OF_SPEECH) || !(P2->properties & PART_OF_SPEECH)) { char* tokens[2]; tokens[1] = D->word; ReplaceWords(i,2,1,tokens); fixedSpell = true; continue; } } } // break apart slashed pair like eat/feed char* slash = strchr(word,'/'); if (slash && slash != word && slash[1]) // break apart word/word { if ((wordCount + 2 ) >= REAL_SENTENCE_LIMIT) continue; // no room *slash = 0; D = StoreWord(word); *slash = '/'; E = StoreWord(slash+1); char* tokens[4]; tokens[1] = D->word; tokens[2] = "/"; tokens[3] = E->word; ReplaceWords(i,1,3,tokens); fixedSpell = true; --i; continue; } // see if hypenated word should be separate or joined (ignore obvious adjective suffix) if (hyphen && !stricmp(hyphen,(char*)"-like")) { StoreWord(word,ADJECTIVE_NORMAL|ADJECTIVE); // accept it as a word continue; } else if (hyphen && (hyphen-word) > 1) { char test[MAX_WORD_SIZE]; char first[MAX_WORD_SIZE]; // test for split *hyphen = 0; strcpy(test,hyphen+1); strcpy(first,word); *hyphen = '-'; WORDP E = FindWord(test,0,LOWERCASE_LOOKUP); WORDP D = FindWord(first,0,LOWERCASE_LOOKUP); if (*first == 0) { wordStarts[i] = AllocateString(wordStarts[i] + 1); // -pieces want to lose the leading hypen (2-pieces) fixedSpell = true; } else if (D && E) // 1st word gets replaced, we added another word after { if ((wordCount + 1 ) >= REAL_SENTENCE_LIMIT) continue; // no room char* tokens[3]; tokens[1] = D->word; tokens[2] = E->word; ReplaceWords(i,1,2,tokens); fixedSpell = true; --i; } else if (!stricmp(test,(char*)"old") || !stricmp(test,(char*)"olds")) // break apart 5-year-old { if ((wordCount + 1 ) >= REAL_SENTENCE_LIMIT) continue; // no room D = StoreWord(first); E = StoreWord(test); char* tokens[3]; tokens[1] = D->word; tokens[2] = E->word; ReplaceWords(i,1,2,tokens); fixedSpell = true; --i; } else // remove hyphen entirely? { strcpy(test,first); strcat(test,hyphen+1); D = FindWord(test,0,(tokenControl & ONLY_LOWERCASE) ? PRIMARY_CASE_ALLOWED : STANDARD_LOOKUP); if (D) { wordStarts[i] = D->word; fixedSpell = true; --i; } } continue; // ignore hypenated errors that we couldnt solve, because no one mistypes a hypen } // leave uppercase in first position if not adjusted yet... but check for lower case spell error if (IsUpperCase(word[0]) && tokenControl & NO_PROPER_SPELLCHECK) { char lower[MAX_WORD_SIZE]; MakeLowerCopy(lower,word); WORDP D = FindWord(lower,0,LOWERCASE_LOOKUP); if (!D && i == startWord) { char* okword = SpellFix(lower,i,PART_OF_SPEECH,language); if (okword) { char* tokens[2]; WORDP E = StoreWord(okword); tokens[1] = E->word; ReplaceWords(i,1,1,tokens); fixedSpell = true; } } continue; } if (*word != '\'' && (!FindCanonical(word, i,true) || IsUpperCase(word[0]))) // dont check quoted or findable words unless they are capitalized { word = SpellCheck(i,language); // dont spell check proper names to improper, if word before or after is lower case originally if (word && i != 1 && originalCapState[i] && !IsUpperCase(*word)) { if (!originalCapState[i-1]) return false; else if (i != wordCount && !originalCapState[i+1]) return false; } if (word && !*word) // performed substitution on prior word, restart this one { fixedSpell = true; --i; continue; } if (word) { char* tokens[2]; tokens[1] = word; ReplaceWords(i,1,1,tokens); fixedSpell = true; continue; } } } return fixedSpell; }
LPSUBSET Subsets_SetMonitor (LPSUBSET sub, LPIDENT lpiServer, BOOL fMonitor) { if (sub == NULL) { sub = New (SUBSET); memset (sub, 0x00, sizeof(SUBSET)); } if (fMonitor != Subsets_fMonitorServer (sub, lpiServer)) { sub->fModified = TRUE; TCHAR szLong[ cchNAME ]; TCHAR szShort[ cchNAME ]; lpiServer->GetShortServerName (szShort); lpiServer->GetLongServerName (szLong); // First ensure that the server name doesn't appear anywhere // in the subset. // LPTSTR pszMonitoredNew = NULL; LPTSTR pszUnmonitoredNew = NULL; if (sub->pszMonitored) { for (LPTSTR psz = sub->pszMonitored; *psz; psz += 1+lstrlen(psz)) { if (lstrcmpi (psz, szLong) && lstrcmpi (psz, szShort)) { FormatMultiString (&pszMonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), psz); } } } else if (sub->pszUnmonitored) { for (LPTSTR psz = sub->pszUnmonitored; *psz; psz += 1+lstrlen(psz)) { if (lstrcmpi (psz, szLong) && lstrcmpi (psz, szShort)) { FormatMultiString (&pszUnmonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), psz); } } } // Then ensure it shows up only where necessary. // if (sub->pszMonitored && fMonitor) { FormatMultiString (&pszMonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), szLong); } else if (!sub->pszMonitored && !fMonitor) { FormatMultiString (&pszUnmonitoredNew, TRUE, TEXT("%1"), TEXT("%s"), szLong); } if (sub->pszMonitored && !pszMonitoredNew) { pszMonitoredNew = AllocateString (2); pszMonitoredNew[0] = TEXT('\0'); pszMonitoredNew[1] = TEXT('\0'); } if (sub->pszUnmonitored && !pszUnmonitoredNew) { pszUnmonitoredNew = AllocateString (2); pszUnmonitoredNew[0] = TEXT('\0'); pszUnmonitoredNew[1] = TEXT('\0'); } // Finally, update the subset's members. // if (sub->pszMonitored) FreeString (sub->pszMonitored); if (sub->pszUnmonitored) FreeString (sub->pszUnmonitored); sub->pszMonitored = pszMonitoredNew; sub->pszUnmonitored = pszUnmonitoredNew; } return sub; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d M V G I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadMVGImage creates a gradient image and initializes it to % the X server color range as specified by the filename. It allocates the % memory necessary for the new Image structure and returns a pointer to the % new image. % % The format of the ReadMVGImage method is: % % Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: Method ReadMVGImage returns a pointer to the image after % creating it. A null image is returned if there is a memory shortage % or if the image cannot be read. % % o image_info: Specifies a pointer to a ImageInfo structure. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception) { #define BoundingBox "viewbox" DrawInfo *draw_info; Image *image; size_t length; unsigned int status; /* Open image. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == False) ThrowReaderException(FileOpenError,UnableToOpenFile,image); if ((image->columns == 0) || (image->rows == 0)) { char primitive[MaxTextExtent]; register char *p; SegmentInfo bounds; /* Determine size of image canvas. */ while (ReadBlobString(image,primitive) != (char *) NULL) { for (p=primitive; (*p == ' ') || (*p == '\t'); p++); if (LocaleNCompare(BoundingBox,p,strlen(BoundingBox)) != 0) continue; (void) sscanf(p,"viewbox %lf %lf %lf %lf",&bounds.x1,&bounds.y1, &bounds.x2,&bounds.y2); image->columns=(unsigned long) (bounds.x2-bounds.x1+0.5); image->rows=(unsigned long) (bounds.y2-bounds.y1+0.5); break; } } if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,MustSpecifyImageSize,image); if (CheckImagePixelLimits(image, exception) != MagickPass) ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image); /* Render drawing. */ (void) SetImage(image,OpaqueOpacity); draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); draw_info->fill=image_info->pen; if (GetBlobStreamData(image)) draw_info->primitive=AllocateString((char *) GetBlobStreamData(image)); else draw_info->primitive=(char *) FileToBlob(image->filename,&length,exception); if (draw_info->primitive == (char *) NULL) { DestroyDrawInfo(draw_info); CloseBlob(image); return (Image *) NULL; } (void) DrawImage(image,draw_info); DestroyDrawInfo(draw_info); CloseBlob(image); return(image); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t M a g i c k L i s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method GetMagickInfo returns a pointer MagickInfo structure that matches % the specified tag. If tag is NULL, the head of the image format list is % returned. % % The format of the GetMagickInfo method is: % % MagickInfo *GetMagickInfo(const char *tag) % % A description of each parameter follows: % % o magick_info: Method GetMagickInfo returns a pointer MagickInfo % structure that matches the specified tag. % % o tag: a character string that represents the image format we are % looking for. % % */ Export MagickInfo *GetMagickInfo(const char *tag) { register MagickInfo *p; if (magick_info == (MagickInfo *) NULL) { MagickInfo *entry; /* entry=SetMagickInfo("8BIM"); entry->decoder=Read8BIMImage; entry->encoder=Write8BIMImage; entry->magick=Is8BIM; entry->adjoin=False; entry->description=AllocateString("Photoshop resource format"); RegisterMagickInfo(entry); entry=SetMagickInfo("AVS"); entry->decoder=ReadAVSImage; entry->encoder=WriteAVSImage; entry->description=AllocateString("AVS X image"); RegisterMagickInfo(entry); #if defined(HasJBIG) entry=SetMagickInfo("BIE"); entry->decoder=ReadJBIGImage; entry->encoder=WriteJBIGImage; entry->adjoin=False; entry->description= AllocateString("Joint Bi-level Image experts Group interchange format"); RegisterMagickInfo(entry); #endif */ entry=SetMagickInfo("BMP"); entry->decoder=ReadBMPImage; entry->encoder=WriteBMPImage; entry->magick=IsBMP; entry->description=AllocateString("Microsoft Windows bitmap image"); RegisterMagickInfo(entry); entry=SetMagickInfo("BMP24"); entry->decoder=ReadBMPImage; entry->encoder=WriteBMPImage; entry->description= AllocateString("Microsoft Windows 24-bit bitmap image"); RegisterMagickInfo(entry); /* entry=SetMagickInfo("CMYK"); entry->decoder=ReadCMYKImage; entry->encoder=WriteCMYKImage; entry->adjoin=False; entry->raw=True; entry->description= AllocateString("Raw cyan, magenta, yellow, and black bytes"); RegisterMagickInfo(entry); entry=SetMagickInfo("DCM"); entry->decoder=ReadDCMImage; entry->magick=IsDCM; entry->adjoin=False; entry->description= AllocateString("Digital Imaging and Communications in Medicine image"); RegisterMagickInfo(entry); entry=SetMagickInfo("DCX"); entry->decoder=ReadPCXImage; entry->encoder=WritePCXImage; entry->magick=IsDCX; entry->description= AllocateString("ZSoft IBM PC multi-page Paintbrush"); RegisterMagickInfo(entry); */ entry=SetMagickInfo("DIB"); entry->decoder=ReadBMPImage; entry->encoder=WriteBMPImage; entry->description= AllocateString("Microsoft Windows bitmap image"); RegisterMagickInfo(entry); /* entry=SetMagickInfo("EPDF"); entry->decoder=ReadPDFImage; entry->encoder=WritePDFImage; entry->adjoin=False; entry->description= AllocateString("Encapsulated Portable Document Format"); RegisterMagickInfo(entry); entry=SetMagickInfo("EPI"); entry->decoder=ReadPSImage; entry->adjoin=False; entry->description= AllocateString("Adobe Encapsulated PostScript Interchange format"); RegisterMagickInfo(entry); entry=SetMagickInfo("EPS"); entry->decoder=ReadPSImage; entry->encoder=WritePSImage; entry->adjoin=False; entry->description=AllocateString("Adobe Encapsulated PostScript"); RegisterMagickInfo(entry); entry=SetMagickInfo("EPS2"); entry->decoder=ReadPSImage; entry->encoder=WritePS2Image; entry->adjoin=False; entry->description= AllocateString("Adobe Level II Encapsulated PostScript"); RegisterMagickInfo(entry); entry=SetMagickInfo("EPSF"); entry->decoder=ReadPSImage; entry->encoder=WritePSImage; entry->adjoin=False; entry->description=AllocateString("Adobe Encapsulated PostScript"); RegisterMagickInfo(entry); entry=SetMagickInfo("EPSI"); entry->decoder=ReadPSImage; entry->encoder=WritePSImage; entry->adjoin=False; entry->description= AllocateString("Adobe Encapsulated PostScript Interchange format"); RegisterMagickInfo(entry); entry=SetMagickInfo("EPT"); entry->decoder=ReadPSImage; entry->encoder=WriteEPTImage; entry->magick=IsEPT; entry->adjoin=False; entry->description= AllocateString("Adobe Encapsulated PostScript with TIFF preview"); RegisterMagickInfo(entry); entry=SetMagickInfo("FAX"); entry->decoder=ReadFAXImage; entry->encoder=WriteFAXImage; entry->magick=IsFAX; entry->description=AllocateString("Group 3 FAX"); RegisterMagickInfo(entry); entry=SetMagickInfo("FITS"); entry->decoder=ReadFITSImage; entry->encoder=WriteFITSImage; entry->magick=IsFITS; entry->adjoin=False; entry->description= AllocateString("Flexible Image Transport System"); RegisterMagickInfo(entry); #if defined(HasFPX) entry=SetMagickInfo("FPX"); entry->decoder=ReadFPXImage; entry->encoder=WriteFPXImage; entry->adjoin=False; entry->description=AllocateString("FlashPix Format"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("G3"); entry->decoder=ReadFAXImage; entry->adjoin=False; entry->description=AllocateString("Group 3 FAX"); RegisterMagickInfo(entry); */ entry=SetMagickInfo("GIF"); entry->decoder=ReadGIFImage; entry->encoder=WriteGIFImage; entry->magick=IsGIF; entry->description= AllocateString("CompuServe graphics interchange format"); RegisterMagickInfo(entry); entry=SetMagickInfo("GIF87"); entry->decoder=ReadGIFImage; entry->encoder=WriteGIFImage; entry->adjoin=False; entry->description= AllocateString("CompuServe graphics interchange format (version 87a)"); RegisterMagickInfo(entry); /* entry=SetMagickInfo("GRADATION"); entry->decoder=ReadGRADATIONImage; entry->adjoin=False; entry->description= AllocateString("Gradual passing from one shade to another"); RegisterMagickInfo(entry); entry=SetMagickInfo("GRANITE"); entry->decoder=ReadLOGOImage; entry->encoder=WriteLOGOImage; entry->adjoin=False; entry->description=AllocateString("Granite texture"); RegisterMagickInfo(entry); entry=SetMagickInfo("GRAY"); entry->decoder=ReadGRAYImage; entry->encoder=WriteGRAYImage; entry->raw=True; entry->description=AllocateString("Raw gray bytes"); RegisterMagickInfo(entry); entry=SetMagickInfo("H"); entry->decoder=ReadLOGOImage; entry->encoder=WriteLOGOImage; entry->adjoin=False; entry->description=AllocateString("Internal format"); RegisterMagickInfo(entry); #if defined(HasHDF) entry=SetMagickInfo("HDF"); entry->decoder=ReadHDFImage; entry->encoder=WriteHDFImage; entry->magick=IsHDF; entry->blob_support=False; entry->description=AllocateString("Hierarchical Data Format"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("HISTOGRAM"); entry->decoder=ReadHISTOGRAMImage; entry->encoder=WriteHISTOGRAMImage; entry->adjoin=False; entry->description=AllocateString("Histogram of the image"); RegisterMagickInfo(entry); entry=SetMagickInfo("HTM"); entry->encoder=WriteHTMLImage; entry->magick=IsHTML; entry->adjoin=False; entry->description= AllocateString("Hypertext Markup Language and a client-side image map"); RegisterMagickInfo(entry); entry=SetMagickInfo("HTML"); entry->encoder=WriteHTMLImage; entry->adjoin=False; entry->description= AllocateString("Hypertext Markup Language and a client-side image map"); RegisterMagickInfo(entry); entry=SetMagickInfo("ICB"); entry->decoder=ReadTGAImage; entry->encoder=WriteTGAImage; entry->description=AllocateString("Truevision Targa image"); RegisterMagickInfo(entry); entry=SetMagickInfo("ICC"); entry->decoder=ReadICCImage; entry->encoder=WriteICCImage; entry->adjoin=False; entry->description=AllocateString("ICC Color Profile"); RegisterMagickInfo(entry); entry=SetMagickInfo("ICO"); entry->decoder=ReadICONImage; entry->adjoin=False; entry->description=AllocateString("Microsoft icon"); RegisterMagickInfo(entry); entry=SetMagickInfo("IMPLICIT"); entry->description=AllocateString("Internal format"); RegisterMagickInfo(entry); entry=SetMagickInfo("IPTC"); entry->decoder=ReadIPTCImage; entry->encoder=WriteIPTCImage; entry->magick=IsIPTC; entry->adjoin=False; entry->description=AllocateString("IPTC Newsphoto"); RegisterMagickInfo(entry); #if defined(HasJBIG) entry=SetMagickInfo("JBG"); entry->decoder=ReadJBIGImage; entry->encoder=WriteJBIGImage; entry->description= AllocateString("Joint Bi-level Image experts Group interchange format"); RegisterMagickInfo(entry); entry=SetMagickInfo("JBIG"); entry->decoder=ReadJBIGImage; entry->encoder=WriteJBIGImage; entry->description= AllocateString("Joint Bi-level Image experts Group interchange format"); RegisterMagickInfo(entry); #endif #if defined(HasJPEG) entry=SetMagickInfo("JPG"); entry->decoder=ReadJPEGImage; entry->encoder=WriteJPEGImage; entry->adjoin=False; entry->description= AllocateString("Joint Photographic Experts Group JFIF format"); RegisterMagickInfo(entry); entry=SetMagickInfo("JPEG"); entry->decoder=ReadJPEGImage; entry->encoder=WriteJPEGImage; entry->magick=IsJPEG; entry->adjoin=False; entry->description= AllocateString("Joint Photographic Experts Group JFIF format"); RegisterMagickInfo(entry); entry=SetMagickInfo("JPEG24"); entry->decoder=ReadJPEGImage; entry->encoder=WriteJPEGImage; entry->adjoin=False; entry->description= AllocateString("Joint Photographic Experts Group JFIF format"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("LABEL"); entry->decoder=ReadLABELImage; entry->adjoin=False; entry->description=AllocateString("Text image format"); RegisterMagickInfo(entry); entry=SetMagickInfo("LOGO"); entry->decoder=ReadLOGOImage; entry->encoder=WriteLOGOImage; entry->adjoin=False; entry->description=AllocateString("ImageMagick Logo"); RegisterMagickInfo(entry); entry=SetMagickInfo("MAP"); entry->decoder=ReadMAPImage; entry->encoder=WriteMAPImage; entry->adjoin=False; entry->raw=True; entry->description= AllocateString("Colormap intensities and indices"); RegisterMagickInfo(entry); entry=SetMagickInfo("MATTE"); entry->decoder=ReadMIFFImage; entry->encoder=WriteMATTEImage; entry->raw=True; entry->description=AllocateString("Matte format"); RegisterMagickInfo(entry); */ entry=SetMagickInfo("MIFF"); entry->decoder=ReadMIFFImage; entry->encoder=WriteMIFFImage; entry->magick=IsMIFF; entry->description=AllocateString("Magick image format"); RegisterMagickInfo(entry); /* #if defined(HasPNG) entry=SetMagickInfo("MNG"); entry->decoder=ReadPNGImage; entry->encoder=WritePNGImage; entry->magick=IsMNG; entry->description=AllocateString("Multiple-image Network Graphics"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("MONO"); entry->decoder=ReadMONOImage; entry->encoder=WriteMONOImage; entry->adjoin=False; entry->description= AllocateString("Bi-level bitmap in least-significant-byte first order"); RegisterMagickInfo(entry); entry=SetMagickInfo("MTV"); entry->decoder=ReadMTVImage; entry->encoder=WriteMTVImage; entry->description=AllocateString("MTV Raytracing image format"); RegisterMagickInfo(entry); entry=SetMagickInfo("NETSCAPE"); entry->decoder=ReadLOGOImage; entry->encoder=WriteLOGOImage; entry->adjoin=False; entry->description=AllocateString("Netscape 216 color cube"); RegisterMagickInfo(entry); entry=SetMagickInfo("NULL"); entry->decoder=ReadNULLImage; entry->adjoin=False; entry->description=AllocateString("NULL image"); RegisterMagickInfo(entry); entry=SetMagickInfo("P7"); entry->decoder=ReadPNMImage; entry->encoder=WritePNMImage; entry->description=AllocateString("Xv thumbnail format"); RegisterMagickInfo(entry); entry=SetMagickInfo("PBM"); entry->decoder=ReadPNMImage; entry->encoder=WritePNMImage; entry->description= AllocateString("Portable bitmap format (black and white)"); RegisterMagickInfo(entry); entry=SetMagickInfo("PCD"); entry->decoder=ReadPCDImage; entry->encoder=WritePCDImage; entry->magick=IsPCD; entry->adjoin=False; entry->description=AllocateString("Photo CD"); RegisterMagickInfo(entry); entry=SetMagickInfo("PCDS"); entry->decoder=ReadPCDImage; entry->encoder=WritePCDImage; entry->adjoin=False; entry->description=AllocateString("Photo CD"); RegisterMagickInfo(entry); entry=SetMagickInfo("PCL"); entry->decoder=ReadPCLImage; entry->encoder=WritePCLImage; entry->magick=IsPCL; entry->adjoin=False; entry->description=AllocateString("Page Control Language"); RegisterMagickInfo(entry); entry=SetMagickInfo("PCT"); entry->encoder=WritePICTImage; entry->adjoin=False; entry->description=AllocateString("Apple Macintosh QuickDraw/PICT"); RegisterMagickInfo(entry); entry=SetMagickInfo("PCX"); entry->decoder=ReadPCXImage; entry->encoder=WritePCXImage; entry->magick=IsPCX; entry->adjoin=False; entry->description=AllocateString("ZSoft IBM PC Paintbrush"); RegisterMagickInfo(entry); entry=SetMagickInfo("PDF"); entry->decoder=ReadPDFImage; entry->encoder=WritePDFImage; entry->magick=IsPDF; entry->description=AllocateString("Portable Document Format"); RegisterMagickInfo(entry); entry=SetMagickInfo("PIC"); entry->decoder=ReadPICTImage; entry->encoder=WritePICTImage; entry->adjoin=False; entry->description=AllocateString("Apple Macintosh QuickDraw/PICT"); RegisterMagickInfo(entry); entry=SetMagickInfo("PICT"); entry->decoder=ReadPICTImage; entry->encoder=WritePICTImage; entry->adjoin=False; entry->description=AllocateString("Apple Macintosh QuickDraw/PICT"); RegisterMagickInfo(entry); entry=SetMagickInfo("PICT24"); entry->decoder=ReadPICTImage; entry->encoder=WritePICTImage; entry->adjoin=False; entry->description= AllocateString("24-bit Apple Macintosh QuickDraw/PICT"); RegisterMagickInfo(entry); entry=SetMagickInfo("PIX"); entry->decoder=ReadPIXImage; entry->description= AllocateString("Alias/Wavefront RLE image format"); RegisterMagickInfo(entry); entry=SetMagickInfo("PLASMA"); entry->decoder=ReadPLASMAImage; entry->adjoin=False; entry->description=AllocateString("Plasma fractal image"); RegisterMagickInfo(entry); entry=SetMagickInfo("PGM"); entry->decoder=ReadPNMImage; entry->encoder=WritePNMImage; entry->description= AllocateString("Portable graymap format (gray scale)"); RegisterMagickInfo(entry); entry=SetMagickInfo("PM"); entry->decoder=ReadXPMImage; entry->encoder=WriteXPMImage; entry->adjoin=False; entry->description=AllocateString("X Windows system pixmap (color)"); RegisterMagickInfo(entry); #if defined(HasPNG) entry=SetMagickInfo("PNG"); entry->decoder=ReadPNGImage; entry->encoder=WritePNGImage; entry->magick=IsPNG; entry->adjoin=False; entry->description=AllocateString("Portable Network Graphics"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("PNM"); entry->decoder=ReadPNMImage; entry->encoder=WritePNMImage; entry->magick=IsPNM; entry->description=AllocateString("Portable anymap"); RegisterMagickInfo(entry); entry=SetMagickInfo("PPM"); entry->decoder=ReadPNMImage; entry->encoder=WritePNMImage; entry->description=AllocateString("Portable pixmap format (color)"); RegisterMagickInfo(entry); entry=SetMagickInfo("PREVIEW"); entry->encoder=WritePREVIEWImage; entry->adjoin=False; entry->description= AllocateString("Show a preview an image enhancement, effect, or f/x"); RegisterMagickInfo(entry); entry=SetMagickInfo("PS"); entry->decoder=ReadPSImage; entry->encoder=WritePSImage; entry->magick=IsPS; entry->description=AllocateString("Adobe PostScript"); RegisterMagickInfo(entry); entry=SetMagickInfo("PS2"); entry->encoder=WritePS2Image; entry->description=AllocateString("Adobe Level II PostScript"); RegisterMagickInfo(entry); entry=SetMagickInfo("PS3"); entry->encoder=WritePS3Image; entry->description=AllocateString("Adobe Level III PostScript"); RegisterMagickInfo(entry); entry=SetMagickInfo("PSD"); entry->decoder=ReadPSDImage; entry->encoder=WritePSDImage; entry->magick=IsPSD; entry->adjoin=False; entry->description=AllocateString("Adobe Photoshop bitmap"); RegisterMagickInfo(entry); #if defined(HasTIFF) entry=SetMagickInfo("PTIF"); entry->decoder=ReadTIFFImage; entry->encoder=WriteTIFFImage; entry->blob_support=False; entry->description=AllocateString("Pyramid encoded TIFF"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("PWP"); entry->decoder=ReadPWPImage; entry->magick=IsPWP; entry->description=AllocateString("Seattle Film Works"); RegisterMagickInfo(entry); entry=SetMagickInfo("RAS"); entry->decoder=ReadSUNImage; entry->encoder=WriteSUNImage; entry->magick=IsSUN; entry->description=AllocateString("SUN Rasterfile"); RegisterMagickInfo(entry); */ entry=SetMagickInfo("RGB"); entry->decoder=ReadRGBImage; entry->encoder=WriteRGBImage; entry->raw=True; entry->description=AllocateString("Raw red, green, and blue bytes"); RegisterMagickInfo(entry); /* entry=SetMagickInfo("RGBA"); entry->decoder=ReadRGBImage; entry->encoder=WriteRGBImage; entry->raw=True; entry->description= AllocateString("Raw red, green, blue, and matte bytes"); RegisterMagickInfo(entry); entry=SetMagickInfo("RLA"); entry->decoder=ReadRLAImage; entry->adjoin=False; entry->description=AllocateString("Alias/Wavefront image"); RegisterMagickInfo(entry); entry=SetMagickInfo("RLE"); entry->decoder=ReadRLEImage; entry->magick=IsRLE; entry->adjoin=False; entry->description=AllocateString("Utah Run length encoded image"); RegisterMagickInfo(entry); entry=SetMagickInfo("SCT"); entry->decoder=ReadSCTImage; entry->magick=IsSCT; entry->adjoin=False; entry->description=AllocateString("Scitex HandShake"); RegisterMagickInfo(entry); entry=SetMagickInfo("SFW"); entry->decoder=ReadSFWImage; entry->magick=IsSFW; entry->adjoin=False; entry->description=AllocateString("Seattle Film Works"); RegisterMagickInfo(entry); entry=SetMagickInfo("SGI"); entry->decoder=ReadSGIImage; entry->encoder=WriteSGIImage; entry->magick=IsSGI; entry->description=AllocateString("Irix RGB image"); RegisterMagickInfo(entry); entry=SetMagickInfo("SHTML"); entry->encoder=WriteHTMLImage; entry->adjoin=False; entry->description= AllocateString("Hypertext Markup Language and a client-side image map"); RegisterMagickInfo(entry); entry=SetMagickInfo("STEGANO"); entry->decoder=ReadSTEGANOImage; entry->description=AllocateString("Steganographic image"); RegisterMagickInfo(entry); entry=SetMagickInfo("SUN"); entry->decoder=ReadSUNImage; entry->encoder=WriteSUNImage; entry->description=AllocateString("SUN Rasterfile"); RegisterMagickInfo(entry); entry=SetMagickInfo("TEXT"); entry->decoder=ReadTXTImage; entry->encoder=WriteTXTImage; entry->raw=True; entry->description=AllocateString("Raw text"); RegisterMagickInfo(entry); entry=SetMagickInfo("TGA"); entry->decoder=ReadTGAImage; entry->encoder=WriteTGAImage; entry->description=AllocateString("Truevision Targa image"); RegisterMagickInfo(entry); #if defined(HasTIFF) entry=SetMagickInfo("TIF"); entry->decoder=ReadTIFFImage; entry->encoder=WriteTIFFImage; entry->blob_support=False; entry->description=AllocateString("Tagged Image File Format"); RegisterMagickInfo(entry); entry=SetMagickInfo("TIFF"); entry->decoder=ReadTIFFImage; entry->encoder=WriteTIFFImage; entry->magick=IsTIFF; entry->blob_support=False; entry->description=AllocateString("Tagged Image File Format"); RegisterMagickInfo(entry); entry=SetMagickInfo("TIFF24"); entry->decoder=ReadTIFFImage; entry->encoder=WriteTIFFImage; entry->blob_support=False; entry->description=AllocateString("24-bit Tagged Image File Format"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("TILE"); entry->decoder=ReadTILEImage; entry->raw=True; entry->description=AllocateString("Tile image with a texture"); RegisterMagickInfo(entry); entry=SetMagickInfo("TIM"); entry->decoder=ReadTIMImage; entry->description=AllocateString("PSX TIM"); RegisterMagickInfo(entry); #if defined(HasTTF) entry=SetMagickInfo("TTF"); entry->decoder=ReadTTFImage; entry->adjoin=False; entry->description=AllocateString("TrueType font"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("TXT"); entry->decoder=ReadTXTImage; entry->encoder=WriteTXTImage; entry->description=AllocateString("Raw text"); RegisterMagickInfo(entry); entry=SetMagickInfo("UIL"); entry->decoder=ReadUILImage; entry->encoder=WriteUILImage; entry->adjoin=False; entry->description=AllocateString("X-Motif UIL table"); RegisterMagickInfo(entry); entry=SetMagickInfo("UYVY"); entry->decoder=ReadUYVYImage; entry->encoder=WriteUYVYImage; entry->adjoin=False; entry->raw=True; entry->description=AllocateString("16bit/pixel interleaved YUV"); RegisterMagickInfo(entry); entry=SetMagickInfo("VDA"); entry->decoder=ReadTGAImage; entry->encoder=WriteTGAImage; entry->description=AllocateString("Truevision Targa image"); RegisterMagickInfo(entry); entry=SetMagickInfo("VICAR"); entry->decoder=ReadVICARImage; entry->encoder=WriteVICARImage; entry->magick=IsVICAR; entry->adjoin=False; entry->description=AllocateString("VICAR rasterfile format"); RegisterMagickInfo(entry); entry=SetMagickInfo("VID"); entry->decoder=ReadVIDImage; entry->encoder=WriteMIFFImage; entry->description=AllocateString("Visual Image Directory"); RegisterMagickInfo(entry); entry=SetMagickInfo("VIFF"); entry->decoder=ReadVIFFImage; entry->encoder=WriteVIFFImage; entry->magick=IsVIFF; entry->description=AllocateString("Khoros Visualization image"); RegisterMagickInfo(entry); entry=SetMagickInfo("VST"); entry->decoder=ReadTGAImage; entry->encoder=WriteTGAImage; entry->description=AllocateString("Truevision Targa image"); RegisterMagickInfo(entry); entry=SetMagickInfo("WBMP"); entry->decoder=ReadWBMPImage; entry->encoder=WriteWBMPImage; entry->adjoin=False; entry->description=AllocateString("Wireless Bitmap (level 0) image"); RegisterMagickInfo(entry); #if defined(HasX11) entry=SetMagickInfo("X"); entry->decoder=ReadXImage; entry->encoder=WriteXImage; entry->adjoin=False; entry->description=AllocateString("X Image"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("XBM"); entry->decoder=ReadXBMImage; entry->encoder=WriteXBMImage; entry->magick=IsXBM; entry->adjoin=False; entry->description= AllocateString("X Windows system bitmap (black and white)"); RegisterMagickInfo(entry); entry=SetMagickInfo("XC"); entry->decoder=ReadXCImage; entry->adjoin=False; entry->raw=True; entry->description= AllocateString("Constant image of X server color"); RegisterMagickInfo(entry); entry=SetMagickInfo("XPM"); entry->decoder=ReadXPMImage; entry->encoder=WriteXPMImage; entry->magick=IsXPM; entry->adjoin=False; entry->description=AllocateString("X Windows system pixmap (color)"); RegisterMagickInfo(entry); entry=SetMagickInfo("XV"); entry->decoder=ReadVIFFImage; entry->encoder=WriteVIFFImage; entry->description=AllocateString("Khoros Visualization image"); RegisterMagickInfo(entry); #if defined(HasX11) entry=SetMagickInfo("XWD"); entry->decoder=ReadXWDImage; entry->encoder=WriteXWDImage; entry->magick=IsXWD; entry->adjoin=False; entry->description= AllocateString("X Windows system window dump (color)"); RegisterMagickInfo(entry); #endif entry=SetMagickInfo("YUV"); entry->decoder=ReadYUVImage; entry->encoder=WriteYUVImage; entry->adjoin=False; entry->raw=True; entry->description=AllocateString("CCIR 601 4:1:1"); RegisterMagickInfo(entry); */ } if (tag == (char *) NULL) return(magick_info); for (p=magick_info; p != (MagickInfo *) NULL; p=p->next) if (Latin1Compare(p->tag,tag) == 0) return(p); return((MagickInfo *) NULL); }
void ConfigManager::Load( const IDataStream& Stream ) { uint Pos = Stream.GetPos(); if( 'FCCD' == Stream.ReadUInt32() ) { uint NumContexts = Stream.ReadUInt32(); for( uint ContextIndex = 0; ContextIndex < NumContexts; ++ContextIndex ) { HashedString ContextKey( Stream.ReadUInt32() ); uint NumVars = Stream.ReadUInt32(); VarMap& VarMap = GetInstance()->m_Vars[ ContextKey ]; for( uint VarIndex = 0; VarIndex < NumVars; ++VarIndex ) { ConfigVar ConfigVar; HashedString Key( Stream.ReadUInt32() ); ConfigVar.m_Type = ( ConfigVar::EVarType )Stream.ReadUInt8(); switch( ConfigVar.m_Type ) { case ConfigVar::EVT_Bool: ConfigVar.m_Bool = ( Stream.ReadUInt8() != 0 ); break; case ConfigVar::EVT_Int: ConfigVar.m_Int = Stream.ReadInt32(); break; case ConfigVar::EVT_Float: ConfigVar.m_Float = Stream.ReadFloat(); break; case ConfigVar::EVT_String: { uint Length = Stream.ReadUInt32(); char* pString = AllocateString( Length + 1 ); Stream.Read( Length, pString ); pString[ Length ] = '\0'; StringManager::AddString( StringManager::ESL_Permanent, pString ); ConfigVar.m_String = pString; ConfigVar.m_Hash = Stream.ReadUInt32(); if( ReverseHash::IsEnabled() ) { ReverseHash::RegisterHash( ConfigVar.m_Hash, ConfigVar.m_String ); } } break; default: WARNDESC( "Bad config var type" ); break; } VarMap.Insert( Key, ConfigVar ); } } } else { Stream.SetPos( Pos ); ConfigParser::Parse( Stream ); } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + R e a d C o n f i g u r e F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Method ReadConfigureFile reads the color configuration file which maps % color strings with a particular image format. % % The format of the ReadConfigureFile method is: % % unsigned int ReadConfigureFile(const char *basename, % const unsigned long depth,ExceptionInfo *exception) % % A description of each parameter follows: % % o status: Method ReadConfigureFile returns True if at least one color % is defined otherwise False. % % o basename: The color configuration filename. % % o depth: depth of <include /> statements. % % o exception: Return any errors or warnings in this structure. % % */ #if defined(MSWINDOWS) static void CatDelegatePath(char *path, const char *binpath, const char *command) { strcpy(path,binpath); strcat(path,command); if (IsAccessibleNoLogging(path)) return; strcpy(path,command); return; } #endif /* defined(MSWINDOWS) */ static unsigned int ReadConfigureFile(const char *basename, const unsigned long depth,ExceptionInfo *exception) { char keyword[MaxTextExtent], path[MaxTextExtent], *q, *token, *xml; size_t length; /* Read the delegates configure file. */ (void) strcpy(path,basename); if (depth == 0) xml=(char *) GetConfigureBlob(basename,path,&length,exception); else xml=(char *) FileToBlob(basename,&length,exception); if (xml == (char *) NULL) xml=AllocateString(DelegateMap); token=AllocateString(xml); for (q=xml; *q != '\0'; ) { /* Interpret XML. */ GetToken(q,&q,token); if (*token == '\0') break; (void) strlcpy(keyword,token,MaxTextExtent); if (LocaleNCompare(keyword,"<!--",4) == 0) { /* Comment element. */ while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0')) GetToken(q,&q,token); continue; } if (LocaleCompare(keyword,"<include") == 0) { /* Include element. */ while ((*token != '>') && (*q != '\0')) { (void) strlcpy(keyword,token,MaxTextExtent); GetToken(q,&q,token); if (*token != '=') continue; GetToken(q,&q,token); if (LocaleCompare(keyword,"file") == 0) { if (depth > 200) ThrowException(exception,ConfigureError,IncludeElementNestedTooDeeply,path); else { char filename[MaxTextExtent]; GetPathComponent(path,HeadPath,filename); if (*filename != '\0') (void) strlcat(filename,DirectorySeparator,MaxTextExtent); (void) strlcat(filename,token,MaxTextExtent); (void) ReadConfigureFile(filename,depth+1,exception); } if (delegate_list != (DelegateInfo *) NULL) while (delegate_list->next != (DelegateInfo *) NULL) delegate_list=delegate_list->next; } } continue; } if (LocaleCompare(keyword,"<delegate") == 0) { DelegateInfo *delegate_info; /* Allocate memory for the delegate list. */ delegate_info=MagickAllocateMemory(DelegateInfo *,sizeof(DelegateInfo)); if (delegate_info == (DelegateInfo *) NULL) MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed, UnableToAllocateDelegateInfo); (void) memset(delegate_info,0,sizeof(DelegateInfo)); delegate_info->path=AcquireString(path); delegate_info->signature=MagickSignature; if (delegate_list == (DelegateInfo *) NULL) { delegate_list=delegate_info; continue; } delegate_list->next=delegate_info; delegate_info->previous=delegate_list; delegate_list=delegate_list->next; continue; } if (delegate_list == (DelegateInfo *) NULL) continue; GetToken(q,(char **) NULL,token); if (*token != '=') continue; GetToken(q,&q,token); GetToken(q,&q,token); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare((char *) keyword,"command") == 0) { delegate_list->commands=AllocateString(token); #if defined(MSWINDOWS) if (strchr(delegate_list->commands,'@') != (char *) NULL) { char BinPath[MaxTextExtent], path[MaxTextExtent]; BinPath[0]=0; /* Substitute @PSDelegate@ with path to Ghostscript */ NTGhostscriptEXE(path,MaxTextExtent-1); SubstituteString((char **) &delegate_list->commands, "@PSDelegate@",path); # if defined(UseInstalledMagick) # if defined(MagickBinPath) strcpy(BinPath,MagickBinPath); # else { char *key, *key_value; /* Obtain installation path from registry */ key="BinPath"; key_value=NTRegistryKeyLookup(key); if (!key_value) { ThrowException(exception,ConfigureError, RegistryKeyLookupFailed,key); } else { strcpy(BinPath,key_value); MagickFreeMemory(key_value); } } # endif /* defined(MagickBinPath) */ # else /* Base path off of client path */ strcpy(BinPath,SetClientPath(NULL)); # endif /* defined(UseInstalledMagick) */ if ((BinPath[0] != 0) && (BinPath[strlen(BinPath)-1] != *DirectorySeparator)) strcat(BinPath,DirectorySeparator); /* Substitute @GMDelegate@ with path to gm.exe */ CatDelegatePath(path,BinPath,"gm.exe"); SubstituteString((char **) &delegate_list->commands, "@GMDelegate@",path); /* Substitute @GMDisplayDelegate@ with path to gmdisplay.exe */ CatDelegatePath(path,BinPath,"gmdisplay.exe"); SubstituteString((char **) &delegate_list->commands, "@GMDisplayDelegate@",path); /* Substitute @MPEGDecodeDelegate@ with path to mpeg2dec.exe */ CatDelegatePath(path,BinPath,"mpeg2dec.exe"); SubstituteString((char **) &delegate_list->commands, "@MPEGDecodeDelegate@",path); /* Substitute @MPEGEncodeDelegate@ with path to mpeg2enc.exe */ CatDelegatePath(path,BinPath,"mpeg2enc.exe"); SubstituteString((char **) &delegate_list->commands, "@MPEGEncodeDelegate@",path); /* Substitute @HPGLDecodeDelegate@ with path to hp2xx.exe */ CatDelegatePath(path,BinPath,"hp2xx.exe"); SubstituteString((char **) &delegate_list->commands, "@HPGLDecodeDelegate@",path); } #endif /* defined(MSWINDOWS) */ } /* LocaleCompare */ break; } case 'D': case 'd': { if (LocaleCompare((char *) keyword,"decode") == 0) { delegate_list->decode=AcquireString(token); delegate_list->mode=1; break; } break; } case 'E': case 'e': { if (LocaleCompare((char *) keyword,"encode") == 0) { delegate_list->encode=AcquireString(token); delegate_list->mode=(-1); break; } break; } case 'M': case 'm': { if (LocaleCompare((char *) keyword,"mode") == 0) { delegate_list->mode=1; if (LocaleCompare(token,"bi") == 0) delegate_list->mode=0; else if (LocaleCompare(token,"encode") == 0) delegate_list->mode=(-1); break; } break; } case 'S': case 's': { if (LocaleCompare((char *) keyword,"stealth") == 0) { delegate_list->stealth=LocaleCompare(token,"True") == 0; break; } break; } default: break; } }
unsigned int CGIToArgv(const char *text,int *argc,char ***argv) { char **vector; const char *p, *q; register int i; int count; if (text == (char *) NULL) return(False); /* Determine the number of arguments by scanning for delimiters */ q=text; count=0; while (1) { int len; p=q; while (!IsCGIDelimiter(*q)) q++; len=q-p; if (len > 0) count++; if (*q == '\0') break; q++; } vector=(char **) AcquireMemory((count+2)*sizeof(char *)); if (vector == (char **) NULL) { MagickError(ResourceLimitError,"Unable to convert string to argv", "Memory allocation failed"); return(False); } /* Convert string to an ASCII list. */ vector[0]=AllocateString("isapimagick"); vector[count+1]=(char *) NULL; q=text; i=1; while (i <= count) { int len; p=q; while (!IsCGIDelimiter(*q)) q++; /* Skip an zero length tokens. This typically happens for the case of xxx=& on a CGI GET or POST were the name value pair has no value */ len=q-p; if (len > 0) { vector[i]=(char *) AcquireMemory(q-p+1); if (vector[i] == (char *) NULL) { MagickError(ResourceLimitError,"Unable to convert string to argv", "Memory allocation failed"); return(False); } (void) strncpy(vector[i],p,q-p); vector[i][q-p]='\0'; /* Convert any special HTML codes in place back to ASCII */ HttpUnescape(vector[i], (char *) NULL); i++; } q++; } *argc=count+1; *argv=vector; return(True); }
bool GetDirectoryFileList(const udtFileListQuery& query) { if(query.Files == NULL || query.FolderPath == NULL || query.PersistAllocator == NULL || query.TempAllocator == NULL) { return false; } DIR* const dirHandle = opendir(query.FolderPath); if(dirHandle == NULL) { return false; } udtVMArray<const char*> folders; const udtString folderPath = udtString::NewConstRef(query.FolderPath); struct dirent* dirEntry; while((dirEntry = readdir(dirHandle)) != NULL) { if((dirEntry->d_type & DT_DIR) != 0) { if(query.Recursive && strcmp(dirEntry->d_name, ".") != 0 && strcmp(dirEntry->d_name, "..") != 0) { folders.Add(AllocateString(*query.TempAllocator, dirEntry->d_name)); } continue; } if((dirEntry->d_type & DT_REG) == 0) { // Not a regular file. continue; } udtString filePath; if(!udtPath::Combine(filePath, *query.TempAllocator, folderPath, dirEntry->d_name)) { return false; } const u64 fileSize = udtFileStream::GetFileLength(filePath.String); if(query.FileFilter != NULL && !(*query.FileFilter)(dirEntry->d_name, fileSize)) { continue; } udtFileInfo info; info.Name = AllocateString(*query.PersistAllocator, dirEntry->d_name); info.Path = AllocateString(*query.PersistAllocator, filePath.String); info.Size = fileSize; query.Files->Add(info); } closedir(dirHandle); if(query.Recursive) { for(u32 i = 0; i < folders.GetSize(); ++i) { udtString subFolderPath; if(!udtPath::Combine(subFolderPath, *query.TempAllocator, folderPath, folders[i])) { return false; } udtFileListQuery newQuery = query; newQuery.FolderPath = subFolderPath.String; if(!GetDirectoryFileList(newQuery)) { return false; } } } return true; }
bool GetDirectoryFileList(const udtFileListQuery& query) { if(query.Files == NULL || query.FolderPath == NULL || query.PersistAllocator == NULL || query.TempAllocator == NULL) { return false; } const udtString folderPath = udtString::NewConstRef(query.FolderPath); udtString queryPath; if(!udtPath::Combine(queryPath, *query.TempAllocator, folderPath, "*")) { return false; } WIN32_FIND_DATAA findData; const HANDLE findHandle = FindFirstFileA(queryPath.String, &findData); if(findHandle == INVALID_HANDLE_VALUE) { return false; } udtVMArray<const char*> folders; do { if((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { if(query.Recursive && strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0) { folders.Add(AllocateString(*query.TempAllocator, findData.cFileName)); } continue; } const u64 fileSize = (u64)findData.nFileSizeLow + ((u64)findData.nFileSizeHigh << 32); if(query.FileFilter != NULL && !(*query.FileFilter)(findData.cFileName, fileSize)) { continue; } udtString filePath; if(!udtPath::Combine(filePath, *query.TempAllocator, folderPath, findData.cFileName)) { return false; } udtFileInfo info; info.Name = AllocateString(*query.PersistAllocator, findData.cFileName); info.Path = AllocateString(*query.PersistAllocator, filePath.String); info.Size = fileSize; query.Files->Add(info); } while(FindNextFile(findHandle, &findData) != 0); FindClose(findHandle); if(query.Recursive) { for(u32 i = 0; i < folders.GetSize(); ++i) { udtString subFolderPath; if(!udtPath::Combine(subFolderPath, *query.TempAllocator, folderPath, folders[i])) { return false; } udtFileListQuery newQuery = query; newQuery.FolderPath = subFolderPath.String; if(!GetDirectoryFileList(newQuery)) { return false; } } } return true; }