/* * mod_aolserver aolserver emulation --- Copyright 2000 Robert S. Thau. * This file derived from the actual aolserver code, and is distributed * in accord with its license, as follows: * * 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.lcs.mit.edu/. * * 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 AOLserver Code and related documentation * distributed by AOL. * * The Initial Developer of the Original Code is America Online, * Inc. Portions created by AOL are Copyright (C) 1999 America Online, * Inc. All Rights Reserved. * * Alternatively, the contents of this file may be used under the terms * of the GNU General Public License (the "GPL"), in which case the * provisions of 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 * License, 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 License or the GPL. */ /* * tclcmds.c -- * * Connect Tcl command names to the functions that implement them */ #include "nsd.h" static TclCmd tclCmds[ ] = { /* tclset.c */ { "ns_set", NsTclSetCmd, NULL }, { "ns_parseheader", NsTclParseHeaderCmd, NULL }, /* tclmisc.c */ { "ns_striphtml", NsTclStripHtmlCmd, NULL }, { "ns_crypt", NsTclCryptCmd, NULL }, { "ns_hrefs", NsTclHrefsCmd, NULL }, { "ns_localtime", NsTclLocalTimeCmd }, { "ns_gmtime", NsTclGmTimeCmd }, { "ns_time", NsTclTimeCmd, NULL }, { "ns_fmttime", NsTclStrftimeCmd, NULL }, { "ns_sleep", NsTclSleepCmd, NULL }, { "ns_uuencode", NsTclHTUUEncodeCmd, NULL }, { "ns_uudecode", NsTclHTUUDecodeCmd, NULL }, { "ns_gifsize", NsTclGifSizeCmd, NULL }, { "ns_jpegsize", NsTclJpegSizeCmd, NULL }, /* tclfile.c */ { "ns_unlink", NsTclUnlinkCmd, NULL }, { "ns_mkdir", NsTclMkdirCmd, NULL }, { "ns_rmdir", NsTclRmdirCmd, NULL }, { "ns_cp", NsTclCpCmd, NULL }, { "ns_cpfp", NsTclCpFpCmd, NULL }, { "ns_mktemp", NsTclMkTempCmd, NULL }, { "ns_tmpnam", NsTclTmpNamCmd, NULL }, { "ns_normalizepath", NsTclNormalizePathCmd, NULL }, { "ns_url2file", NsTclUrl2FileCmd, NULL }, { "ns_guesstype", NsTclGuessTypeCmd, NULL }, { "ns_kill", NsTclKillCmd, NULL }, { "ns_link", NsTclLinkCmd, NULL }, { "ns_symlink", NsTclSymlinkCmd, NULL }, { "ns_rename", NsTclRenameCmd, NULL }, { "ns_truncate", NsTclTruncateCmd, NULL }, { "ns_chmod", NsTclChmodCmd, NULL }, /* tclsock.c */ { "ns_hostbyaddr", NsTclGetByCmd, NULL }, { "ns_addrbyhost", NsTclGetByCmd, (ClientData) 1 }, { "ns_sockblocking", NsTclSockSetBlockingCmd, NULL }, { "ns_socknonblocking", NsTclSockSetNonBlockingCmd, NULL }, { "ns_socknread", NsTclSockNReadCmd, NULL }, { "ns_sockcheck", NsTclSockCheckCmd, NULL }, { "ns_sockopen", NsTclSockOpenCmd, NULL }, { "ns_sockselect", NsTclSelectCmd, NULL }, { "ns_puts", NsTclPutsCmd, NULL }, { "ns_adp_puts", NsTclPutsCmd, NULL }, { "ns_adp_dir", NsTclDirCmd, NULL }, { "ns_adp_break", NsTclBreakCmd, (ClientData) ADP_BREAK }, { "ns_adp_return", NsTclBreakCmd, (ClientData) ADP_RETURN }, { "ns_adp_abort", NsTclBreakCmd, (ClientData) ADP_ABORT }, { "ns_adp_exception", NsTclExceptionCmd, NULL }, /* adp.c */ { "ns_adp_argc", NsTclArgcCmd, NULL }, { "ns_adp_argv", NsTclArgvCmd, NULL }, { "ns_adp_bind_args", NsTclBindCmd, NULL }, { "ns_adp_tell", NsTclTellCmd, NULL }, { "ns_adp_trunc", NsTclTruncCmd, NULL }, { "ns_adp_dump", NsTclDumpCmd, NULL }, { "ns_adp_eval", NsTclAdpEvalCmd, NULL }, { "ns_adp_parse", NsTclAdpParseCmd, NULL }, { "ns_adp_stream", NsTclStreamCmd, NULL }, { "ns_adp_debug", NsTclDebugCmd, NULL }, { "ns_adp_mimetype", NsTclAdpMimeCmd, NULL }, /* adpfancy.c */ { "ns_register_adptag", NsTclRegisterTagCmd, NULL }, { "ns_adp_registeradp", NsTclRegisterAdpCmd, NULL }, /* urlencode.c */ { "ns_urlencode", NsTclUrlEncodeCmd, NULL }, { "ns_urldecode", NsTclUrlDecodeCmd, NULL }, /* modlog.c */ { "ns_log", NsTclLogCmd, NULL }, { "ns_modlog", NsTclModLogCmd, NULL }, /* dbtcl.c */ { "ns_db", NsTclDbCmd, NULL }, { "ns_pooldescription", NsTclPoolDescriptionCmd, NULL }, { "ns_dberrorcode", NsTclDbErrorCodeCmd, NULL }, { "ns_dberrormsg", NsTclDbErrorMsgCmd, NULL }, { "ns_quotelisttolist", NsTclQuoteListToListCmd, NULL }, { "ns_getcsv", NsTclGetCsvCmd, NULL }, /* quotehtml.c */ { "ns_quotehtml", NsTclQuoteHtmlCmd, NULL /* Needed */ }, /* random.c --- NOT library reinvention, sadly; they're past 8.0???? */ { "ns_rand", NsTclRandCmd, NULL /* Not used */ }, #ifdef NOTDEF /* Done elsewhere */ { "ns_write", NsTclWriteCmd, NULL }, { "ns_return", NsTclReturnCmd, NULL }, { "ns_conncptofp", NsTclWriteContentCmd, NULL }, { "nsv_array", NsTclVArrayCmd, NULL, /* Partial implementation */ }, { "nsv_get", NsTclVGetCmd, (ClientData) 'g' }, { "nsv_exists", NsTclVGetCmd, (ClientData) 'e' }, { "nsv_set", NsTclVSetCmd, (ClientData) 's' }, { "nsv_unset", NsTclVUnsetCmd, NULL }, #endif #ifdef NOTDEF /* Emulated in tcl */ { "ns_atclose", NsTclAtCloseCmd, NULL /* needed --- http req case only */ }, { "ns_conn", NsTclConnCmd, NULL /* with C support */ }, { "ns_writefp", NsTclWriteFpCmd, NULL }, { "ns_register_filter", NsTclRegisterFilterCmd, NULL }, { "ns_register_proc", NsTclRegisterCmd, NULL }, { "ns_share", NsTclShareCmd, NULL /* partial */ }, { "ns_returnbadrequest", NsTclReturnBadRequestCmd, NULL }, { "ns_returnerror", NsTclReturnErrorCmd, NULL }, { "ns_returnredirect", NsTclReturnRedirectCmd, NULL }, { "ns_connsendfp", NsTclConnSendFpCmd, NULL }, { "ns_checkurl", NsTclRequestAuthorizeCmd, NULL /* stubbed */ }, { "ns_requestauthorize", NsTclRequestAuthorizeCmd, NULL /* stubbed */ }, { "ns_returnfile", NsTclReturnFileCmd, NULL }, { "ns_returnfp", NsTclReturnFpCmd, NULL }, { "ns_modlogcontrol", NsTclModLogControlCmd, NULL }, { "ns_info", NsTclInfoCmd, NULL }, { "ns_parsequery", NsTclParseQueryCmd, NULL }, { "ns_server", NsTclServerCmd, NULL /* Stubbed */ }, { "ns_httptime", NsTclHttpTimeCmd, NULL }, { "ns_config", NsTclConfigCmd, NULL }, { "ns_configsection", NsTclConfigSectionCmd, NULL /* partial --- subsecs not visible */ }, { "ns_configsections", NsTclConfigSectionsCmd, NULL /* incompatible */ }, { "ns_schedule_proc", NsTclSchedCmd, NULL /* Needed */ }, { "ns_schedule_daily", NsTclSchedDailyCmd, NULL /* Needed */ }, { "ns_schedule_weekly", NsTclSchedWeeklyCmd, NULL /* Needed */ }, #endif #ifdef NOTDEF /* Stuff we don't need to implement */ { "ns_dbconfigpath", NsTclDbConfigPathCmd, NULL }, { "ns_atsignal", NsTclAtSignalCmd, NULL /* Not needed */ }, { "ns_atshutdown", NsTclAtShutdownCmd, NULL /* Not needed */ }, { "ns_atexit", NsTclAtExitCmd, NULL /* Not needed */ }, { "ns_after", NsTclAfterCmd, NULL /* Not needed */ }, { "ns_cancel", NsTclCancelCmd, (ClientData) 'c' /* Not needed */ }, { "ns_pause", NsTclCancelCmd, (ClientData) 'p' /* Not needed */ }, { "ns_resume", NsTclCancelCmd, (ClientData) 'r' /* Not needed */ }, { "ns_unschedule_proc", NsTclCancelCmd, (ClientData) 'u' /* Not needed */ }, { "ns_socklisten", NsTclSockListenCmd, NULL /* Not needed */ }, { "ns_sockaccept", NsTclSockAcceptCmd, NULL /* Not needed */ }, { "ns_sockcallback", NsTclSockCallbackCmd, NULL /* Not needed */ }, { "ns_socklistencallback", NsTclSockListenCallbackCmd, NULL /* Not needed */ }, { "ns_socketpair", NsTclSocketPairCmd, NULL /* Not needed */ }, { "ns_register_trace", NsTclRegisterTraceCmd, NULL /* Not needed */ }, { "ns_unregister_proc", NsTclUnRegisterCmd, NULL /* Not needed */ }, { "ns_eval", NsTclEvalCmd, NULL /* Not needed & deprecated */ }, { "ns_respond", NsTclRespondCmd, NULL /* Not needed */ }, { "ns_returnnotice", NsTclReturnNoticeCmd, NULL /* Used by aolserver support tcl which we don't need */ }, { "ns_returnadminnotice", NsTclReturnAdminNoticeCmd, NULL /* Not needed */ }, { "ns_headers", NsTclHeadersCmd, NULL /* Not needed */ }, { "ns_rollfile", NsTclRollFileCmd, (ClientData) "roll" /* Not needed */ }, { "ns_purgefiles", NsTclRollFileCmd, (ClientData) "purge" /* Not needed */ }, { "ns_ftruncate", NsTclFTruncateCmd, NULL /* Not needed */ }, { "ns_getchannels", NsTclGetChannelsCmd, NULL /* Not needed */ }, { "ns_logroll", NsTclLogRollCmd, NULL /* Not needed */ }, { "ns_var", NsTclVarCmd, NULL /* Not needed --- used only in ACS code * that emulates nsv in aolserver 2.x */ }, { "ns_library", NsTclLibraryCmd, NULL /* Not needed --- aolserver admin stuff only */ }, { "ns_writecontent", NsTclWriteContentCmd, NULL /* Not used */ }, { "ns_module", NsTclModuleCmd, NULL /* Not used */ }, { "ns_modulepath", NsTclModulePathCmd, NULL /* Not used */ }, { "ns_parsehttptime", NsTclParseHttpTimeCmd, NULL /* Not used */ }, { "ns_get_multipart_formdata", NsTclGetMultipartFormdataCmd, NULL /* Not used */ }, { "ns_markfordelete", NsTclMarkForDeleteCmd, NULL /* Not used */ }, { "ns_thread", NsTclThreadCmd, NULL /* Not used */ }, { "ns_mutex", NsTclMutexCmd, NULL /* Not used */ }, { "ns_cond", NsTclEventCmd, NULL /* Not used */ }, { "ns_event", NsTclEventCmd, NULL /* Not used */ }, { "ns_rwlock", NsTclRWLockCmd, NULL /* Not used */ }, { "ns_sema", NsTclSemaCmd, NULL /* Not used */ }, { "ns_critsec", NsTclCritSecCmd, NULL /* Not used */ }, { "ns_shutdown", NsTclShutdownCmd, NULL /* Not used */ }, { "ns_cache_flush", NsTclCacheFlushCmd, NULL /* Not used */ }, { "ns_cache_stats", NsTclCacheStatsCmd, NULL /* Not used */ }, { "ns_cache_names", NsTclCacheNamesCmd, NULL /* Not used */ }, { "ns_cache_size", NsTclCacheSizeCmd, NULL /* Not used */ }, /* * tclenv.c */ { "ns_env", NsTclEnvCmd, NULL /* Not used , in either variant */ }, { "env", NsTclEnvCmd, NULL /* NB: Backwards compatible. */ }, /* * tclstats.c */ { "ns_stats", NsTclStatsCmd, NULL /* Not used */ }, /* Unused nsv stuff */ { "nsv_append", NsTclVAppendCmd, (ClientData) 'a' }, { "nsv_lappend", NsTclVAppendCmd, (ClientData) 'l' }, { "nsv_incr", NsTclVIncrCmd, NULL }, /* Db commands unused or implemented in ACS drivers... */ { "ns_column", NsTclUnsupDbCmd, NULL }, { "ns_table", NsTclUnsupDbCmd, NULL }, { "ns_dbreturnerror", NsTclUnsupDbCmd, NULL }, #endif #ifdef NOTDEF /* Hard stuff we still need to handle */ { "ns_geturl", NsTclGetUrlCmd, NULL /* Needed --- ONE use in ACS. * can define in terms of ns_httpopen */ }, #endif /* * add more Tcl commands here */ { NULL, NULL, NULL } }; /* *---------------------------------------------------------------------- * * NsTclCreateCmds -- * * Loop over all the tcl commands in this file and create them. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void NsTclCreateCmds(Tcl_Interp *interp) { struct TclCmd *cmd; #ifdef NOTDEF char *crash; #endif cmd = tclCmds; while (cmd->name != NULL) { Tcl_CreateCommand(interp, cmd->name, cmd->proc, cmd->clientData, NULL); ++cmd; } #ifdef NOTDEF Tcl_CreateCommand(interp, "ns_returnforbidden", NsTclSimpleReturnCmd, (void *) Ns_ConnReturnForbidden, NULL); Tcl_CreateCommand(interp, "ns_returnunauthorized", NsTclSimpleReturnCmd, (void *) Ns_ConnReturnUnauthorized, NULL); Tcl_CreateCommand(interp, "ns_returnnotfound", NsTclSimpleReturnCmd, (void *) Ns_ConnReturnNotFound, NULL); crash = Ns_ConfigGet(NS_CONFIG_PARAMETERS, "CrashCmd"); if (crash != NULL) { Tcl_CreateCommand(interp, crash, NsTclCrashCmd, NULL, NULL); } #endif }