extern XP_File VR_StubOpen (const char * mode) { char path[ CCHMAXPATH ]; int pathlen; XP_File fh = NULL; struct stat st; #ifdef XP_OS2_HACK /*DSR050197 - at this point, I need some front-end call to get the install directory of*/ /*communicator... for now I will let it default to the current directory...*/ #endif XP_STRCPY(path, "."); pathlen = strlen(path); if ( pathlen > 0 ) { XP_STRCPY( path+pathlen, "\\nsreg.dat" ); if ( stat( path, &st ) == 0 ) fh = fopen( path, XP_FILE_UPDATE_BIN ); else fh = fopen( path, XP_FILE_WRITE_BIN ); } return fh; }
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); }
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); }
/* Again like strdup but it concatinates and free's and uses Realloc */ PUBLIC char * NET_SACat (char **destination, const char *source) { if (source && *source) { if (*destination) { int length = XP_STRLEN (*destination); *destination = (char *) XP_REALLOC (*destination, length + XP_STRLEN(source) + 1); if (*destination == NULL) return(NULL); XP_STRCPY (*destination + length, source); } else { *destination = (char *) XP_ALLOC (XP_STRLEN(source) + 1); if (*destination == NULL) return(NULL); XP_STRCPY (*destination, source); } } return *destination; }
void lm_RegisterComponentProp(const char *comp, const char *targetName, uint8 retType, ETCompPropSetterFunc setter, ETCompPropGetterFunc getter) { JSContext *cx; JSObject *arrayObj, *obj; jsval val; char *type, *set, *get; if (!comp || !targetName || !(cx = lm_crippled_decoder->js_context)) return; arrayObj = lm_DefineComponents(lm_crippled_decoder); if (!arrayObj) return; if (!JS_GetProperty(cx, arrayObj, comp, &val) || !JSVAL_IS_OBJECT(val)) return; obj = JSVAL_TO_OBJECT(val); if (!JS_DefineProperty(cx, obj, targetName, JSVAL_VOID, component_mozilla_getProperty, component_mozilla_setProperty, 0)) { } type = JS_malloc(cx, XP_STRLEN(lm_typePrefix_str) + XP_STRLEN(targetName) + 1); if (type) { XP_STRCPY(type, lm_typePrefix_str); XP_STRCAT(type, targetName); if (!JS_DefineProperty(cx, obj, type, INT_TO_JSVAL((int32)retType), 0, 0, JSPROP_READONLY)) { } JS_free(cx, type); } get = JS_malloc(cx, XP_STRLEN(lm_getPrefix_str) + XP_STRLEN(targetName) + 1); if (get) { XP_STRCPY(get, lm_getPrefix_str); XP_STRCAT(get, targetName); if (!JS_DefineProperty(cx, obj, get, INT_TO_JSVAL(getter), 0, 0, JSPROP_READONLY)) { } JS_free(cx, get); } set = JS_malloc(cx, XP_STRLEN(lm_setPrefix_str) + XP_STRLEN(targetName) + 1); if (set) { XP_STRCPY(set, lm_setPrefix_str); XP_STRCAT(set, targetName); if (!JS_DefineProperty(cx, obj, set, INT_TO_JSVAL(setter), 0, 0, JSPROP_READONLY)) { } JS_free(cx, set); } }
extern void vr_findGlobalRegName () { char path[ CCHMAXPATH ]; int pathlen; XP_File fh = NULL; struct stat st; XP_STRCPY(path, "."); pathlen = strlen(path); if ( pathlen > 0 ) { XP_STRCPY( path+pathlen, WIN_REG ); globalRegName = XP_STRDUP(path); } }
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; }
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 * xp_FilePlatformName(const char * name, char* path) { if ((name == NULL) || (XP_STRLEN(name) > 1000)) return NULL; XP_STRCPY(path, name); return path; }
component_mozilla_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { char *name, *type_str, *set_str, *prop_val; jsval type, func; if (!JSVAL_IS_STRING(id)) return JS_TRUE; name = JS_GetStringBytes(JSVAL_TO_STRING(id)); type_str = JS_malloc(cx, XP_STRLEN(lm_typePrefix_str) + XP_STRLEN(name) + 1); set_str = JS_malloc(cx, XP_STRLEN(lm_setPrefix_str) + XP_STRLEN(name) + 1); if (!type_str || !set_str) return JS_TRUE; XP_STRCPY(type_str, lm_typePrefix_str); XP_STRCAT(type_str, name); XP_STRCPY(set_str, lm_setPrefix_str); XP_STRCAT(set_str, name); if (!JS_GetProperty(cx, obj, type_str, &type) || !JSVAL_IS_INT(type) || !JS_GetProperty(cx, obj, set_str, &func)) return JS_TRUE; JS_free(cx, type_str); JS_free(cx, set_str); switch(JSVAL_TO_INT(type)) { case ARGTYPE_INT32: if (JSVAL_IS_INT(*vp)) ET_moz_CompSetterFunction((ETCompPropSetterFunc)JSVAL_TO_INT(func), name, (void*)JSVAL_TO_INT(*vp)); break; case ARGTYPE_BOOL: if (JSVAL_IS_BOOLEAN(*vp)) ET_moz_CompSetterFunction((ETCompPropSetterFunc)JSVAL_TO_INT(func), name, (void*)JSVAL_TO_BOOLEAN(*vp)); break; case ARGTYPE_STRING: if (JSVAL_IS_STRING(*vp)) { prop_val = JS_GetStringBytes(JSVAL_TO_STRING(*vp)); ET_moz_CompSetterFunction((ETCompPropSetterFunc)JSVAL_TO_INT(func), name, (void*)prop_val); } break; } return JS_TRUE; }
/* * The beginning of a usemap MAP record. * Allocate the structure and initialize it. It will be filled * by later AREA tags. */ void lo_BeginMap(MWContext *context, lo_DocState *state, PA_Tag *tag) { PA_Block buff; char *str; lo_MapRec *map; map = XP_NEW(lo_MapRec); if (map == NULL) { state->top_state->out_of_memory = TRUE; return; } map->name = NULL; map->areas = NULL; map->areas_last = NULL; map->next = NULL; buff = lo_FetchParamValue(context, tag, PARAM_NAME); if (buff != NULL) { char *name; PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); } name = (char *)XP_ALLOC(XP_STRLEN(str) + 1); if (name == NULL) { map->name = NULL; } else { XP_STRCPY(name, str); map->name = name; } PA_UNLOCK(buff); PA_FREE(buff); } else { map->name = NULL; } if (map->name == NULL) { XP_DELETE(map); return; } state->top_state->current_map = map; }
component_mozilla_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { char *name, *type_str, *get_str; jsval type, func; if (!JSVAL_IS_STRING(id)) return JS_TRUE; name = JS_GetStringBytes(JSVAL_TO_STRING(id)); type_str = JS_malloc(cx, XP_STRLEN(lm_typePrefix_str) + XP_STRLEN(name) + 1); get_str = JS_malloc(cx, XP_STRLEN(lm_getPrefix_str) + XP_STRLEN(name) + 1); if (!type_str || !get_str) return JS_TRUE; XP_STRCPY(type_str, lm_typePrefix_str); XP_STRCAT(type_str, name); XP_STRCPY(get_str, lm_getPrefix_str); XP_STRCAT(get_str, name); if (!JS_GetProperty(cx, obj, type_str, &type) || !JSVAL_IS_INT(type) || !JS_GetProperty(cx, obj, get_str, &func)) return JS_TRUE; JS_free(cx, type_str); JS_free(cx, get_str); switch(JSVAL_TO_INT(type)) { case ARGTYPE_INT32: *vp = INT_TO_JSVAL((int32)ET_moz_CompGetterFunction((ETCompPropGetterFunc)JSVAL_TO_INT(func), name)); break; case ARGTYPE_BOOL: *vp = BOOLEAN_TO_JSVAL((JSBool)ET_moz_CompGetterFunction((ETCompPropGetterFunc)JSVAL_TO_INT(func), name)); break; case ARGTYPE_STRING: *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char*)ET_moz_CompGetterFunction((ETCompPropGetterFunc)JSVAL_TO_INT(func), name))); break; } return JS_TRUE; }
char * XP_PlatformFileToURL (const char *name) { char *prefix = "file://"; char *retVal = XP_ALLOC (XP_STRLEN(name) + XP_STRLEN(prefix) + 1); if (retVal) { XP_STRCPY (retVal, "file://"); XP_STRCAT (retVal, name); } return retVal; }
extern "C" void fe_showConference(Widget w, char *email, short use, char *coolAddr) { // Assume that conference is located at the same directory as netscape XP_ASSERT(w); char execu[32]; XP_STRCPY(execu, fe_conference_path); #if defined(IRIX) pid_t mypid = fork(); #else pid_t mypid = vfork(); #endif if (mypid == 0) { close (ConnectionNumber(XtDisplay(w))); /* sports * int execlp (const char *file, const char *arg0, ..., * int execvp (const char *file, char *const *argv); * const char *argn, (char *)0); */ if (email && XP_STRLEN(email)) { if (use == kDefaultDLS || !coolAddr || XP_STRLEN(coolAddr) == 0) { execlp(execu, execu, "-invite", email, 0); }/* if */ else if (use == kSpecificDLS && coolAddr && XP_STRLEN(coolAddr)) { execlp(execu, execu, "-invite", email, "-server", coolAddr, 0); }/* else */ else if (use == kHostOrIPAddress && coolAddr && XP_STRLEN(coolAddr)) { execlp(execu, execu, "-invite", email, "-direct", coolAddr, 0); }/* else */ }/* if */ else /* insufficient info to run */ execlp(execu, execu, 0); _exit(0); }/* if */ }/* fe_showConference() */
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); } }
/* * used for ARCHIVE= and SRC= * Create name of form "archive.jar/src.js" */ static char * lo_BuildJSArchiveURL( char *archive_name, char *filename ) { uint32 len = XP_STRLEN(archive_name) + XP_STRLEN(filename) + 2; char *path = XP_ALLOC(len); if (path) { XP_STRCPY(path, archive_name); XP_STRCAT(path, "/"); XP_STRCAT(path, filename); } return 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 */
char* vr_findVerRegName() { char path[ PATHLEN ]; int pathlen; if ( verRegName == NULL ) { pathlen = GetWindowsDirectory(path, PATHLEN); if ( pathlen > 0 ) { XP_STRCPY( path+pathlen, WIN_VERREG ); verRegName = XP_STRDUP(path); } } return verRegName; }
extern XP_File VR_StubOpen (const char * mode) { char path[ PATHLEN ]; int pathlen; XP_File fh = NULL; struct stat st; pathlen = GetWindowsDirectory(path, PATHLEN); if ( pathlen > 0 ) { XP_STRCPY( path+pathlen, "\\nsreg.dat" ); if ( stat( path, &st ) == 0 ) fh = fopen( path, XP_FILE_UPDATE_BIN ); else fh = fopen( path, XP_FILE_WRITE_BIN ); } return fh; }
char * hk_TagIndexToFunctionString(int32 tag_indx) { char *total_name; total_name = NULL; if (tag_indx == P_TEXT) { total_name = XP_STRDUP("TEXT_hook"); } else if (tag_indx == P_UNKNOWN) { total_name = NULL; } else if (tag_indx >= P_MAX) { total_name = NULL; } else { const char *tag_name; tag_name = PA_TagString(tag_indx); if (tag_name == NULL) { total_name = NULL; } else { int32 len; len = XP_STRLEN(tag_name) + XP_STRLEN("_hook") + 1; total_name = XP_ALLOC(len); if (total_name != NULL) { XP_STRCPY(total_name, tag_name); XP_STRCAT(total_name, "_hook"); } } } return(total_name); }
char * XFE_LdapSearchView::getColumnHeaderText(int column) { /* Server ? */ DIR_Server *pServer = getDirServer(); XP_ASSERT(pServer != NULL); /* attrib */ MSG_SearchAttribute attrib; switch (column) { case SEARCH_OUTLINER_COLUMN_NAME: attrib = attribCommonName; break; case SEARCH_OUTLINER_COLUMN_EMAIL: attrib = attrib822Address; break; case SEARCH_OUTLINER_COLUMN_COMPANY: attrib = attribOrganization; break; case SEARCH_OUTLINER_COLUMN_PHONE: attrib = attribPhoneNumber; break; case SEARCH_OUTLINER_COLUMN_LOCALITY: attrib = attribLocality; break; default: XP_ASSERT(0); return 0; }/* switch */ DIR_AttributeId id; MSG_SearchAttribToDirAttrib(attrib, &id); const char *text = DIR_GetAttributeName(pServer, id); static char header[128]; header[0] = '\0'; XP_STRCPY(header, text); return header; }
/* Very similar to strdup except it free's too */ PUBLIC char * NET_SACopy (char **destination, const char *source) { if(*destination) { XP_FREE(*destination); *destination = 0; } if (! source) { *destination = NULL; } else { *destination = (char *) XP_ALLOC (XP_STRLEN(source) + 1); if (*destination == NULL) return(NULL); XP_STRCPY (*destination, source); } return *destination; }
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*/ }
/* Generate mimetype string corresponding to this script language. Specifically, <SCRIPT language = blah> should yield a mimetype of "script/blah" */ char * npl_Script2mimeType(MWContext *context, PA_Tag *tag) { PA_Block buff; char * language; char * preface = "script/"; uint32 prefLen = XP_STRLEN(preface); char * mimebuf = NULL; uint32 len; buff = lo_FetchParamValue(context, tag, PARAM_LANGUAGE); if (buff != NULL) { PA_LOCK(language, char *, buff); len = prefLen + XP_STRLEN(language); mimebuf = XP_ALLOC(len+1); if (mimebuf) { XP_STRCPY(mimebuf, preface); XP_STRCAT(mimebuf, language); } PA_FREE(buff); } return mimebuf; }
static void lo_FormatJavaAppInternal(MWContext *context, lo_DocState *state, PA_Tag *tag, LO_JavaAppStruct *java_app) { PA_Block buff; char *str; int32 val; int32 doc_width; Bool widthSpecified = FALSE; Bool heightSpecified = FALSE; lo_DocLists *doc_lists; java_app->nextApplet = NULL; #ifdef MOCHA java_app->mocha_object = NULL; #endif java_app->FE_Data = NULL; java_app->session_data = NULL; java_app->line_height = state->line_height; java_app->base_url = NULL; java_app->attr_code = NULL; java_app->attr_codebase = NULL; java_app->attr_archive = NULL; java_app->attr_name = NULL; java_app->param_cnt = 0; java_app->param_names = NULL; java_app->param_values = NULL; java_app->may_script = FALSE; java_app->alignment = LO_ALIGN_BASELINE; java_app->border_width = JAVA_DEF_BORDER; java_app->border_vert_space = JAVA_DEF_VERTICAL_SPACE; java_app->border_horiz_space = JAVA_DEF_HORIZONTAL_SPACE; java_app->layer = NULL; java_app->tag = tag; /* * Assign a unique index for this object * and increment the master index. */ java_app->embed_index = state->top_state->embed_count++; /* * Save away the base of the document */ buff = PA_ALLOC(XP_STRLEN(state->top_state->base_url) + 1); if (buff != NULL) { char *cp; PA_LOCK(cp, char*, buff); XP_STRCPY(cp, state->top_state->base_url); PA_UNLOCK(buff); java_app->base_url = buff; } else { state->top_state->out_of_memory = TRUE; return; } /* * Check for an align parameter */ buff = lo_FetchParamValue(context, tag, PARAM_ALIGN); if (buff != NULL) { Bool floating; floating = FALSE; PA_LOCK(str, char *, buff); java_app->alignment = lo_EvalAlignParam(str, &floating); if (floating != FALSE) { java_app->ele_attrmask |= LO_ELE_FLOATING; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Get the applet CODE or object CLASSID parameter. In both * cases the value is place in java_app->attr_code */ if (java_app->selector_type == LO_JAVA_SELECTOR_APPLET) { /* APPLET tag CODE attribute */ buff = lo_FetchParamValue(context, tag, PARAM_CODE); } else { /* OBJECT tag CLASSID attribute */ char * str1, * str2; PA_Block new_buff; int selectorLength; selectorLength = 5; if (java_app->selector_type == LO_JAVA_SELECTOR_OBJECT_JAVAPROGRAM) selectorLength = 12; else if (java_app->selector_type == LO_JAVA_SELECTOR_OBJECT_JAVABEAN) selectorLength = 9; buff = lo_FetchParamValue(context, tag, PARAM_CLASSID); if (buff != NULL) { /* remove the "java:", "javaprogram:", or "javabean:" * protocol selector. */ PA_LOCK(str1, char *, buff); new_buff = PA_ALLOC(XP_STRLEN(str1) + 1); PA_LOCK(str2, char *, new_buff); XP_STRCPY(str2, str1 + selectorLength); PA_UNLOCK(new_buff); PA_UNLOCK(buff); PA_FREE(buff); buff = new_buff; } } java_app->attr_code = buff; /* * Check for the loaderbase parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_CODEBASE); java_app->attr_codebase = buff; /* * Check for the archive parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_ARCHIVE); java_app->attr_archive = buff; /* * Check for a mayscript attribute */ buff = lo_FetchParamValue(context, tag, PARAM_MAYSCRIPT); if (buff != NULL) { java_app->may_script = TRUE; PA_FREE(buff); } /* * Get the name of this java applet. */ if (java_app->selector_type != LO_JAVA_SELECTOR_APPLET) buff = lo_FetchParamValue(context, tag, PARAM_ID); else buff = lo_FetchParamValue(context, tag, PARAM_NAME); if (buff != NULL) { PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); } PA_UNLOCK(buff); } java_app->attr_name = buff; doc_width = state->right_margin - state->left_margin; /* * Get the width parameter, in absolute or percentage. * If percentage, make it absolute. */ buff = lo_FetchParamValue(context, tag, PARAM_WIDTH); if (buff != NULL) { Bool is_percent; PA_LOCK(str, char *, buff); val = lo_ValueOrPercent(str, &is_percent); if (is_percent != FALSE) { java_app->percent_width = val; } else { java_app->percent_width = 0; java_app->width = val; val = FEUNITS_X(val, context); } PA_UNLOCK(buff); PA_FREE(buff); widthSpecified = TRUE; } val = LO_GetWidthFromStyleSheet(context, state); if(val) { java_app->width = val; widthSpecified = TRUE; } /* * Get the height parameter, in absolute or percentage. * If percentage, make it absolute. */ buff = lo_FetchParamValue(context, tag, PARAM_HEIGHT); if (buff != NULL) { Bool is_percent; PA_LOCK(str, char *, buff); val = lo_ValueOrPercent(str, &is_percent); if (is_percent != FALSE) { java_app->percent_height = val; } else { java_app->percent_height = 0; val = FEUNITS_Y(val, context); } java_app->height = val; PA_UNLOCK(buff); PA_FREE(buff); heightSpecified = TRUE; } val = LO_GetHeightFromStyleSheet(context, state); if(val) { java_app->height = val; heightSpecified = TRUE; } /* If they forgot to specify a width, make one up. */ if (!widthSpecified) { val = 0; if (heightSpecified) { val = java_app->height; } else if (state->allow_percent_width) { val = state->win_width * 90 / 100; } if (val < 1) { val = 600; } java_app->width = val; } /* If they forgot to specify a height, make one up. */ if (!heightSpecified) { val = 0; if (widthSpecified) { val = java_app->width; } else if (state->allow_percent_height) { val = state->win_height / 2; } if (val < 1) { val = 400; } java_app->height = val; } /* After going through all the trouble, just to make sure * the object tag HIDDEN case is covered as well. */ if (java_app->ele_attrmask & LO_ELE_HIDDEN) { java_app->width = 0; java_app->height = 0; } /* * Get the border parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_BORDER); if (buff != NULL) { PA_LOCK(str, char *, buff); val = XP_ATOI(str); if (val < 0) { val = 0; } java_app->border_width = val; PA_UNLOCK(buff); PA_FREE(buff); } java_app->border_width = FEUNITS_X(java_app->border_width, context); /* * Get the extra vertical space parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_VSPACE); if (buff != NULL) { PA_LOCK(str, char *, buff); val = XP_ATOI(str); if (val < 0) { val = 0; } java_app->border_vert_space = val; PA_UNLOCK(buff); PA_FREE(buff); } java_app->border_vert_space = FEUNITS_Y(java_app->border_vert_space, context); /* * Get the extra horizontal space parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_HSPACE); if (buff != NULL) { PA_LOCK(str, char *, buff); val = XP_ATOI(str); if (val < 0) { val = 0; } java_app->border_horiz_space = val; PA_UNLOCK(buff); PA_FREE(buff); } java_app->border_horiz_space = FEUNITS_X(java_app->border_horiz_space, context); lo_FillInJavaAppGeometry(state, java_app, FALSE); /* * See if we have some saved embed/java_app session data to restore. */ if (state->top_state->savedData.EmbedList != NULL) { lo_SavedEmbedListData *embed_list; embed_list = state->top_state->savedData.EmbedList; /* * If there is still valid data to restore available. */ if (java_app->embed_index < embed_list->embed_count) { lo_EmbedDataElement* embed_data_list; PA_LOCK(embed_data_list, lo_EmbedDataElement*, embed_list->embed_data_list); java_app->session_data = embed_data_list[java_app->embed_index].data; PA_UNLOCK(embed_list->embed_data_list); }
/* * Takes a "PARAM" tag and pointers to the object's attribute * count, attribute name array, and attribute value array. * Parses the name and value of the PARAM and adjusts the * attribute count, names, and values accordingly. */ void lo_ObjectParam(MWContext* context, lo_DocState* state, PA_Tag* tag, uint32* count, char*** names, char*** values) { PA_Block buff; char *str; char *param_name = NULL; char *param_value = NULL; char **name_list; char **value_list; /* * Get the name of this parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_NAME); if (buff != NULL) { PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; char *new_str; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); new_str = (char *)XP_ALLOC(len + 1); if (new_str != NULL) { XP_STRCPY(new_str, str); } param_name = new_str; } PA_UNLOCK(buff); PA_FREE(buff); } else { /* If we don't have a parameter name, it's useless */ return; } /* * Get the value of this parameter. */ buff = lo_FetchParamValue(context, tag, PARAM_VALUE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; char *new_str; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); new_str = (char *)XP_ALLOC(len + 1); if (new_str != NULL) { XP_STRCPY(new_str, str); } param_value = new_str; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Add the parameter to the name/value list. */ if (*names == NULL) name_list = (char **)XP_ALLOC(sizeof(char *)); else name_list = (char **)XP_REALLOC(*names, ((*count + 1) * sizeof(char *))); /* * If we run out of memory here, free up what * we can and return. */ if (name_list == NULL) { state->top_state->out_of_memory = TRUE; XP_FREE(param_name); if (param_value != NULL) XP_FREE(param_value); return; } if (*values == NULL) value_list = (char **)XP_ALLOC(sizeof(char *)); else value_list = (char **)XP_REALLOC(*values, ((*count + 1) * sizeof(char *))); /* * If we run out of memory here, free up what * we can and return. */ if (value_list == NULL) { state->top_state->out_of_memory = TRUE; XP_FREE(param_name); if (param_value != NULL) XP_FREE(param_value); return; } *names = name_list; *values = value_list; (*names)[*count] = param_name; (*values)[*count] = param_value; (*count)++; }
PA_Block lo_ValueToRoman(int32 value, Bool large, intn *len_ptr) { int i, j; int indx[4]; char str[4][6]; char *fives; char *ones; char str2[22]; char *ptr; PA_Block buff; char *bptr; *len_ptr = 0; if (large != FALSE) { fives = Fives[1]; ones = Ones[1]; } else { fives = Fives[0]; ones = Ones[0]; } if (value >= 4000) { value = value % 3999; value++; } for (i=0; i<4; i++) { indx[i] = (int) value % 10; value = value / 10; } for (i=0; i<4; i++) { if (indx[i] >= 5) { indx[i] -= 5; str[i][0] = fives[i]; } else { str[i][0] = ' '; } if (indx[i] == 4) { if (str[i][0] == ' ') { str[i][1] = fives[i]; } else { str[i][1] = ones[i + 1]; } str[i][0] = ones[i]; str[i][2] = '\0'; } else { for (j=0; j<indx[i]; j++) { str[i][j + 1] = ones[i]; } str[i][indx[i] + 1] = '\0'; } } XP_STRCPY(str2, ""); for (i=3; i>=0; i--) { ptr = str[i]; if (*ptr == ' ') { ptr++; } XP_STRCAT(str2, ptr); } XP_STRCAT(str2, "."); *len_ptr = XP_STRLEN(str2); buff = PA_ALLOC(*len_ptr + 1); if (buff != NULL) { PA_LOCK(bptr, char *, buff); XP_STRCPY(bptr, str2); PA_UNLOCK(buff); } return(buff); }
/* * This is an AREA tag. Create the structure, fill it in based on the * attributes passed, and add it to the map record for the current * MAP tag. */ void lo_BeginMapArea(MWContext *context, lo_DocState *state, PA_Tag *tag) { PA_Block buff; char *str; lo_MapRec *map; lo_MapAreaRec *area; lo_DocLists *doc_lists; doc_lists = lo_GetCurrentDocLists(state); /* * Get the current map, if there is none, error out. */ map = state->top_state->current_map; if (map == NULL) { return; } area = XP_NEW(lo_MapAreaRec); if (area == NULL) { state->top_state->out_of_memory = TRUE; return; } area->type = AREA_SHAPE_RECT; area->coords = NULL; area->coord_cnt = 0; area->anchor = NULL; area->alt = NULL; area->alt_len = 0; area->next = NULL; buff = lo_FetchParamValue(context, tag, PARAM_SHAPE); if (buff != NULL) { PA_LOCK(str, char *, buff); if (pa_TagEqual(S_AREA_SHAPE_RECT, str)) { area->type = AREA_SHAPE_RECT; } else if (pa_TagEqual(S_AREA_SHAPE_CIRCLE, str)) { area->type = AREA_SHAPE_CIRCLE; } else if (pa_TagEqual(S_AREA_SHAPE_POLY, str)) { area->type = AREA_SHAPE_POLY; } else if (pa_TagEqual(S_AREA_SHAPE_POLYGON, str)) { area->type = AREA_SHAPE_POLY; } else if (pa_TagEqual(S_AREA_SHAPE_DEFAULT, str)) { area->type = AREA_SHAPE_DEFAULT; } else { area->type = AREA_SHAPE_UNKNOWN; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Get the alt parameter, and store the resulting * text, and its length. */ buff = lo_FetchParamValue(context, tag, PARAM_ALT); if (buff != NULL) { PA_LOCK(str, char *, buff); area->alt_len = XP_STRLEN(str); area->alt_len = (int16)lo_StripTextNewlines(str, (int32)area->alt_len); PA_UNLOCK(buff); } area->alt = buff; /* * Parse the comma separated coordinate list into an * array of integers. */ buff = lo_FetchParamValue(context, tag, PARAM_COORDS); if (buff != NULL) { int32 cnt; Bool must_be_odd; must_be_odd = FALSE; if (area->type == AREA_SHAPE_POLY) { must_be_odd = TRUE; } PA_LOCK(str, char *, buff); area->coords = lo_parse_coord_list(str, &cnt, must_be_odd); if (area->coords != NULL) { area->coord_cnt = cnt; } PA_UNLOCK(buff); PA_FREE(buff); } /* * Get the HREF, and if one exists, get the TARGET to go along * with it. */ buff = lo_FetchParamValue(context, tag, PARAM_HREF); if (buff != NULL) { char *target; PA_Block targ_buff; PA_Block href_buff; LO_AnchorData *anchor; anchor = NULL; PA_LOCK(str, char *, buff); if (str != NULL) { int32 len; len = lo_StripTextWhitespace(str, XP_STRLEN(str)); } str = NET_MakeAbsoluteURL(state->top_state->base_url, str); if (str == NULL) { href_buff = NULL; } else { href_buff = PA_ALLOC(XP_STRLEN(str) + 1); if (href_buff != NULL) { char *full_url; PA_LOCK(full_url, char *, href_buff); XP_STRCPY(full_url, str); PA_UNLOCK(href_buff); } else { state->top_state->out_of_memory = TRUE; } XP_FREE(str); } PA_UNLOCK(buff); PA_FREE(buff); if (href_buff != NULL) { targ_buff = lo_FetchParamValue(context, tag, PARAM_TARGET); if (targ_buff != NULL) { int32 len; PA_LOCK(target, char *, targ_buff); len = lo_StripTextWhitespace(target, XP_STRLEN(target)); if ((*target == '\0')|| (lo_IsValidTarget(target) == FALSE)) { PA_UNLOCK(targ_buff); PA_FREE(targ_buff); targ_buff = NULL; } else { PA_UNLOCK(targ_buff); } } /* * If there was no target use the default one. * (default provided by BASE tag) */ if ((targ_buff == NULL)&& (state->top_state->base_target != NULL)) { targ_buff = PA_ALLOC(XP_STRLEN( state->top_state->base_target) + 1); if (targ_buff != NULL) { char *targ; PA_LOCK(targ, char *, targ_buff); XP_STRCPY(targ, state->top_state->base_target); PA_UNLOCK(targ_buff); } else { state->top_state->out_of_memory = TRUE; } } anchor = lo_NewAnchor(state, href_buff, targ_buff); if (anchor == NULL) { PA_FREE(href_buff); if (targ_buff != NULL) { PA_FREE(targ_buff); } } /* * If the AREA tag has an ALT attribute, * stick that text into the anchor data. */ else if (area->alt != NULL) { PA_Block alt_buff; char *alt_text; PA_LOCK(alt_text, char *, area->alt); alt_buff = PA_ALLOC(area->alt_len + 1); if (alt_buff != NULL) { char *new_alt; PA_LOCK(new_alt, char *, alt_buff); XP_STRCPY(new_alt, alt_text); PA_UNLOCK(alt_buff); } PA_UNLOCK(area->alt); anchor->alt = alt_buff; }
PA_Block lo_ValueToAlpha(int32 value, Bool large, intn *len_ptr) { int i; char str[20]; char str2[22]; intn pos, cnt; PA_Block buff; char *bptr; char base; *len_ptr = 0; if (large != FALSE) { base = 'A'; } else { base = 'a'; } for (i=0; i<20; i++) { str[i] = (char)0; } while (value > 26) { pos = 1; str[pos] = (char)((int)str[pos] + 1); cnt = (int)str[pos]; while ((cnt > 26)&&(pos < 19)) { str[pos] = (char)0; pos++; str[pos] = (char)((int)str[pos] + 1); cnt = (int)str[pos]; } if ((pos == 20)&&(cnt > 26)) { str[pos] = (char)0; } value -= 26; } str[0] = (char)value; pos = 0; while ((int)str[pos] != 0) { pos++; } if (pos == 0) { XP_STRCPY(str2, " ."); } else { cnt = 0; for (i=pos; i>0; i--) { str2[cnt] = (char)(base + (int)str[i - 1] - 1); cnt++; } str2[cnt] = '.'; str2[cnt + 1] = '\0'; } *len_ptr = XP_STRLEN(str2); buff = PA_ALLOC(*len_ptr + 1); if (buff != NULL) { PA_LOCK(bptr, char *, buff); XP_STRCPY(bptr, str2); PA_UNLOCK(buff); } return(buff); }