void lo_DestroyScriptData(void *arg) { ScriptData *data = arg; if (data == NULL) return; XP_FREEIF(data->url); XP_FREEIF(data->archiveSrc); XP_FREEIF(data->id); XP_FREEIF(data->codebase); XP_FREEIF(data->buffer); if (data->tag) PA_FreeTag(data->tag); XP_FREE(data); }
PUBLIC void XP_NetHelp(MWContext *pContext, const char *topic) { MWContext *pActiveContext = NULL; char *pHelpURLString = NULL; /* Prepend the vendor name "netscape/" to all of our own topics */ if (topic == NULL) { pHelpURLString = XP_STRDUP("netscape/home"); } else { pHelpURLString = (char *) XP_ALLOC(strlen(topic) + strlen("netscape/")+1); if (!pHelpURLString) { return; } XP_STRCPY(pHelpURLString, "netscape/"); XP_STRCPY(&(pHelpURLString[9]), topic); } /* Now get the right context to load it from */ if (pContext != NULL) { pActiveContext = pContext; } else { pActiveContext = FE_GetNetHelpContext(); } NET_LoadNetHelpTopic(pActiveContext, pHelpURLString); XP_FREEIF(pHelpURLString); }
PUBLIC void NET_LoadNetHelpTopic(MWContext *pContext, const char *topic) { char *pNetHelpURLString; URL_Struct *pHelpURL; if (topic == NULL) { return; } /* Convert the fully-specified topic into a nethelp URL: */ pNetHelpURLString = (char *) XP_ALLOC(strlen(topic) + strlen(NETHELP_URL_PREFIX)+1); if (!pNetHelpURLString) { return; } XP_STRCPY(pNetHelpURLString, NETHELP_URL_PREFIX); XP_STRCPY(&(pNetHelpURLString[strlen(NETHELP_URL_PREFIX)]), topic); pHelpURL = NET_CreateURLStruct(pNetHelpURLString, NET_NORMAL_RELOAD); if (!pHelpURL) { return; } NET_GetURL(pHelpURL, FO_PRESENT, pContext, simple_exit); XP_FREEIF(pNetHelpURLString); }
char* vr_findVerRegName () { if ( verRegName != NULL ) return verRegName; #ifndef STANDALONE_REGISTRY { char *def = NULL; char settings[1024]; find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, settings, sizeof(settings)); if (settings != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(settings) + XP_STRLEN(BEOS_VERREG)+1); if (def != NULL) { XP_STRCPY(def, settings); XP_STRCAT(def, BEOS_VERREG); } } if (def != NULL) { verRegName = XP_STRDUP(def); } XP_FREEIF(def); } #else verRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ return verRegName; }
char* vr_findVerRegName () { if ( verRegName != NULL ) return verRegName; #ifndef STANDALONE_REGISTRY { char *def = NULL; char *home = getenv("HOME"); if (home != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(home) + XP_STRLEN(DEF_VERREG)+1); if (def != NULL) { XP_STRCPY(def, home); XP_STRCAT(def, DEF_VERREG); } } if (def != NULL) { verRegName = XP_STRDUP(def); } XP_FREEIF(def); } #else verRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ return verRegName; }
VR_INTERFACE(REGERR) VR_UninstallDeleteSharedFilesKey(char *component_path) { REGERR err; char *regbuf; char *converted_component_path; uint32 convertedDataLength = 0; uint32 regbuflen = 0; uint32 curregbuflen = 0; uint32 len = 0; err = vr_Init(); if (err != REGERR_OK) return err; if ( component_path == NULL ) err = REGERR_PARAM; convertedDataLength = 2 * XP_STRLEN(component_path) + 1; converted_component_path = (char*)XP_ALLOC(convertedDataLength); if (converted_component_path == NULL ) { err = REGERR_MEMORY; return err; } err = vr_convertPackageName(component_path, converted_component_path, convertedDataLength); if (err != REGERR_OK) { XP_FREEIF(converted_component_path); return err; } regbuflen = 256 + XP_STRLEN(converted_component_path); regbuf = (char*)XP_ALLOC( regbuflen ); if (regbuf != NULL ) { err = vr_GetUninstallItemPath(converted_component_path, regbuf, regbuflen); if (err == REGERR_OK) { curregbuflen = XP_STRLEN(regbuf); len = XP_STRLEN(SHAREDFILESSTR); if (len < (regbuflen - curregbuflen)) { XP_STRCAT(regbuf, SHAREDFILESSTR); err = NR_RegDeleteKey( vreg, ROOTKEY_PRIVATE, regbuf ); } else err = REGERR_BUFTOOSMALL; } XP_FREE(regbuf); } else { err = REGERR_MEMORY; } XP_FREE(converted_component_path); return err; } /* UninstallDeleteSharedFilesKey */
/*ARGSUSED*/ _cfmi_finalize(struct cfmi* self, jint op, JMCException* *exception) { struct cfmiImpl *oimpl = cfmi2cfmiImpl(self); FontMatchInfoObject *fmiob = (FontMatchInfoObject *)oimpl->object; delete fmiob; /* Finally, free the memory for the object containter. */ XP_FREEIF(self); }
MODULE_PRIVATE void net_UsePadPac(XP_Bool useIt) { if(useIt) { net_PadPacURLPrefChanged(NULL, NULL); } else { MK_PadEnabled=FALSE; NET_ProxyAcLoaded=FALSE; XP_FREEIF(MK_padPacURL); MK_padPacURL=NULL; net_SetPACUrl(NULL); } }
/* Set the MK_padPacURL varialbe to point to the string passed in. */ PUBLIC XP_Bool NET_SetPadPacURL(char * u) { char *url=NULL; if(!u || *u == '\0') return FALSE; StrAllocCopy(url, u); if(url && *url) { char *host=NET_ParseURL(url, GET_HOST_PART); if(host && *host && (sizeof(host) <= MAXHOSTNAMELEN) ) { if(MK_padPacURL) XP_FREE(MK_padPacURL); MK_padPacURL=url; return TRUE; } else { XP_FREE(url); XP_FREEIF(host); } } else { XP_FREEIF(url); } return FALSE; }
extern void vr_findGlobalRegName () { char path[ PATHLEN ]; int pathlen; pathlen = GetWindowsDirectory(path, PATHLEN); if ( pathlen > 0 ) { XP_FREEIF(globalRegName); XP_STRCPY( path+pathlen, WIN_REG ); globalRegName = XP_STRDUP(path); } }
VR_INTERFACE(REGERR) VR_CreateRegistry( char *installation, char *programPath, char *versionStr ) { REGERR err; char * regname = vr_findVerRegName(); #if defined(XP_UNIX) && !defined(XP_MACOSX) char * regbuf = NULL; #endif if ( installation == NULL || *installation == '\0' ) return REGERR_PARAM; #if defined(XP_UNIX) && !defined(XP_MACOSX) #ifndef STANDALONE_REGISTRY if (bGlobalRegistry) #endif { regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(programPath) ); if (regbuf == NULL) return REGERR_MEMORY; XP_STRCPY( regbuf, programPath ); XP_STRCAT( regbuf, "registry" ); regname = regbuf; } #endif /* XP_UNIX */ PR_Lock(vr_lock); /* automatically creates it if not found */ err = NR_RegOpen( regname, &vreg ); if (err == REGERR_OK) { /* create default tree with 'installation' under Navigator */ /* set Current to the installation string */ err = vr_SetCurrentNav( installation, programPath, versionStr ); if ( REGERR_OK == err ) isInited = 1; else NR_RegClose( vreg ); } PR_Unlock(vr_lock); #if defined(XP_UNIX) && !defined(XP_MACOSX) XP_FREEIF( regbuf ); #endif return err; } /* CreateRegistry */
VR_INTERFACE(REGERR) VR_UninstallFileExistsInList(char *regPackageName, char *vrName) { REGERR err; RKEY key = 0; char *regbuf; char sharedfilesstr[MAXREGNAMELEN]; uint32 regbuflen = 0; uint32 curregbuflen = 0; uint32 len = 0; err = vr_Init(); if (err != REGERR_OK) return err; if ( regPackageName == NULL ) err = REGERR_PARAM; if ( vrName == NULL ) err = REGERR_PARAM; regbuflen = 256 + XP_STRLEN(regPackageName); regbuf = (char*)XP_ALLOC( regbuflen ); if (regbuf != NULL ) { err = vr_GetUninstallItemPath(regPackageName, regbuf, regbuflen); if (err == REGERR_OK) { curregbuflen = XP_STRLEN(regbuf); len = XP_STRLEN(SHAREDFILESSTR); if (len < (regbuflen - curregbuflen)) { XP_STRCAT(regbuf, SHAREDFILESSTR); err = NR_RegGetKey( vreg, ROOTKEY_PRIVATE, regbuf, &key ); } else err = REGERR_BUFTOOSMALL; } XP_FREEIF(regbuf); } else { err = REGERR_MEMORY; } if (err == REGERR_OK) err = NR_RegGetEntryString( vreg, key, vrName, sharedfilesstr, sizeof(sharedfilesstr) ); return err; } /* UninstallFileExistsInList */
/*ARGSUSED*/ _cf_finalize(struct cf* self, jint op, JMCException* *exception) { /* Release this font object from the fontObjectCache in the Broker */ cfbImpl *fbimpl = cfb2cfbImpl(WF_fbc); FontBrokerObject *fbobj = (FontBrokerObject *)fbimpl->object; WF_TRACEMSG( ("NF: Deleting font object [0x%x].", fbobj) ); fbobj->fontObjectCache.releaseFont((struct nff *)self); /* Delete the font object */ struct cfImpl *oimpl = cf2cfImpl(self); FontObject *fob = (FontObject *)oimpl->object; delete fob; /* Finally, free the memory for the object containter. */ XP_FREEIF(self); }
VR_INTERFACE(REGERR) VR_SetRegDirectory(const char *path) { char *tmp; tmp = XP_STRDUP(path); if (NULL == tmp) { return REGERR_MEMORY; } PR_Lock(vr_lock); XP_FREEIF(app_dir); app_dir = tmp; PR_Unlock(vr_lock); return REGERR_OK; }
/* NativeGetDirectoryPath * gets a platform-specific directory path * stores it in urlPath */ int nsFolderSpec::NativeGetDirectoryPath() { su_DirSpecID folderDirSpecID; char* folderPath = NULL; /* Get the name of the package to prompt for */ folderDirSpecID = MapNameToEnum(folderID); switch (folderDirSpecID) { case eBadFolder: return SUERR_INVALID_PATH_ERR; case eCurrentUserFolder: { char dir[MAX_PATH]; int len = MAX_PATH; if ( PREF_GetCharPref("profile.directory", dir, &len) == PREF_NOERROR) { char * platformDir = WH_FileName(dir, xpURL); if (platformDir) folderPath = AppendSlashToDirPath(platformDir); XP_FREEIF(platformDir); } } break; default: /* Get the FE path */ folderPath = FE_GetDirectoryPath(folderDirSpecID); break; } /* Store it in the object */ if (folderPath != NULL) { urlPath = NULL; urlPath = XP_STRDUP(folderPath); XP_FREE(folderPath); return 0; } return SUERR_INVALID_PATH_ERR; }
XP_Dir XP_OpenDir(const char * name, XP_FileType type) { XP_Dir dir = NULL; char *pathName = NULL; switch (type) { case xpMailSubdirectory: pathName = PR_smprintf ("%s%s", name, ".sbd"); if (pathName) { dir = opendir (pathName); XP_FREEIF(pathName); } else dir = NULL; break; default: dir = opendir (name); } return dir; }
extern void vr_findGlobalRegName () { #ifndef STANDALONE_REGISTRY char *def = NULL; char *home = getenv("HOME"); if (home != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(home) + XP_STRLEN(DEF_REG)+1); if (def != NULL) { XP_STRCPY(def, home); XP_STRCAT(def, DEF_REG); } } if (def != NULL) { globalRegName = XP_STRDUP(def); } else { globalRegName = XP_STRDUP(TheRegistry); } XP_FREEIF(def); #else globalRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ }
extern void vr_findGlobalRegName () { #ifndef STANDALONE_REGISTRY char *def = NULL; char settings[1024]; find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, settings, sizeof(settings)); if (settings != NULL) { def = (char *) XP_ALLOC(XP_STRLEN(settings) + XP_STRLEN(BEOS_REG)+1); if (def != NULL) { XP_STRCPY(def, settings); XP_STRCAT(def, BEOS_REG); } } if (def != NULL) { globalRegName = XP_STRDUP(def); } else { globalRegName = XP_STRDUP(TheRegistry); } XP_FREEIF(def); #else globalRegName = XP_STRDUP(TheRegistry); #endif /*STANDALONE_REGISTRY*/ }
void XFE_ABNameGenTabView::setDlgValues() { /* Get mode, entryid, and ab_view */ XFE_ABNameFolderDlg *dlg = (XFE_ABNameFolderDlg *)getToplevel(); #if defined(USE_ABCOM) XFE_PropertySheetView *folderView = (XFE_PropertySheetView *) getParent(); MSG_Pane *pane = folderView->getPane(); uint16 numItems = AB_LAST+2; AB_AttribID * attribs = (AB_AttribID *) XP_CALLOC(numItems, sizeof(AB_AttribID)); attribs[AB_FIRST_NAME] = AB_attribGivenName; attribs[AB_LAST_NAME] = AB_attribFamilyName; attribs[AB_DISPLAY_NAME] = AB_attribDisplayName; attribs[AB_EMAIL] = AB_attribEmailAddress; attribs[AB_NICKNAME] = AB_attribNickName; attribs[AB_TITLE] = AB_attribTitle; attribs[AB_COMPANY_NAME] = AB_attribCompanyName; attribs[AB_LAST] = AB_attribInfo; attribs[AB_LAST+1] = AB_attribHTMLMail; AB_AttributeValue *values = NULL; int error = AB_GetPersonEntryAttributes(pane, attribs, &values, &numItems); char *tmp = NULL; for (int i=0; i < numItems; i++) { switch (values[i].attrib) { case AB_attribGivenName: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_FIRST_NAME], tmp?tmp:""); break; case AB_attribFamilyName: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_LAST_NAME], tmp?tmp:""); break; case AB_attribDisplayName: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_DISPLAY_NAME], tmp?tmp:""); break; case AB_attribEmailAddress: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_EMAIL], tmp?tmp:""); break; case AB_attribNickName: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_NICKNAME], tmp?tmp:""); break; case AB_attribTitle: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_TITLE], tmp?tmp:""); break; case AB_attribCompanyName: tmp = values[i].u.string; fe_SetTextField(m_textFs[AB_COMPANY_NAME], tmp?tmp:""); break; case AB_attribInfo: // AB_attribInfo tmp = values[i].u.string; fe_SetTextField(m_notesTxt, tmp?tmp:""); break; case AB_attribHTMLMail: XmToggleButtonSetState(m_prefHTMLTog, values[i].u.boolValue, FALSE); break; }/* switch */ }/* for i */ XP_FREEIF(attribs); AB_FreeEntryAttributeValues(values, numItems); #else PersonEntry& entry = dlg->getPersonEntry(); fe_SetTextField(m_textFs[AB_FIRST_NAME], entry.pGivenName?entry.pGivenName:""); fe_SetTextField(m_textFs[AB_LAST_NAME], entry.pFamilyName?entry.pFamilyName:""); fe_SetTextField(m_textFs[AB_COMPANY_NAME], entry.pCompanyName?entry.pCompanyName:""); fe_SetTextField(m_textFs[AB_TITLE], entry.pTitle?entry.pTitle:""); fe_SetTextField(m_textFs[AB_EMAIL], entry.pEmailAddress?entry.pEmailAddress:""); fe_SetTextField(m_textFs[AB_NICKNAME], entry.pNickName?entry.pNickName:""); fe_SetTextField(m_notesTxt, entry.pInfo?entry.pInfo:""); XmToggleButtonSetState(m_prefHTMLTog, entry.HTMLmail, FALSE); #endif /* USE_ABCOM */ }
static REGERR vr_Init(void) { REGERR err = REGERR_OK; char *regname = vr_findVerRegName(); #if defined(XP_UNIX) && !defined(XP_MACOSX) || defined(STANDALONE_REGISTRY) char curstr[MAXREGNAMELEN]; RKEY navKey; #endif #if defined(XP_UNIX) && !defined(XP_MACOSX) char *regbuf = NULL; #endif #ifndef STANDALONE_REGISTRY if (vr_lock == NULL) return REGERR_FAIL; #endif PR_Lock(vr_lock); if (!isInited) { #if defined(XP_UNIX) && !defined(XP_MACOSX) /* need browser directory to find the correct registry */ if (app_dir != NULL) { regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(app_dir) ); if (regbuf != NULL ) { XP_STRCPY( regbuf, app_dir ); XP_STRCAT( regbuf, "/registry" ); } else { err = REGERR_MEMORY; } } if ( err != REGERR_OK ) goto done; if (bGlobalRegistry) regname = regbuf; #endif /* Open version registry */ err = NR_RegOpen( regname, &vreg ); #ifndef STANDALONE_REGISTRY if (err == REGERR_OK) { /* find/set the current nav node */ err = vr_SetCurrentNav( VERSION_NAME, app_dir, NULL ); if ( REGERR_OK != err ) { /* couldn't find or set current nav -- big problems! */ NR_RegClose( vreg ); goto done; } } #if defined(XP_UNIX) && !defined(XP_MACOSX) /* try to open shared Unix registry, but not an error if you can't */ unixreg = NULL; if (!bGlobalRegistry && err == REGERR_OK ) { unixver = 0; if (NR_RegOpen( regbuf, &unixreg ) == REGERR_OK) { if (NR_RegGetKey( unixreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE, &navKey) == REGERR_OK) { if (NR_RegGetEntryString( unixreg, navKey, CURRENT_VER, curstr, sizeof(curstr)) == REGERR_OK ) { NR_RegGetKey( unixreg, navKey, curstr, &unixver ); } } } } #endif if (err == REGERR_OK) { /* successfully opened! */ isInited = 1; } goto done; #else if (err != REGERR_OK) goto done; /* Determine 'curver' key and ensure correct structure by adding */ /* ...find top-level "Navigator" node (add if missing) */ err = NR_RegAddKey( vreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE, &navKey ); if (err != REGERR_OK) goto done; /* ...look for "Current Version" entry */ err = NR_RegGetEntryString( vreg, navKey, CURRENT_VER, curstr, sizeof(curstr) ); if ( err == REGERR_NOFIND ) { /* If not found create one with the built-in version */ err = NR_RegSetEntryString( vreg, navKey, CURRENT_VER, VERSION_NAME ); XP_STRCPY( curstr, VERSION_NAME ); } if ( err != REGERR_OK ) goto done; /* ...look for "curstr" child key of the navigator node */ err = NR_RegAddKey( vreg, navKey, curstr, &curver ); if (err == REGERR_OK) { /* successfully opened! */ isInited = 1; } #endif } done: PR_Unlock(vr_lock); #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(STANDALONE_REGISTRY) XP_FREEIF(regbuf); #endif return err; } /* Init */
VR_INTERFACE(REGERR) VR_UninstallEnumSharedFiles(char *component_path, REGENUM *state, char *buffer, uint32 buflen) { REGERR err; RKEY key = 0; char *regbuf; char *converted_component_path; uint32 convertedDataLength = 0; uint32 regbuflen = 0; uint32 curregbuflen = 0; uint32 len = 0; err = vr_Init(); if (err != REGERR_OK) return err; if ( component_path == NULL ) return REGERR_PARAM; convertedDataLength = 2 * XP_STRLEN(component_path) + 1; converted_component_path = (char*)XP_ALLOC(convertedDataLength); if (converted_component_path == NULL ) { err = REGERR_MEMORY; return err; } err = vr_convertPackageName(component_path, converted_component_path, convertedDataLength); if (err != REGERR_OK) { XP_FREEIF(converted_component_path); return err; } regbuflen = 256 + XP_STRLEN(converted_component_path); regbuf = (char*)XP_ALLOC( regbuflen ); if (regbuf != NULL ) { err = vr_GetUninstallItemPath(converted_component_path, regbuf, regbuflen); if (err == REGERR_OK) { curregbuflen = XP_STRLEN(regbuf); len = XP_STRLEN(SHAREDFILESSTR); if (len < (regbuflen - curregbuflen)) { XP_STRCAT(regbuf, SHAREDFILESSTR); err = NR_RegGetKey( vreg, ROOTKEY_PRIVATE, regbuf, &key ); } else err = REGERR_BUFTOOSMALL; } XP_FREE(regbuf); } else { err = REGERR_MEMORY; } XP_FREE(converted_component_path); if (err == REGERR_OK) err = NR_RegEnumEntries( vreg, key, state, buffer, buflen, NULL); return err; } /* UninstallEnumSharedFiles */
const char * lm_CheckURL(JSContext *cx, const char *url_string, JSBool checkFile) { char *protocol, *absolute; JSObject *obj; MochaDecoder *decoder; protocol = NET_ParseURL(url_string, GET_PROTOCOL_PART); if (!protocol || *protocol == '\0') { lo_TopState *top_state; obj = JS_GetGlobalObject(cx); decoder = JS_GetPrivate(cx, obj); LO_LockLayout(); top_state = lo_GetMochaTopState(decoder->window_context); if (top_state && top_state->base_url) { absolute = NET_MakeAbsoluteURL(top_state->base_url, (char *)url_string); /*XXX*/ /* * Temporarily unlock layout so that we don't hold the lock * across a call (lm_CheckPermissions) that may result in * synchronous event handling. */ LO_UnlockLayout(); if (!lm_CheckPermissions(cx, obj, JSTARGET_UNIVERSAL_BROWSER_READ)) { /* Don't leak information about the url of this page. */ XP_FREEIF(absolute); return NULL; } LO_LockLayout(); } else { absolute = NULL; } if (absolute) { if (protocol) XP_FREE(protocol); protocol = NET_ParseURL(absolute, GET_PROTOCOL_PART); } LO_UnlockLayout(); } else { absolute = JS_strdup(cx, url_string); if (!absolute) { XP_FREE(protocol); return NULL; } decoder = NULL; } if (absolute) { /* Make sure it's a safe URL type. */ switch (NET_URL_Type(protocol)) { case FILE_TYPE_URL: if (checkFile) { const char *subjectOrigin = lm_GetSubjectOriginURL(cx); if (subjectOrigin == NULL) { XP_FREE(protocol); return NULL; } if (NET_URL_Type(subjectOrigin) != FILE_TYPE_URL && !lm_CanAccessTarget(cx, JSTARGET_UNIVERSAL_FILE_READ)) { XP_FREE(absolute); absolute = NULL; } } break; case FTP_TYPE_URL: case GOPHER_TYPE_URL: case HTTP_TYPE_URL: case MAILTO_TYPE_URL: case NEWS_TYPE_URL: case RLOGIN_TYPE_URL: case TELNET_TYPE_URL: case TN3270_TYPE_URL: case WAIS_TYPE_URL: case SECURE_HTTP_TYPE_URL: case URN_TYPE_URL: case NFS_TYPE_URL: case MOCHA_TYPE_URL: case VIEW_SOURCE_TYPE_URL: case NETHELP_TYPE_URL: case WYSIWYG_TYPE_URL: case LDAP_TYPE_URL: #ifdef JAVA case MARIMBA_TYPE_URL: #endif /* These are "safe". */ break; case ABOUT_TYPE_URL: if (XP_STRCASECMP(absolute, "about:blank") == 0) break; if (XP_STRNCASECMP(absolute, "about:pics", 10) == 0) break; /* these are OK if we are signed */ if (lm_CanAccessTarget(cx, JSTARGET_UNIVERSAL_BROWSER_READ)) break; /* FALL THROUGH */ default: /* All others are naughty. */ XP_FREE(absolute); absolute = NULL; break; } } if (!absolute) { JS_ReportError(cx, "illegal URL method '%s'", protocol && *protocol ? protocol : url_string); } if (protocol) XP_FREE(protocol); return absolute; }
void XFE_PrefsLdapPropDialog::cb_ok(Widget w, XtPointer closure, XtPointer callData) { XFE_PrefsLdapPropDialog *theDialog = (XFE_PrefsLdapPropDialog *)closure; PrefsDataLdapProp *fep = theDialog->getData(); Bool create = theDialog->getEditDir() ? False : True; DIR_Server *dir = 0; if (create) { dir = (DIR_Server *)XP_ALLOC(sizeof(DIR_Server)); DIR_InitServer(dir); } else { dir = theDialog->getEditDir(); XP_FREEIF(dir->description); XP_FREEIF(dir->serverName); XP_FREEIF(dir->searchBase); DIR_InitServer(dir); } char *desc = 0; char *server = 0; char *root = 0; char *port_num_text = 0; char *num_hits_text = 0; char dummy; int port_num = 0; int num_hits = 0; Boolean b; char temp[1024]; char *ptr; // TODO: error checking desc = fe_GetTextField(fep->desc_text); server = fe_GetTextField(fep->server_text); root = fe_GetTextField(fep->root_text); XtVaGetValues(fep->port_number_text, XmNvalue, &port_num_text, 0); XtVaGetValues(fep->number_of_hit_text, XmNvalue, &num_hits_text, 0); if (1 != sscanf(port_num_text, " %d %c", &port_num, &dummy) || port_num < 0) { // TODO: error } if (port_num_text) XtFree(port_num_text); if (1 == sscanf(num_hits_text, " %d %c", &num_hits, &dummy) && num_hits < 0) { // TODO: error } if (num_hits_text) XtFree(num_hits_text); if (ptr = XP_STRCHR(server, '.')) { XP_STRCPY(temp, ptr+1); if (ptr = XP_STRCHR(temp, '.')) { *ptr = '\0'; } } else { XP_STRCPY(temp, server); } dir->description = desc ? desc : XP_STRDUP(""); dir->serverName = server ? server : XP_STRDUP(""); dir->searchBase = root ? root : XP_STRDUP(""); // dir->htmlGateway = NULL; // no loner use dir->fileName = WH_FileName(WH_TempName(xpAddrBook, temp), xpAddrBook); dir->port = port_num; dir->maxHits = num_hits; XtVaGetValues(fep->secure_toggle, XmNset, &b, 0); dir->isSecure = b; #if 0 XtVaGetValues(fep->save_passwd_toggle, XmNset, &b, 0); dir->savePassword = b; #endif dir->dirType = LDAPDirectory; // Insert into list if this is create if (create) { XFE_PrefsPageMailNewsAddrBook *dir_page = theDialog->getAddrBookPage(); dir_page->insertDir(dir); } // Simulate a cancel theDialog->cb_cancel(w, closure, callData); }
/* NativeComplete * copies the file to its final location * Tricky, we need to create the directories */ int nsInstallFile::NativeComplete() { char* currentName = NULL; char* finalName = NULL; char* finalNamePlatform; int result = 0; if (tempFile == NULL) { return -1; } /* Get the names */ currentName = tempFile->ToNewCString(); PR_ASSERT(finalFile != NULL); finalNamePlatform = finalFile->ToNewCString(); finalName = XP_PlatformFileToURL(finalNamePlatform); if ( finalName == NULL || currentName == NULL ) { /* memory or JRI problems */ result = -1; goto end; } else { /* convert finalName name to xpURL form by stripping "file://" */ char *temp = XP_STRDUP(&finalName[7]); XP_FREE(finalName); finalName = temp; } if (finalName != NULL) { if ( XP_STRCMP(finalName, currentName) == 0 ) { /* No need to rename, they are the same */ result = 0; } else { XP_StatStruct s; if ( XP_Stat( finalName, &s, xpURL ) != 0 ) { /* Target file doesn't exist, try to rename file */ result = XP_FileRename(currentName, xpURL, finalName, xpURL); } else { /* Target exists, can't trust XP_FileRename--do platform * specific stuff in FE_ReplaceExistingFile() */ result = -1; } } } else { /* memory problem */ result = -1; } if (result != 0) { XP_StatStruct s; if ( XP_Stat( finalName, &s, xpURL ) == 0 ) { /* File already exists, need to remove the original */ result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, force); if ( result == SU_REBOOT_NEEDED ) { #ifdef XP_WIN16 if (!utilityScheduled) { utilityScheduled = PR_TRUE; FE_ScheduleRenameUtility(); } #endif } } else { /* Directory might not exist, check and create if necessary */ char separator; char * end; separator = '/'; end = XP_STRRCHR(finalName, separator); if (end) { end[0] = 0; result = XP_MakeDirectoryR( finalName, xpURL); end[0] = separator; if ( 0 == result ) result = XP_FileRename(currentName, xpURL, finalName, xpURL); } } #ifdef XP_UNIX /* Last try, can't rename() across file systems on UNIX */ if ( -1 == result ) { result = FE_CopyFile(currentName, finalName); } #endif } end: XP_FREEIF(finalName); delete currentName; delete finalNamePlatform; return result; }
static void lo_script_archive_exit_fn(URL_Struct *url_struct, int status, MWContext *context) { ScriptData *data = NULL; char *name; JSPrincipals *principals; ETEvalStuff * stuff; data = (ScriptData *) url_struct->fe_data; stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff); if (!stuff) return; stuff->line_no = 1; stuff->scope_to = NULL; stuff->want_result = JS_FALSE; stuff->version = data->version; stuff->data = context; #ifndef JAVA /* No Java; execute without principals. */ if (data->buffer) { stuff->principals = NULL; ET_EvaluateScript(context, data->buffer, stuff, lo_ScriptEvalExitFn); } else { XP_FREE(stuff); } #else name = data->archiveSrc ? data->archiveSrc : data->id; principals = LM_NewJSPrincipals(url_struct, name, data->codebase); if (principals != NULL) { char *src; uint srcSize; if (data->archiveSrc) { /* Extract from archive using "SRC=" value */ src = LM_ExtractFromPrincipalsArchive(principals, data->archiveSrc, &srcSize); #ifdef JSDEBUGGER if( src != NULL && LM_GetJSDebugActive() ) { char *path = lo_BuildJSArchiveURL(url_struct->address, data->archiveSrc); if (path) { LM_JamSourceIntoJSDebug( path, src, srcSize, context ); XP_FREE(path); } } #endif /* JSDEBUGGER */ if (src == NULL) { /* Unsuccessful extracting from archive. Now try normal SRC= lookup. */ (*principals->destroy)(NULL, principals); data->url = NET_MakeAbsoluteURL(data->state->top_state->base_url, data->archiveSrc); XP_FREEIF(data->archiveSrc); data->archiveSrc = NULL; lo_GetScriptFromURL(data, data->state->top_state->in_script); goto out; } } else { /* Should be an inline script */ src = data->buffer; srcSize = data->bufferSize; } stuff->len = srcSize; stuff->principals = principals; ET_EvaluateScript(context, src, stuff, lo_ScriptEvalExitFn); if (data->archiveSrc){ ET_SetNestingUrl(context, NULL); XP_FREE(src); } } else { XP_FREE(stuff); } #endif /* ifdef JAVA */ lo_DestroyScriptData(data); out: /* Always free (or drop a ref on) the url_struct before returning. */ NET_FreeURLStruct(url_struct); }
void lo_ProcessScriptTag(MWContext *context, lo_DocState *state, PA_Tag *tag, JSObject *obj) { lo_TopState *top_state; pa_DocData *doc_data; XP_Bool type_explicitly_set=FALSE; XP_Bool saw_archive=FALSE; #ifdef DEBUG_ScriptPlugin char * mimebuf = NULL; #endif top_state = state->top_state; doc_data = (pa_DocData *)top_state->doc_data; XP_ASSERT(doc_data != NULL || state->in_relayout || tag->lo_data); if (tag->is_end == FALSE) { PA_Block buff; char *str, *url, *archiveSrc, *id, *codebase; /* Controversial default language value. */ top_state->version = JSVERSION_DEFAULT; if (tag->type == P_STYLE || tag->type == P_LINK) { top_state->in_script = top_state->default_style_script_type; } else { /* in order to get old script behaviour, pretend * that the content-type is explicitly set for all scripts */ type_explicitly_set = TRUE; top_state->in_script = SCRIPT_TYPE_MOCHA; } /* XXX account for HTML comment bytes and "lost" newlines */ if (lo_IsAnyCurrentAncestorSourced(state)) top_state->script_bytes = top_state->layout_bytes; else top_state->script_bytes = top_state->layout_bytes - tag->true_len; if (tag->lo_data != NULL) { top_state->script_bytes += (int32)tag->lo_data - 1; tag->lo_data = NULL; } else if (doc_data != NULL) { top_state->script_bytes += doc_data->comment_bytes; } else { XP_ASSERT(state->in_relayout); } lo_ParseScriptLanguage(context, tag, &top_state->in_script, &top_state->version); #ifdef DEBUG_ScriptPlugin if (top_state->in_script == SCRIPT_TYPE_UNKNOWN) { mimebuf = npl_Script2mimeType(context,tag); if (mimebuf){ if (NPL_FindPluginEnabledForType(mimebuf)){ top_state->in_script = SCRIPT_TYPE_PLUGIN; XP_ASSERT(top_state->mimetype == NULL); StrAllocCopy((char *)top_state->mimetype,mimebuf); XP_FREE(mimebuf); mimebuf = NULL; } else{ XP_FREE(mimebuf); mimebuf = NULL; } } } #endif /* DEBUG_ScriptPlugin */ buff = lo_FetchParamValue(context, tag, PARAM_TYPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if ((XP_STRCASECMP(str, js_content_type) == 0) || (!XP_STRCASECMP(str, "text/javascript"))) { if(tag->type == P_STYLE || tag->type == P_LINK) { top_state->in_script = SCRIPT_TYPE_JSSS; top_state->default_style_script_type = SCRIPT_TYPE_JSSS; } else { top_state->in_script = SCRIPT_TYPE_MOCHA; } type_explicitly_set = TRUE; } else if ((XP_STRCASECMP(str, TEXT_CSS) == 0)) { top_state->in_script = SCRIPT_TYPE_CSS; top_state->default_style_script_type = SCRIPT_TYPE_CSS; type_explicitly_set = TRUE; } else { top_state->in_script = SCRIPT_TYPE_UNKNOWN; top_state->default_style_script_type = SCRIPT_TYPE_UNKNOWN; } PA_UNLOCK(buff); PA_FREE(buff); } /* check for media=screen * don't load the style sheet if there * is a media not equal to screen */ buff = lo_FetchParamValue(context, tag, PARAM_MEDIA); if (buff) { if (strcasecomp((char*)buff, "screen")) { /* set the script type to UNKNOWN * so that it will get thrown away */ top_state->in_script = SCRIPT_TYPE_UNKNOWN; } PA_FREE(buff); } /* * Flush the line buffer so we can start storing Mocha script * source lines in there. */ lo_FlushLineBuffer(context, state); url = archiveSrc = id = codebase = NULL; if (top_state->in_script != SCRIPT_TYPE_NOT) { /* * Check for the archive parameter for known languages. */ buff = lo_FetchParamValue(context, tag, PARAM_ARCHIVE); if (buff != NULL) { saw_archive = TRUE; PA_LOCK(str, char *, buff); url = NET_MakeAbsoluteURL(top_state->base_url, str); PA_UNLOCK(buff); PA_FREE(buff); if (url == NULL) { top_state->out_of_memory = TRUE; return; } } /* * Look for ID attribute. If it's there we have may have * an inline signed script. */ buff = lo_FetchParamValue(context, tag, PARAM_ID); if (buff != NULL) { PA_LOCK(str, char *, buff); StrAllocCopy(id, str); PA_UNLOCK(buff); PA_FREE(buff); if (id == NULL) { top_state->out_of_memory = TRUE; XP_FREEIF(url); return; } } /* * Now look for a SRC="url" attribute for known languages. * If found, synchronously load the url. */ buff = lo_FetchParamValue(context, tag, PARAM_SRC); /* XXX overloaded rv */ if (buff != NULL) { XP_Bool allowFileSrc = FALSE; char *absUrl; PA_LOCK(str, char *, buff); PREF_GetBoolPref(lo_jsAllowFileSrcFromNonFile, &allowFileSrc); absUrl = NET_MakeAbsoluteURL(top_state->base_url, str); if (absUrl == NULL) { top_state->out_of_memory = TRUE; XP_FREEIF(id); } else if (allowFileSrc == FALSE && NET_URL_Type(absUrl) == FILE_TYPE_URL && NET_URL_Type(top_state->url) != FILE_TYPE_URL) { /* * Deny access from http: to file: via SCRIPT SRC=... * XXX silently */ top_state->in_script = SCRIPT_TYPE_UNKNOWN; XP_FREE(absUrl); XP_FREEIF(url); XP_FREEIF(id); } else if (url != NULL) { XP_FREE(absUrl); StrAllocCopy(archiveSrc, str); if (archiveSrc == NULL) { top_state->out_of_memory = TRUE; XP_FREE(url); XP_FREEIF(id); } } else { url = absUrl; } PA_UNLOCK(buff); PA_FREE(buff); if (top_state->out_of_memory) return; /* * If we are doing a <script src=""> mocha script but JS * is turned off just ignore the tag */ if (!LM_CanDoJS(context)) { top_state->in_script = SCRIPT_TYPE_UNKNOWN; XP_FREE(url); XP_FREEIF(id); XP_FREEIF(archiveSrc); return; } } } /* * Set text_divert so we know to accumulate text in line_buf * without interpretation. */ state->text_divert = tag->type; /* * XXX need to stack these to handle blocked SCRIPT tags */ top_state->script_lineno = tag->newline_count + 1; /* if we got here as a result of a LINK tag * check to make sure rel=stylesheet and then * check for an HREF and if one does not exist * fail */ if (tag->type == P_LINK) { char *cbuff = (char*)lo_FetchParamValue(context, tag, PARAM_REL); if (cbuff && !strcasecomp(cbuff, "stylesheet")) { XP_FREE(cbuff); cbuff = (char*)lo_FetchParamValue(context, tag, PARAM_HREF); if (cbuff) { if (saw_archive && url) { archiveSrc = XP_STRDUP(cbuff); } else { XP_FREEIF(url); url = NET_MakeAbsoluteURL(top_state->base_url, cbuff); } } } XP_FREEIF(cbuff); } if (url != NULL || id != NULL || codebase != NULL) { if ((doc_data != NULL) && (state->in_relayout == FALSE) && SCRIPT_EXEC_OK(top_state, state, tag->type, P_SCRIPT)) { ScriptData *data; data = XP_ALLOC(sizeof(ScriptData)); if (data == NULL) { top_state->out_of_memory = TRUE; return; } data->context = context; data->state = state; data->tag = PA_CloneMDLTag(tag); if (data->tag == NULL) { top_state->out_of_memory = TRUE; XP_FREE(data); return; } data->url = url; data->archiveSrc = archiveSrc; data->id = id; if (codebase == NULL) { StrAllocCopy(codebase, top_state->base_url); } data->codebase = codebase; data->buffer = NULL; data->bufferSize = 0; data->version = top_state->version; /* * Only SCRIPT ARCHIVE= ID= without SRC= is an inline signed * script -- if there is a SRC= attribute, archiveSrc will be * non-null. */ data->inlineSigned = (JSBool) (url != NULL && archiveSrc == NULL && id != NULL); /* Reset version accumulator */ top_state->version = JSVERSION_UNKNOWN; XP_ASSERT (tag->type == P_SCRIPT || tag->type == P_STYLE || tag->type == P_LINK); /* * Out-of-line included (by src=) or inline signed script. * Save continuatation data on top_state. If it's signed, * we'll verify the signature once we see </script> and * have the inline script to verify. */ top_state->scriptData = data; } else { XP_FREE(url); XP_FREEIF(id); XP_FREEIF(archiveSrc); } } } else { /* * We are in the </script> tag now... */ size_t line_buf_len; intn script_type; char *scope_to=NULL; char *untransformed = NULL; script_type = top_state->in_script; top_state->in_script = SCRIPT_TYPE_NOT; /* guard against superfluous end tags */ if (script_type == SCRIPT_TYPE_NOT) goto end_tag_out; /* convert from CSS to JavaScript here */ if (tag->type != P_LINK && script_type == SCRIPT_TYPE_CSS) { char *new_buffer; int32 new_buffer_length; CSS_ConvertToJS((char *)state->line_buf, state->line_buf_len, &new_buffer, &new_buffer_length); if (!new_buffer) { /* css translator error, unblock layout and return */ state->text_divert = P_UNKNOWN; state->line_buf_len = 0; /* clear script text */ goto end_tag_out; } untransformed = (char *) state->line_buf; state->line_buf = (PA_Block) new_buffer; state->line_buf_len = new_buffer_length; state->line_buf_size = new_buffer_length; if (state->line_buf_len) state->line_buf_len--; /* hack: subtract one to remove final \n */ script_type = SCRIPT_TYPE_JSSS; } if (tag->type == P_STYLE) { /* mocha scoped to document == jsss */ scope_to = "document"; } /* * Reset these before potentially recursing indirectly through * the document.write() built-in function, which writes to the * very same doc_data->parser_stream that this <SCRIPT> tag * came in on. */ state->text_divert = P_UNKNOWN; line_buf_len = state->line_buf_len; state->line_buf_len = 0; if (script_type != SCRIPT_TYPE_UNKNOWN && script_type != SCRIPT_TYPE_NOT) { /* * If mocha is disabled or can't be done in this context we * are going to just ignore the buffer contents */ if (!LM_CanDoJS(context)) { top_state->in_script = SCRIPT_TYPE_UNKNOWN; goto end_tag_out; } if ((doc_data != NULL) && (state->in_relayout == FALSE) && SCRIPT_EXEC_OK(top_state, state, tag->type, P_SCRIPT)) { /* * First off, make sure layout is blocking on us */ if (lo_create_script_blockage(context, state, tag->type == P_SCRIPT ? LO_SCRIPT : LO_UNKNOWN)) { ScriptData *data; /* * Extreme hackery. Hideous and shameful. See the comment * in lo_BlockScriptTag before similar is_end/overflow code * and commence vomiting. */ lo_BlockScriptTag(context, state, NULL); if (tag->is_end == (PRPackedBool)1) { PA_PushOverflow(doc_data); doc_data->overflow_depth ++; } /* * Set the document.write tag insertion point. */ top_state->input_write_point[top_state->input_write_level] = &top_state->tags; data = top_state->scriptData; top_state->scriptData = NULL; if (data && data->url) { /* * Three cases: * 1. SCRIPT SRC=: url non-null * 2. SCRIPT ARCHIVE= SRC=: url, archiveSrc non-null * 3. SCRIPT ARCHIVE= ID=: url, id non-null * In the last case, we copy the inline script into * data's buffer and let lo_script_archive_exit_fn do * the eval. We use an inlineSigned flag to avoid a * bunch of (url != NULL && archiveSrc == NULL && id * != NULL) tests. */ if (data->inlineSigned) { StrAllocCopy(data->buffer, (char *) state->line_buf); data->bufferSize = line_buf_len; } lo_GetScriptFromURL(data, script_type); } else { JSPrincipals *principals = NULL; ETEvalStuff * stuff; if (data) { principals = LM_NewJSPrincipals(NULL, data->id, data->codebase); if (untransformed && !LM_SetUntransformedSource(principals, untransformed, (char *) state->line_buf)) { top_state->out_of_memory = TRUE; } lo_DestroyScriptData(data); } /* * send the buffer off to be evaluated */ #ifdef DEBUG_ScriptPlugin if (script_type == SCRIPT_TYPE_PLUGIN) { XP_ASSERT(mimebuf == NULL); npl_ScriptPlugin(context, state, tag, line_buf_len,top_state->mimetype); lo_unblock_script_tag(context, TRUE); } else #endif /* DEBUG_ScriptPlugin */ stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff); if (!stuff) goto end_tag_out; stuff->len = line_buf_len; stuff->line_no = top_state->script_lineno; if (scope_to) stuff->scope_to = XP_STRDUP(scope_to); else stuff->scope_to = NULL; stuff->want_result = JS_FALSE; stuff->data = context; stuff->version = top_state->version; stuff->principals = principals; ET_EvaluateScript(context, (char *) state->line_buf, stuff, lo_ScriptEvalExitFn); } /* Reset version accumulator */ top_state->version = JSVERSION_UNKNOWN; } } } end_tag_out: /* * If we got a </SCRIPT> and still have scriptData set here, it must * be left over from an error case above, so we free it. */ if (top_state->scriptData) { XP_ASSERT(!top_state->layout_blocking_element); lo_DestroyScriptData(top_state->scriptData); top_state->scriptData = NULL; } XP_FREEIF(untransformed); } }
void npl_ScriptPlugin(MWContext *context, lo_DocState *state, PA_Tag *tag, size_t line_buf_len, char * mimebuf) { char * suffix = NULL; char * fname = NULL; char * embedtagstr = NULL; char * NET_suffix = NULL; PA_Tag * newTag = NULL; NET_StreamClass* viewstream = NULL; URL_Struct* urls = NULL; int streamStatus = 0; int id = 0; if (!context || !state || !tag || (line_buf_len <= 0) || !mimebuf){ XP_Trace("npl_ScriptPlugin: Invalid input(s)."); return; /* no need to goto clean_exit, since havn't alloc'd anything */ } urls = NET_CreateURLStruct("internal_url.", NET_DONT_RELOAD); ALLOC_CHECK(urls,id,abnormal_exit); /* NETLib gives me a pointer here instead of a copy of the string, so I have to make my own, make checks, etc. */ NET_suffix = NET_cinfo_find_ext(mimebuf); if (!NET_suffix) goto abnormal_exit; suffix = PR_smprintf("internal_url.%s", NET_suffix); ALLOC_CHECK(suffix,id,abnormal_exit); XP_FREEIF(urls->address); StrAllocCopy(urls->address , suffix); ALLOC_CHECK(urls->address,id,abnormal_exit); XP_FREEIF(urls->content_name); StrAllocCopy(urls->content_name, suffix); ALLOC_CHECK(urls->content_name,id,abnormal_exit); XP_FREEIF(urls->content_type); StrAllocCopy(urls->content_type, mimebuf); ALLOC_CHECK(urls->content_type,id,abnormal_exit); urls->must_cache = 1; /* ugly flag for mailto and saveas */ viewstream = NET_StreamBuilder(FO_CACHE_ONLY, urls, context); ALLOC_CHECK(viewstream,id,abnormal_exit); streamStatus = (*viewstream->put_block)(viewstream,(CONST char*)state->line_buf, line_buf_len); if (streamStatus <= 0) goto abnormal_exit; (*viewstream->complete)(viewstream); /* Now build internal embed tag pointing to this source: */ fname = WH_FileName(urls->cache_file, xpCache); ALLOC_CHECK(fname,id,abnormal_exit); embedtagstr = PR_smprintf("<EMBED SRC=file:///%s HIDDEN=TRUE>", fname); ALLOC_CHECK(embedtagstr,id,abnormal_exit); newTag = LO_CreateHiddenEmbedTag(tag,embedtagstr); ALLOC_CHECK(newTag,id,abnormal_exit); lo_FormatEmbed(context,state,newTag); goto normal_exit; abnormal_exit: XP_Trace("npl_ScriptPlugin: Abnormal termination, id = %d",id); if (urls) { XP_FREEIF(urls->content_type); XP_FREEIF(urls->content_name); XP_FREEIF(urls->address); XP_FREE( urls); } normal_exit: XP_FREEIF(newTag); XP_FREEIF(embedtagstr); XP_FREEIF(fname); XP_FREEIF(viewstream); XP_FREEIF(suffix); return; }
/* evaluate the buffer encompassed by the style attribute on any tag. * this will be JSS or CSS * * Returns TRUE if it needs to block layout * Returns FALSE if not. */ XP_Bool lo_ProcessStyleAttribute(MWContext *context, lo_DocState *state, PA_Tag *tag, char *script_buff) { lo_TopState *top_state; char *scope_to = NULL; int32 script_buff_len; char *new_id; XP_Bool in_double_quote=FALSE, in_single_quote=FALSE; char *ptr, *end; ETEvalStuff * stuff; if (!state) { XP_FREEIF(script_buff); return FALSE; } if (!script_buff) return FALSE; /* @@@ A bit of a hack. * Get rid of the style attribute in the tag->data so that we don't * go circular * * get rid of STYLE by rewriting it as SYTLE so that the parser * ignores it :) */ for (ptr=(char*)tag->data, end = ptr+tag->data_len; ptr < end; ptr++) { if (*ptr == '"') { in_double_quote = !in_double_quote; } else if (*ptr == '\'') { in_single_quote = !in_single_quote; } else if (!in_single_quote && !in_double_quote && !strncasecomp(ptr, PARAM_STYLE, sizeof(PARAM_STYLE)-1)) { *ptr = 'T'; /* ttyle NOT style */ break; } } script_buff_len = XP_STRLEN(script_buff); top_state = state->top_state; /* get the tag ID if it has one */ new_id = (char *)lo_FetchParamValue(context, tag, PARAM_ID); if (!new_id) new_id = PR_smprintf(NSIMPLICITID"%ld", top_state->tag_count); if (!new_id) return FALSE; if (top_state->default_style_script_type == SCRIPT_TYPE_JSSS || top_state->default_style_script_type == SCRIPT_TYPE_MOCHA) { StrAllocCopy(scope_to, "document.ids."); StrAllocCat(scope_to, new_id); if (!scope_to) { XP_FREE(new_id); return(FALSE); } } else if (top_state->default_style_script_type == SCRIPT_TYPE_CSS) { char *new_jss_buff; int32 new_jss_buff_len; char *new_css_buff; int32 new_css_buff_len; /* scope the css to the ns implicit ID */ new_css_buff = PR_smprintf("#%s { %s }", new_id, script_buff); XP_FREE(script_buff); if (!new_css_buff) { XP_FREE(new_id); return FALSE; } new_css_buff_len = XP_STRLEN(new_css_buff); /* convert to JSS */ CSS_ConvertToJS(new_css_buff, new_css_buff_len, &new_jss_buff, &new_jss_buff_len); XP_FREE(new_css_buff); if (!new_jss_buff) { XP_FREE(new_id); return FALSE; } script_buff = new_jss_buff; script_buff_len = new_jss_buff_len; } else { /* unknown script type, punt */ XP_FREE(script_buff); XP_FREE(new_id); return FALSE; } /* not needed anymore */ XP_FREE(new_id); stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff); if (!stuff) { /* what do we free here? */ XP_FREE(new_id); return FALSE; } if (lo_CloneTagAndBlockLayout(context, state, tag)) { tag->type = P_UNKNOWN; stuff->len = XP_STRLEN(script_buff); stuff->line_no = top_state->script_lineno; stuff->scope_to = scope_to; stuff->want_result = JS_FALSE; stuff->data = context; stuff->version = top_state->version; stuff->principals = NULL; ET_EvaluateScript(context, script_buff, stuff, lo_StyleEvalExitFn); /* don't free scope_to, ET_EvaluateScript has taken possession */ XP_FREE(script_buff); return TRUE; } XP_FREEIF(scope_to); XP_FREE(script_buff); return FALSE; }
_cdlm_finalize(struct cdlm* self, jint op, JMCException* *exc) { /* Override this method and add your own finalization here. */ XP_FREEIF(self); }
/* ARGSUSED */ _cdoer_finalize(struct cdoer* self, jint op, JMCException* *exc) { /* Finally, free the memory for the object containter. */ XP_FREEIF(self); }