Home | History | Annotate | Download | only in include
      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* ***** BEGIN LICENSE BLOCK *****
      3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
      4  *
      5  * The contents of this file are subject to the Mozilla Public License Version
      6  * 1.1 (the "License"); you may not use this file except in compliance with
      7  * the License. You may obtain a copy of the License at
      8  * http://www.mozilla.org/MPL/
      9  *
     10  * Software distributed under the License is distributed on an "AS IS" basis,
     11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
     12  * for the specific language governing rights and limitations under the
     13  * License.
     14  *
     15  * The Original Code is mozilla.org code.
     16  *
     17  * The Initial Developer of the Original Code is
     18  * Netscape Communications Corporation.
     19  * Portions created by the Initial Developer are Copyright (C) 1998
     20  * the Initial Developer. All Rights Reserved.
     21  *
     22  * Contributor(s):
     23  *
     24  * Alternatively, the contents of this file may be used under the terms of
     25  * either the GNU General Public License Version 2 or later (the "GPL"), or
     26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
     27  * in which case the provisions of the GPL or the LGPL are applicable instead
     28  * of those above. If you wish to allow use of your version of this file only
     29  * under the terms of either the GPL or the LGPL, and not to allow others to
     30  * use your version of this file under the terms of the MPL, indicate your
     31  * decision by deleting the provisions above and replace them with the notice
     32  * and other provisions required by the GPL or the LGPL. If you do not delete
     33  * the provisions above, a recipient may use your version of this file under
     34  * the terms of any one of the MPL, the GPL or the LGPL.
     35  *
     36  * ***** END LICENSE BLOCK ***** */
     37 
     38 #ifndef __FORMAT_H__
     39 #define __FORMAT_H__
     40 
     41 #include <string>
     42 #include "npapi.h"
     43 
     44 typedef enum
     45 {
     46   action_invalid = 0,
     47   action_npn_version,
     48   action_npn_get_url_notify,
     49   action_npn_get_url,
     50   action_npn_post_url_notify,
     51   action_npn_post_url,
     52   action_npn_request_read,
     53   action_npn_new_stream,
     54   action_npn_write,
     55   action_npn_destroy_stream,
     56   action_npn_status,
     57   action_npn_user_agent,
     58   action_npn_mem_alloc,
     59   action_npn_mem_free,
     60   action_npn_mem_flush,
     61   action_npn_reload_plugins,
     62   action_npn_get_java_env,
     63   action_npn_get_java_peer,
     64   action_npn_get_value,
     65   action_npn_set_value,
     66   action_npn_invalidate_rect,
     67   action_npn_invalidate_region,
     68   action_npn_force_redraw,
     69   action_npn_enumerate,
     70   action_npn_pop_popups_enabled_state,
     71   action_npn_push_popups_enabled_state,
     72   action_npn_set_exception,
     73   action_npn_release_variant_value,
     74   action_npn_has_method,
     75   action_npn_has_property,
     76   action_npn_remove_property,
     77   action_npn_set_property,
     78   action_npn_get_property,
     79   action_npn_evaluate,
     80   action_npn_invoke_default,
     81   action_npn_invoke,
     82   action_npn_release_object,
     83   action_npn_retain_object,
     84   action_npn_create_object,
     85   action_npn_int_from_identifier,
     86   action_npn_utf8_from_identifier,
     87   action_npn_identifier_is_string,
     88   action_npn_get_int_identifer,
     89   action_npn_get_string_identifier,
     90   action_npn_get_string_identifiers,
     91 
     92   action_npp_new,
     93   action_npp_destroy,
     94   action_npp_set_window,
     95   action_npp_new_stream,
     96   action_npp_destroy_stream,
     97   action_npp_stream_as_file,
     98   action_npp_write_ready,
     99   action_npp_write,
    100   action_npp_print,
    101   action_npp_handle_event,
    102   action_npp_url_notify,
    103   action_npp_get_java_class,
    104   action_npp_get_value,
    105   action_npp_set_value
    106 } NPAPI_Action;
    107 
    108 struct LogArgumentStruct
    109 {
    110   DWORD dwArg;
    111   int iLength;
    112   void * pData;
    113 
    114   LogArgumentStruct()
    115   {
    116     iLength = 0;
    117     pData = NULL;
    118   }
    119 
    120   ~LogArgumentStruct()
    121   {
    122     if(pData != NULL)
    123       delete [] pData;
    124     iLength = 0;
    125   }
    126 };
    127 
    128 struct LogItemStruct
    129 {
    130   NPAPI_Action action;
    131   LogArgumentStruct arg1;
    132   LogArgumentStruct arg2;
    133   LogArgumentStruct arg3;
    134   LogArgumentStruct arg4;
    135   LogArgumentStruct arg5;
    136   LogArgumentStruct arg6;
    137   LogArgumentStruct arg7;
    138 
    139   LogItemStruct(){}
    140   ~LogItemStruct(){}
    141 };
    142 
    143 char * FormatNPAPIError(int iError);
    144 char * FormatNPAPIReason(int iReason);
    145 char * FormatNPPVariable(NPPVariable var);
    146 char * FormatNPNVariable(NPNVariable var);
    147 BOOL FormatPCHARArgument(char * szBuf, int iLength, LogArgumentStruct * parg);
    148 BOOL FormatBOOLArgument(char * szBuf, int iLength, LogArgumentStruct * parg);
    149 BOOL FormatPBOOLArgument(char * szBuf, int iLength, LogArgumentStruct * parg);
    150 LogItemStruct * makeLogItemStruct(NPAPI_Action action,
    151                                   DWORD dw1, DWORD dw2, DWORD dw3, DWORD dw4,
    152                                   DWORD dw5, DWORD dw6, DWORD dw7, BOOL bShort = FALSE);
    153 void freeLogItemStruct(LogItemStruct * lis);
    154 void formatLogItem(LogItemStruct * plis, std::string * szOutput, BOOL bDOSStyle = FALSE);
    155 
    156 #endif // __LOGHLP_H__
    157