"Fossies" - the Fresh Open Source Software Archive

Member "mozplugger-2.1.6/npapi/npp_funcs.c" (17 Apr 2014, 4218 Bytes) of package /linux/www/old/mozplugger-2.1.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
    2  *
    3  * ***** BEGIN LICENSE BLOCK *****
    4  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
    5  *
    6  * The contents of this file are subject to the Mozilla Public License Version
    7  * 1.1 (the "License"); you may not use this file except in compliance with
    8  * the License. You may obtain a copy of the License at
    9  * http://www.mozilla.org/MPL/
   10  *
   11  * Software distributed under the License is distributed on an "AS IS" basis,
   12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   13  * for the specific language governing rights and limitations under the
   14  * License.
   15  *
   16  * The Original Code is mozilla.org code.
   17  *
   18  * The Initial Developer of the Original Code is
   19  * Netscape Communications Corporation.
   20  * Portions created by the Initial Developer are Copyright (C) 1998
   21  * the Initial Developer. All Rights Reserved.
   22  *
   23  * Contributor(s):
   24  *   Stephen Mak <smak@sun.com>
   25  *
   26  * Alternatively, the contents of this file may be used under the terms of
   27  * either of the GNU General Public License Version 2 or later (the "GPL"),
   28  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   29  * in which case the provisions of the GPL or the LGPL are applicable instead
   30  * of those above. If you wish to allow use of your version of this file only
   31  * under the terms of either the GPL or the LGPL, and not to allow others to
   32  * use your version of this file under the terms of the MPL, indicate your
   33  * decision by deleting the provisions above and replace them with the notice
   34  * and other provisions required by the GPL or the LGPL. If you do not delete
   35  * the provisions above, a recipient may use your version of this file under
   36  * the terms of any one of the MPL, the GPL or the LGPL.
   37  *
   38  * ***** END LICENSE BLOCK ***** */
   39 
   40 #include <stdio.h>
   41 #include <string.h>
   42 
   43 #include "npapi.h"
   44 #include "npruntime.h"
   45 #include "npp_func_tab.h"
   46 #include "npp_funcs.h"
   47 
   48 /***********************************************************************
   49  *
   50  * Wrapper functions : plugin calling Netscape Navigator
   51  *
   52  * These functions let the plugin developer just call the APIs
   53  * as documented and defined in npapi.h, without needing to know
   54  * about the function table and call macros in npupp.h.
   55  *
   56  ***********************************************************************/
   57 
   58 void NPP_Version(int * plugin_major, int * plugin_minor)
   59 {
   60     *plugin_major = NP_VERSION_MAJOR;
   61     *plugin_minor = NP_VERSION_MINOR;
   62 }
   63 
   64 
   65 NPError NPP_InitFuncTable(NPPluginFuncs * pluginFuncs)
   66 {
   67     NPError err = NPERR_NO_ERROR;
   68 
   69     if (pluginFuncs != NULL)
   70     {
   71         /* Create a temporary local copy */
   72         NPPluginFuncs funcs;
   73 
   74         /* Zero to start */
   75         memset(&funcs, 0, sizeof(NPPluginFuncs));
   76 
   77         /* First create a local copy of the table */
   78         funcs.version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
   79         funcs.newp = NPP_New;
   80         funcs.destroy = NPP_Destroy;
   81         funcs.setwindow = NPP_SetWindow;
   82         funcs.newstream = NPP_NewStream;
   83         funcs.destroystream = NPP_DestroyStream;
   84         funcs.asfile = NPP_StreamAsFile;
   85         funcs.writeready = NPP_WriteReady;
   86         funcs.write = NPP_Write;
   87         funcs.print = NPP_Print;
   88         funcs.event = NPP_HandleEvent;
   89         funcs.urlnotify = NPP_URLNotify;
   90         funcs.getvalue = (NPP_GetValueProcPtr) NPP_GetValue;
   91         funcs.setvalue = NPP_SetValue;
   92         funcs.gotfocus = NPP_GotFocus;
   93         funcs.lostfocus = NPP_LostFocus;
   94         funcs.urlredirectnotify = NPP_URLRedirectNotify;
   95         funcs.clearsitedata = NPP_ClearSiteData;
   96         funcs.getsiteswithdata = NPP_GetSitesWithData;
   97 
   98         if(pluginFuncs->size > sizeof(NPPluginFuncs))
   99         {
  100             /* Zero the fields we dont have anything for */
  101             memset(&pluginFuncs[sizeof(NPPluginFuncs)], 0,
  102                                      pluginFuncs->size - sizeof(NPPluginFuncs));
  103             funcs.size = sizeof(NPPluginFuncs);
  104         }
  105         else
  106         {
  107             funcs.size = pluginFuncs->size;
  108         }
  109 
  110         /* Copy across */
  111         memcpy(pluginFuncs, &funcs, funcs.size);
  112     }
  113     else
  114     {
  115         err = NPERR_INVALID_FUNCTABLE_ERROR;
  116     }
  117     return err;
  118 }