⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmtcmn.h

📁 安全开发库。含客户端建立ssl连接、签名、证书验证、证书发布和撤销等。编译用到nss
💻 H
📖 第 1 页 / 共 5 页
字号:
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- *//*  * The contents of this file are subject to the Mozilla Public * License Version 1.1 (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.mozilla.org/MPL/ *  * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. *  * The Original Code is the Netscape security libraries. *  * The Initial Developer of the Original Code is Netscape * Communications Corporation.  Portions created by Netscape are  * Copyright (C) 1994-2000 Netscape Communications Corporation.  All * Rights Reserved. *  * Contributor(s): *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable  * instead of those above.  If you wish to allow use of your  * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL.  If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. */#ifndef __CMTCMN_H__#define __CMTCMN_H__/*** Macro shorthands for conditional C++ extern block delimiters.*/#ifdef __cplusplus#define CMT_BEGIN_EXTERN_C     extern "C" {#define CMT_END_EXTERN_C       }#else#define CMT_BEGIN_EXTERN_C#define CMT_END_EXTERN_C#endif#include <stdio.h>#include "ssmdefs.h"#ifdef WIN32#include <windows.h>#include <winsock.h>#else#ifndef macintosh#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#endif#endif#include "cmtclist.h"#include "obscure.h"typedef void (*void_fun) (void);typedef void (* CMTP7ContentCallback)(void *arg, const char *buf,				      unsigned long len);typedef struct _CMTPrivate CMTPrivate;typedef void (*CMTReclaimFunc)(CMTPrivate *priv);struct _CMTPrivate {    CMTReclaimFunc dest;    /* void (* dest)(CMTPrivate *priv); */};/* * The version supported by the protocol library. * Pass this version to CMT_Hello. */#define PROTOCOL_VERSION SSM_PROTOCOL_VERSION/* * Socket Abstraction layer. */typedef void* CMTSocket;/* * This function should return a handle to an internet-streaming TCP socket. * For UNIX, need a UNIX socket for hello message. * * If parameter is 1, then we want UNIX socket.  Otherwise INET socket. */typedef CMTSocket (*CMT_GET_SOCKET)(int);/* * All connections will be on the same machine.  Below is the port number * to connect to. * If using a UNIX domain socket, then use path as the path to connect to. */typedef CMTStatus (*CMT_CONNECT)(CMTSocket sock, short port, char* path);/* * Will call this function to verify that UNIX domain sockets are * held by correct user.  If the socket is not, then the socket is * closed. */typedef CMTStatus (*CMT_VERIFY_UNIX)(CMTSocket sock);/* * Use this function to send data across the socket */typedef size_t (*CMT_SEND)(CMTSocket sock, void* buffer, size_t length);/* * Use this function to select a socket. If poll is non-zero, then  * just poll the socket to see if there is any data waiting to be read. * Otherwise block until there is data waiting to be read.  Select any * of the sockets in the array and return the selected socket. */typedef CMTSocket (*CMT_SELECT)(CMTSocket *sock, int numSocks, int poll);/* * Use this function to receive data from a socket.  Function should * return number of bytes actually read. Return -1 in case of error. */typedef size_t (*CMT_RECEIVE)(CMTSocket sock, void *buffer, size_t bufSize);/* * Use this function to shutdown writing to the socket. */typedef CMTStatus (*CMT_SHUTDOWN)(CMTSocket sock);/* * Prototype for function to close down the socket permanently. */typedef CMTStatus (*CMT_CLOSE)(CMTSocket sock);/* * This structure should be passed at initialization time. */typedef struct CMT_SocketFuncsStr {    CMT_GET_SOCKET  socket;    CMT_CONNECT     connect;    CMT_VERIFY_UNIX verify;        CMT_SEND        send;    CMT_SELECT      select;    CMT_RECEIVE     recv;    CMT_SHUTDOWN    shutdown;    CMT_CLOSE       close;} CMT_SocketFuncs;/*  mutex abstraction */typedef void * CMTMutexPointer;typedef void (*CMTMutexFunction)(CMTMutexPointer);typedef struct _CMT_MUTEX {    CMTMutexPointer mutex;    CMTMutexFunction lock;    CMTMutexFunction unlock;} CMT_MUTEX;#define CMT_LOCK(_m)     if (_m) _m->lock(_m->mutex)#define CMT_UNLOCK(_m)   if (_m) _m->unlock(_m->mutex)/*  session info */typedef struct _CMT_DATA {	CMTSocket sock;	CMUint32 connectionID;	CMTPrivate *priv;	struct _CMT_DATA * next;	struct _CMT_DATA * previous;} CMT_DATA, *PCMT_DATA;/*  event info */typedef struct _CMT_EVENT {    CMUint32 type;    CMUint32 resourceID;    void_fun handler;    void *data;    struct _CMT_EVENT * next;    struct _CMT_EVENT * previous;} CMT_EVENT, *PCMT_EVENT;/* * Type defines for callbacks that are set in the CMT library. *//* * FUNCTION TYPE: promptCallback_fn * ----------------------------------- * INPUTS *    arg *        This is an opaque pointer that is provided to the library *        when the callback is registered.  The library merely passes *        it to the callback so the application can properly handle *        the password prompt. *    clientContext *        This is the client context pointer that is set the client. *    prompt *        The text to display to the user when prompting for a password. *    isPasswd *        If this value is non-zero, then this is prompt is for a password *        request and the text typed in by the user should not be echoed *        to the screen.  Meaning the text should be masked as asterisks *        or nothing should be displayed on the screen as the user types *        input.  If the value is zero, then the function should echo *        the user's input to the screen. * * NOTES: * This defines the type of function used for prompting the user for a * typed input.  The application is free to use that arg parameter as  * it sees fit.  The apllication provides the parameter when registering * the callback so the application will know what type of data the pointer * represents.  The application should display the text passed via the * prompt parameter. Then read the input typed by the user and return that  * value.  If isPasswd is non-zero, then the function should not echo * the user's input. * * RETURN: * This function should return the user's input or NULL if the user canceled * the operation or some other error occurred. */typedef char * (*promptCallback_fn)(void *arg, char *prompt,                                     void* clientContext, int isPasswd);/* * FUNCTION TYPE: applicationFreeCallback_fn * ------------------------------------ * INPUTS *    userInput *        A string returned by callback of the type promptCallback_fn that *        the application has implemented. * NOTES: * This function is used to free the string returned by the callback of * type promptCallback_fn or filePathPromptCallback_fn.   * After calling the apllication provided function of type promptCallback_fn, *  the library will process the data and then * call the application provided function of type applicationFreeCallback_fn * so that the memory can be discarded of correctly. * * RETURN * This function has no return value.  */typedef void (*applicationFreeCallback_fn)(char *userInput);/* * FUNCTION TYPE: filePathPromptCallback_fn * ---------------------------------------- * INPUTS *    arg *        This is an opaque pointer that is provided to the library *        when the callback is registered.  The library merely passes *        it to the callback so the application can properly handle *        the password prompt. *    prompt *        The text to display to the user when prompting for a file. *    fileRegEx *        This is the regular expression the selected file should  *        satisfy.  These will tend to be of the form *.<extension> *    shouldFileExist *        A flag indicating wheter or not the file selected by the user *        should already exist on disk. * NOTES: * This type defines the prototype for a function used to prompt the user  * for a file.  When the psm server needs to request the path to a file, * ie when doing PKCS-12 restore or backup, it will send an event and  * this a function of this type will ultimately be called.  The implementation * should display the text from the parameter prompt to the user.  The  * fileRegEx is intended as a guide for the types of file the user  * should select.  The application does not have to enforce choosing a file * that matches the regular expression, but is encouraged to relay the * extension type to the user.  If shouldFileExist is a non-zero value, * then the file selected by the user must already exist on disk.  If  * shouldFileExist has a value of zero, then the psm server will create * a file living at the path returned--overwriting any pre-existing files * or creating a new file if no file with the returned path exists. * * RETURN * The function should return a full path to the file the user has selected. * The returned string will be passed to the callback of type  * applicationFreeCallback_fn after the path is no longer needed. */typedef char * (*filePathPromptCallback_fn)(void   *arg,                                            char   *prompt,                                             char   *fileRegEx,                                            CMUint32  shouldFileExist);/* * FUNCTION TYPE: uiHandlerCallback_fn * ----------------------------------- * INPUTS *    resourceID *        The ID of the resource that generated the UI event. *    context *        A pointer that was originally created by a call to  *        uiHandlerCallback_fn.  When non-NULL, this value  *        be used as a map to a previously created window which *        should be the parent of whatever window is created by *        the current call. *    width *        The width of the new window created. *    height *        The height of the new window created. *    url *        The URL to load in the new window. *    data *        An opaque pointer that was passed in when registering your *        UI handler via CMT_SetUIHandler.  the application should *        use the pointer to help it bring up new windows. * * NOTES * This defines the signature of a function called whenever a UI event occurs. * resourceID is the handle of the resource that sent the UI event and  * context is a pointer returned by a previous call the uiHandlerCallback_fn * registered with the control connection.  If non-NULL, context should be * used as the parent window for the window the function creates.  The  * function should then create an http window of size width x height that can  * handle Basic-auth URL's and the psm server will send the data to the newly * created window. * * RETURN * The function should return some pointer that is associated with the * window just created so that a future call to this event handler can * reference a window that was previously created. */typedef void* (*uiHandlerCallback_fn)(CMUint32 resourceID, void* context,                                       CMUint32 width, CMUint32 height,                                       char* url, void* data);/* * These #defines are to be used to fill in the type field for the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -