install-ds.c
来自「支持SSL v2/v3, TLS, PKCS #5, PKCS #7, PKCS」· C语言 代码 · 共 1,542 行 · 第 1/3 页
C
1,542 行
{ int i; if(!_this->OS || !_this->arch || !cmp->OS || !cmp->arch) { return PR_FALSE; } if( PORT_Strcasecmp(_this->OS, cmp->OS) || PORT_Strcasecmp(_this->arch, cmp->arch) || _this->numDigits != cmp->numDigits ) { return PR_FALSE; } for(i=0; i < _this->numDigits; i++) { if(PORT_Strcasecmp(_this->verString[i], cmp->verString[i])) { return PR_FALSE; } } return PR_TRUE;}/*//////////////////////////////////////////////////////////////////////////// Method: operator <=// Class: Pk11Install_PlatformName// Returns: PR_TRUE if the platform have the same OS and arch and a lower// or equal release.*/PRBoolPk11Install_PlatformName_lteq(Pk11Install_PlatformName* _this, Pk11Install_PlatformName* cmp){ return (Pk11Install_PlatformName_equal(_this,cmp) || Pk11Install_PlatformName_lt(_this,cmp)) ? PR_TRUE : PR_FALSE;}/*//////////////////////////////////////////////////////////////////////////// Method: operator <// Class: Pk11Install_PlatformName// Returns: PR_TRUE if the platform have the same OS and arch and a greater// release.*/PRBoolPk11Install_PlatformName_lt(Pk11Install_PlatformName* _this, Pk11Install_PlatformName* cmp){ int i, scmp; if(!_this->OS || !_this->arch || !cmp->OS || !cmp->arch) { return PR_FALSE; } if( PORT_Strcasecmp(_this->OS, cmp->OS) ) { return PR_FALSE; } if( PORT_Strcasecmp(_this->arch, cmp->arch) ) { return PR_FALSE; } for(i=0; (i < _this->numDigits) && (i < cmp->numDigits); i++) { scmp = PORT_Strcasecmp(_this->verString[i], cmp->verString[i]); if (scmp > 0) { return PR_FALSE; } else if (scmp < 0) { return PR_TRUE; } } /* All the digits they have in common are the same. */ if(_this->numDigits < cmp->numDigits) { return PR_TRUE; } return PR_FALSE;}/*//////////////////////////////////////////////////////////////////////////// Method: GetString// Class: Pk11Install_PlatformName// Returns: String composed of OS, release, and architecture separated// by the separator char. Memory is allocated by this function// but is the responsibility of the caller to de-allocate.*/char*Pk11Install_PlatformName_GetString(Pk11Install_PlatformName* _this) { char *ret; char *ver; char *OS_; char *arch_; OS_=NULL; arch_=NULL; OS_ = _this->OS ? _this->OS : ""; arch_ = _this->arch ? _this->arch : ""; ver = Pk11Install_PlatformName_GetVerString(_this); ret = PR_smprintf("%s%c%s%c%s", OS_, PLATFORM_SEPARATOR_CHAR, ver, PLATFORM_SEPARATOR_CHAR, arch_); PR_Free(ver); return ret;}/*//////////////////////////////////////////////////////////////////////////// Method: GetVerString// Class: Pk11Install_PlatformName// Returns: The version string for this platform, in the form x.x.x with an// arbitrary number of digits. Memory allocated by function,// must be de-allocated by caller.*/char*Pk11Install_PlatformName_GetVerString(Pk11Install_PlatformName* _this) { char *tmp; char *ret; int i; char buf[80]; tmp = (char*)PR_Malloc(80*_this->numDigits+1); tmp[0] = '\0'; for(i=0; i < _this->numDigits-1; i++) { sprintf(buf, "%s.", _this->verString[i]); strcat(tmp, buf); } if(i < _this->numDigits) { sprintf(buf, "%s", _this->verString[i]); strcat(tmp, buf); } ret = PR_Strdup(tmp); free(tmp); return ret;}/*//////////////////////////////////////////////////////////////////////////// Method: Print// Class: Pk11Install_PlatformName*/voidPk11Install_PlatformName_Print(Pk11Install_PlatformName* _this, int pad){ PAD(pad); printf("OS: %s\n", _this->OS ? _this->OS : "<NULL>"); PAD(pad); printf("Digits: "); if(_this->numDigits == 0) { printf("None\n"); } else { printf("%s\n", Pk11Install_PlatformName_GetVerString(_this)); } PAD(pad); printf("arch: %s\n", _this->arch ? _this->arch : "<NULL>");}Pk11Install_Platform*Pk11Install_Platform_new(){ Pk11Install_Platform* new_this; new_this = (Pk11Install_Platform*)PR_Malloc(sizeof(Pk11Install_Platform)); Pk11Install_Platform_init(new_this); return new_this;}voidPk11Install_Platform_init(Pk11Install_Platform* _this){ Pk11Install_PlatformName_init(&_this->name); Pk11Install_PlatformName_init(&_this->equivName); _this->equiv = NULL; _this->usesEquiv = PR_FALSE; _this->moduleFile = NULL; _this->moduleName = NULL; _this->modFile = -1; _this->mechFlags = 0; _this->cipherFlags = 0; _this->files = NULL; _this->numFiles = 0;}/*//////////////////////////////////////////////////////////////////////////// Method: ~Pk11Install_Platform// Class: Pk11Install_Platform*/voidPk11Install_Platform_delete(Pk11Install_Platform* _this){ Pk11Install_Platform_Cleanup(_this);}/*//////////////////////////////////////////////////////////////////////////// Method: Cleanup// Class: Pk11Install_Platform*/voidPk11Install_Platform_Cleanup(Pk11Install_Platform* _this){ int i; if(_this->moduleFile) { PR_Free(_this->moduleFile); _this->moduleFile = NULL; } if(_this->moduleName) { PR_Free(_this->moduleName); _this->moduleName = NULL; } if(_this->files) { for (i=0;i<_this->numFiles;i++) { Pk11Install_File_delete(&_this->files[i]); } PR_Free(_this->files); _this->files = NULL; } _this->equiv = NULL; _this->usesEquiv = PR_FALSE; _this->modFile = -1; _this->numFiles = 0; _this->mechFlags = _this->cipherFlags = 0;}/*//////////////////////////////////////////////////////////////////////////// Method: Generate// Class: Pk11Install_Platform// Notes: Creates a platform data structure from a syntax tree.// Returns: NULL for success, otherwise an error message.*/char*Pk11Install_Platform_Generate(Pk11Install_Platform* _this, const Pk11Install_Pair *pair){ char* errStr; char* endptr; char* tmp; int i; Pk11Install_ListIter *iter; Pk11Install_Value *val; Pk11Install_Value *subval; Pk11Install_Pair *subpair; Pk11Install_ListIter *subiter; PRBool gotModuleFile, gotModuleName, gotMech, gotCipher, gotFiles, gotEquiv; errStr=NULL; iter=subiter=NULL; val=subval=NULL; subpair=NULL; gotModuleFile=gotModuleName=gotMech=gotCipher=gotFiles=gotEquiv=PR_FALSE; Pk11Install_Platform_Cleanup(_this); errStr = Pk11Install_PlatformName_Generate(&_this->name,pair->key); if(errStr) { tmp = PR_smprintf("%s: %s", pair->key, errStr); PR_smprintf_free(errStr); errStr = tmp; goto loser; } iter = Pk11Install_ListIter_new(pair->list); for( ; (val=iter->current); Pk11Install_ListIter_nextItem(iter)) { if(val->type==PAIR_VALUE) { subpair = val->pair; if( !PORT_Strcasecmp(subpair->key, MODULE_FILE_STRING)) { if(gotModuleFile) { errStr = PR_smprintf(errString[REPEAT_MODULE_FILE], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } subiter = Pk11Install_ListIter_new(subpair->list); subval = subiter->current; if(!subval || (subval->type != STRING_VALUE)) { errStr = PR_smprintf(errString[BOGUS_MODULE_FILE], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } _this->moduleFile = PR_Strdup(subval->string); Pk11Install_ListIter_delete(subiter); PR_Free(subiter); subiter = NULL; gotModuleFile = PR_TRUE; } else if(!PORT_Strcasecmp(subpair->key, MODULE_NAME_STRING)){ if(gotModuleName) { errStr = PR_smprintf(errString[REPEAT_MODULE_NAME], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } subiter = Pk11Install_ListIter_new(subpair->list); subval = subiter->current; if(!subval || (subval->type != STRING_VALUE)) { errStr = PR_smprintf(errString[BOGUS_MODULE_NAME], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } _this->moduleName = PR_Strdup(subval->string); Pk11Install_ListIter_delete(subiter); PR_Free(subiter); subiter = NULL; gotModuleName = PR_TRUE; } else if(!PORT_Strcasecmp(subpair->key, MECH_FLAGS_STRING)) { endptr=NULL; if(gotMech) { errStr = PR_smprintf(errString[REPEAT_MECH], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } subiter = Pk11Install_ListIter_new(subpair->list); subval = subiter->current; if(!subval || (subval->type != STRING_VALUE)) { errStr = PR_smprintf(errString[BOGUS_MECH_FLAGS], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } _this->mechFlags = strtol(subval->string, &endptr, 0); if(*endptr!='\0' || (endptr==subval->string) ) { errStr = PR_smprintf(errString[BOGUS_MECH_FLAGS], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } Pk11Install_ListIter_delete(subiter); PR_Free(subiter); subiter=NULL; gotMech = PR_TRUE; } else if(!PORT_Strcasecmp(subpair->key,CIPHER_FLAGS_STRING)) { endptr=NULL; if(gotCipher) { errStr = PR_smprintf(errString[REPEAT_CIPHER], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } subiter = Pk11Install_ListIter_new(subpair->list); subval = subiter->current; if(!subval || (subval->type != STRING_VALUE)) { errStr = PR_smprintf(errString[BOGUS_CIPHER_FLAGS], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } _this->cipherFlags = strtol(subval->string, &endptr, 0); if(*endptr!='\0' || (endptr==subval->string) ) { errStr = PR_smprintf(errString[BOGUS_CIPHER_FLAGS], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } Pk11Install_ListIter_delete(subiter); PR_Free(subiter); subiter=NULL; gotCipher = PR_TRUE; } else if(!PORT_Strcasecmp(subpair->key, FILES_STRING)) { if(gotFiles) { errStr = PR_smprintf(errString[REPEAT_FILES], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } subiter = Pk11Install_ListIter_new(subpair->list); _this->numFiles = subpair->list->numPairs; _this->files = (Pk11Install_File*) PR_Malloc(sizeof(Pk11Install_File)*_this->numFiles); for(i=0; i < _this->numFiles; i++, Pk11Install_ListIter_nextItem(subiter)) { Pk11Install_File_init(&_this->files[i]); val = subiter->current; if(val && (val->type==PAIR_VALUE)) { errStr = Pk11Install_File_Generate(&_this->files[i],val->pair); if(errStr) { tmp = PR_smprintf("%s: %s", Pk11Install_PlatformName_GetString(&_this->name),errStr); PR_smprintf_free(errStr); errStr = tmp; goto loser; } } } gotFiles = PR_TRUE; } else if(!PORT_Strcasecmp(subpair->key, EQUIVALENT_PLATFORM_STRING)) { if(gotEquiv) { errStr = PR_smprintf(errString[REPEAT_EQUIV], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } subiter = Pk11Install_ListIter_new(subpair->list); subval = subiter->current; if(!subval || (subval->type != STRING_VALUE) ) { errStr = PR_smprintf(errString[BOGUS_EQUIV], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } errStr = Pk11Install_PlatformName_Generate(&_this->equivName, subval->string); if(errStr) { tmp = PR_smprintf("%s: %s", Pk11Install_PlatformName_GetString(&_this->name), errStr); tmp = PR_smprintf("%s: %s", Pk11Install_PlatformName_GetString(&_this->name), errStr); PR_smprintf_free(errStr); errStr = tmp; goto loser; } _this->usesEquiv = PR_TRUE; } } } /* Make sure we either have an EquivalentPlatform or all the other info */ if(_this->usesEquiv && (gotFiles || gotModuleFile || gotModuleName || gotMech || gotCipher)) { errStr = PR_smprintf(errString[EQUIV_TOO_MUCH_INFO], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } if(!gotFiles && !_this->usesEquiv) { errStr = PR_smprintf(errString[NO_FILES], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } if(!gotModuleFile && !_this->usesEquiv) { errStr= PR_smprintf(errString[NO_MODULE_FILE], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } if(!gotModuleName && !_this->usesEquiv) { errStr = PR_smprintf(errString[NO_MODULE_NAME], Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } /* Point the modFile pointer to the correct file */ if(gotModuleFile) { for(i=0; i < _this->numFiles; i++) { if(!PORT_Strcasecmp(_this->moduleFile, _this->files[i].jarPath) ) { _this->modFile = i; break; } } if(_this->modFile==-1) { errStr = PR_smprintf(errString[UNKNOWN_MODULE_FILE], _this->moduleFile, Pk11Install_PlatformName_GetString(&_this->name)); goto loser; } } loser: if(iter) { PR_Free(iter); } if(subiter) { PR_Free(subiter); } return errStr;}/*//////////////////////////////////////////////////////////////////////////// Method: Print// Class: Pk11Install_Platform*/voidPk11Install_Platform_Print(Pk11Install_Platform* _this, int pad){ int i; PAD(pad); printf("Name:\n"); Pk11Install_PlatformName_Print(&_this->name,pad+PADINC); PAD(pad); printf("equivName:\n"); Pk11Install_PlatformName_Print(&_this->equivName,pad+PADINC); PAD(pad); if(_this->usesEquiv) { printf("Uses equiv, which points to:\n"); Pk11Install_Platform_Print(_this->equiv,pad+PADINC); } else { printf("Doesn't use equiv\n"); } PAD(pad); printf("Module File: %s\n", _this->moduleFile ? _this->moduleFile : "<NULL>"); PAD(pad); printf("mechFlags: %lx\n", _this->mechFlags); PAD(pad); printf("cipherFlags: %lx\n", _this->cipherFlags); PAD(pad); printf("Files:\n"); for(i=0; i < _this->numFiles; i++) { Pk11Install_File_Print(&_this->files[i],pad+PADINC); PAD(pad); printf("--------------------\n"); }}/*//////////////////////////////////////////////////////////////////////////// Method: Pk11Install_Info// Class: Pk11Install_Info*/Pk11Install_Info*Pk11Install_Info_new(){ Pk11Install_Info* new_this; new_this = (Pk11Install_Info*)PR_Malloc(sizeof(Pk11Install_Info)); Pk11Install_Info_init(new_this); return new_this;}voidPk11Install_Info_init(Pk11Install_Info* _this){ _this->platforms = NULL; _this->numPlatforms = 0; _this->forwardCompatible = NULL; _this->numForwardCompatible = 0;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?