/* Copyright 1997 Acorn Computers Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /***************************************************/ /* File : PlugIn.c */ /* */ /* Purpose: Supporting the generic RISC OS browser */ /* Plug-In interface. */ /* */ /* Author : A.D.Hodgkinson */ /* */ /* History: 05-Oct-97: Created. */ /***************************************************/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include "swis.h" #include "flex.h" #include "HTMLLib.h" /* HTML library API, Which will include html2_ext.h, tags.h and struct.h */ #include "wimp.h" #include "wimplib.h" #include "event.h" #include "toolbox.h" #include "svcprint.h" #include "Global.h" #include "FromROSLib.h" #include "Utils.h" #include "Fetch.h" /* (Which itself includes URLstat.h) */ #include "FetchHTML.h" #include "Handlers.h" #include "Images.h" #include "MiscDefs.h" #include "Object.h" #include "Redraw.h" #include "Reformat.h" #include "TokenUtils.h" #include "URLveneer.h" #include "PlugIn.h" /*************************************************/ /* plugin_return_string() */ /* */ /* Takes a message block and string_value from */ /* within it, and returns the string it points */ /* to. */ /* */ /* Parameters: Pointer to a WimpMessage struct */ /* holding the string_value field; */ /* */ /* Pointer to the string_value field */ /* inside that message. */ /* */ /* Returns: Pointer to the string the */ /* string_value references, or NULL */ /* if the value seems invalid. */ /*************************************************/ const char * plugin_return_string(WimpMessage * m, string_value * sv) { int offset = ((char *) sv) - ((char *) m); if (!m || !sv || !sv->offset) return NULL; /* Is the offset of the string_value field within the message */ /* block out of range (i.e. the string_value does not appear */ /* to lie in the given message block)? */ if (offset >= m->hdr.size || offset < sizeof(m->hdr)) return NULL; /* Now read the string_value field itself */ if (sv->offset < 256) { if (sizeof(m->hdr) + offset >= m->hdr.size) return NULL; else return (const char *) (((char *) m) + sizeof(m->hdr) + sv->offset); } else return (const char *) sv->offset; }