From: Stephen D. <sd...@us...> - 2005-04-12 05:09:54
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20543/nsd Modified Files: proc.c Log Message: Add proc info for NsFastGet. Cleanup source code formatting. Index: proc.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/proc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** proc.c 26 Mar 2005 17:42:26 -0000 1.3 --- proc.c 12 Apr 2005 05:09:42 -0000 1.4 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver 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://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * 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://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 31,36 **** * proc.c -- * ! * Support for getting information on procs (thread routines, ! * callbacks, scheduled procs, etc.). */ --- 31,36 ---- * proc.c -- * ! * Support for describing procs and their arguments (thread routines, ! * callbacks, scheduled procs, etc.). */ *************** *** 39,42 **** --- 39,43 ---- #include "nsd.h" + /* * The following struct maintains callback and description for *************** *** 45,80 **** typedef struct Info { ! Ns_ArgProc *proc; ! char *desc; } Info; /* ! * The following struct array defines common procs in nsd. */ ! struct proc { ! void *procAddr; ! char *desc; ! Ns_ArgProc *argProc; ! } procs[] = { ! {(void *) NsTclThread, "ns:tclthread", NsTclThreadArgProc}, ! {(void *) Ns_TclCallbackProc, "ns:tclcallback", Ns_TclCallbackArgProc}, ! {(void *) NsTclSchedProc, "ns:tclschedproc", Ns_TclCallbackArgProc}, ! {(void *) NsTclSockProc, "ns:tclsockcallback", NsTclSockArgProc}, ! {(void *) NsCachePurge, "ns:cachepurge", NsCacheArgProc}, ! {(void *) NsConnThread, "ns:connthread", NsConnArgProc}, ! {(void *) NsTclFilter, "ns:tclfilter", Ns_TclCallbackArgProc}, ! {(void *) NsTclRequest, "ns:tclrequest", Ns_TclCallbackArgProc}, ! {(void *) NsAdpRequest, "ns:adprequest", Ns_StringArgProc}, ! {NULL, NULL, NULL} ! }; /* ! * Static functions defined in this file. */ - static void AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr); static Tcl_HashTable info; /* --- 46,84 ---- typedef struct Info { ! Ns_ArgProc *proc; ! char *desc; } Info; /* ! * Static functions defined in this file. */ ! static void ServerArgProc(Tcl_DString *dsPtr, void *arg); ! static void AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr); /* ! * Static variables defined in this file. */ static Tcl_HashTable info; + struct proc { + void *procAddr; + char *desc; + Ns_ArgProc *argProc; + } procs[] = { + {(void *) NsTclThread, "ns:tclthread", NsTclThreadArgProc}, + {(void *) Ns_TclCallbackProc, "ns:tclcallback", Ns_TclCallbackArgProc}, + {(void *) NsTclSchedProc, "ns:tclschedproc", Ns_TclCallbackArgProc}, + {(void *) NsTclSockProc, "ns:tclsockcallback", NsTclSockArgProc}, + {(void *) NsCachePurge, "ns:cachepurge", NsCacheArgProc}, + {(void *) NsConnThread, "ns:connthread", NsConnArgProc}, + {(void *) NsTclFilter, "ns:tclfilter", Ns_TclCallbackArgProc}, + {(void *) NsTclRequest, "ns:tclrequest", Ns_TclCallbackArgProc}, + {(void *) NsAdpRequest, "ns:adprequest", Ns_StringArgProc}, + {(void *) NsFastGet, "ns:fastget", ServerArgProc}, + {NULL, NULL, NULL} + }; + /* *************** *** 83,93 **** * NsInitProcInfo -- * ! * Initialize the proc info API and default compiled-in callbacks. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- --- 87,97 ---- * NsInitProcInfo -- * ! * Initialize the proc info API and default compiled-in callbacks. * * Results: ! * None. * * Side effects: ! * None. * *---------------------------------------------------------------------- *************** *** 102,108 **** procPtr = procs; while (procPtr->procAddr != NULL) { ! Ns_RegisterProcInfo(procPtr->procAddr, procPtr->desc, ! procPtr->argProc); ! ++procPtr; } } --- 106,112 ---- procPtr = procs; while (procPtr->procAddr != NULL) { ! Ns_RegisterProcInfo(procPtr->procAddr, procPtr->desc, ! procPtr->argProc); ! ++procPtr; } } *************** *** 114,126 **** * Ns_RegisterProcInfo -- * ! * Register a callback to describe the arguments to a proc, ! * e.g., a thread start arg. * * Results: ! * None. * * Side effects: ! * Given argProc will be invoked for given procAddr by ! * Ns_GetProcInfo. * *---------------------------------------------------------------------- --- 118,130 ---- * Ns_RegisterProcInfo -- * ! * Register a proc description and a callback to describe the ! * arguments e.g., a thread start arg. * * Results: ! * None. * * Side effects: ! * Given argProc will be invoked for given procAddr by ! * Ns_GetProcInfo. * *---------------------------------------------------------------------- *************** *** 131,143 **** { Tcl_HashEntry *hPtr; ! Info *iPtr; ! int new; hPtr = Tcl_CreateHashEntry(&info, (char *) procAddr, &new); if (!new) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = ns_malloc(sizeof(Info)); ! Tcl_SetHashValue(hPtr, iPtr); } iPtr->desc = desc; --- 135,147 ---- { Tcl_HashEntry *hPtr; ! Info *iPtr; ! int new; hPtr = Tcl_CreateHashEntry(&info, (char *) procAddr, &new); if (!new) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = ns_malloc(sizeof(Info)); ! Tcl_SetHashValue(hPtr, iPtr); } iPtr->desc = desc; *************** *** 151,162 **** * Ns_GetProcInfo -- * ! * Format a string of information for the given proc ! * and arg, invoking the argProc callback if it exists. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- --- 155,166 ---- * Ns_GetProcInfo -- * ! * Format a string of information for the given proc ! * and arg, invoking the argProc callback if it exists. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- *************** *** 166,188 **** Ns_GetProcInfo(Tcl_DString *dsPtr, void *procAddr, void *arg) { ! Tcl_HashEntry *hPtr; ! Info *iPtr; ! static Info nullInfo = {NULL, NULL}; hPtr = Tcl_FindHashEntry(&info, (char *) procAddr); if (hPtr != NULL) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = &nullInfo; } if (iPtr->desc != NULL) { ! Tcl_DStringAppendElement(dsPtr, iPtr->desc); } else { ! AppendAddr(dsPtr, "p", procAddr); } if (iPtr->proc != NULL) { ! (*iPtr->proc)(dsPtr, arg); } else { ! AppendAddr(dsPtr, "a", arg); } } --- 170,192 ---- Ns_GetProcInfo(Tcl_DString *dsPtr, void *procAddr, void *arg) { ! Tcl_HashEntry *hPtr; ! Info *iPtr; ! static Info nullInfo = {NULL, NULL}; hPtr = Tcl_FindHashEntry(&info, (char *) procAddr); if (hPtr != NULL) { ! iPtr = Tcl_GetHashValue(hPtr); } else { ! iPtr = &nullInfo; } if (iPtr->desc != NULL) { ! Tcl_DStringAppendElement(dsPtr, iPtr->desc); } else { ! AppendAddr(dsPtr, "p", procAddr); } if (iPtr->proc != NULL) { ! (*iPtr->proc)(dsPtr, arg); } else { ! AppendAddr(dsPtr, "a", arg); } } *************** *** 194,198 **** * Ns_StringArgProc -- * ! * Treat arg as cstring and copy to dstring. * * Results: --- 198,202 ---- * Ns_StringArgProc -- * ! * Info callback for procs which take a cstring arg. * * Results: *************** *** 217,229 **** *---------------------------------------------------------------------- * * AppendAddr -- * ! * Format a simple string with the given address. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- --- 221,258 ---- *---------------------------------------------------------------------- * + * ServerArgProc -- + * + * Info callback for procs which take an NsServer arg. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + void + ServerArgProc(Tcl_DString *dsPtr, void *arg) + { + NsServer *servPtr = arg; + + Tcl_DStringAppendElement(dsPtr, servPtr->server); + } + + + /* + *---------------------------------------------------------------------- + * * AppendAddr -- * ! * Format a simple string with the given address. * * Results: ! * None. * * Side effects: ! * String will be appended to given dsPtr. * *---------------------------------------------------------------------- *************** *** 233,243 **** AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr) { ! char buf[30]; ! ! if (addr == NULL) { ! sprintf(buf, "%s:0x0", prefix); ! } else { ! sprintf(buf, "%s:%p", prefix, addr); ! } ! Tcl_DStringAppendElement(dsPtr, buf); } --- 262,265 ---- AppendAddr(Tcl_DString *dsPtr, char *prefix, void *addr) { ! Ns_DStringPrintf(dsPtr, " %s:%p", prefix, addr); } |