📄 mfd-top.m2c
字号:
@if $m2c_mark_boundary == 1@/** START code generated by $RCSfile$ $Revision: 14170 $ */@end@#include "${name}_interface.h"@foreach $table table@@ include m2c_setup_table.m2i@oid ${context}_oid[] = { $context.uc_OID };int ${context}_oid_size = OID_LENGTH(${context}_oid);@ if "x$m2c_context_reg" ne "x"@ ${context}_registration ${context}_user_context;@ end@void initialize_table_$context(void);void shutdown_table_$context(void);@end@/** * Initializes the $name module */voidinit_$name(void){ DEBUGMSGTL(("verbose:$name:init_$name","called\n")); /* * TODO:300:o: Perform $name one-time module initialization. */ /* * here we initialize all the tables we're planning on supporting */ @foreach $table table@ if (should_init("$context")) initialize_table_$context(); @end@} /* init_$name *//** * Shut-down the $name module (agent is exiting) */voidshutdown_$name(void){ @foreach $table table@ if (should_init("$context")) shutdown_table_$context(); @end@}##########################################################################@foreach $table table@@ include m2c_setup_table.m2i@/** * Initialize the table $context * (Define its contents and how it's structured) */voidinitialize_table_$context(void){ ${context}_registration * user_context; u_long flags; DEBUGMSGTL(("verbose:$context:initialize_table_$context","called\n")); /* * TODO:301:o: Perform $context one-time table initialization. */ /* * TODO:302:o: |->Initialize $context user context * if you'd like to pass in a pointer to some data for this * table, allocate or set it up here. */@ if "$m2c_context_reg" eq "netsnmp_data_list"@ /* * a netsnmp_data_list is a simple way to store void pointers. A simple * string token is used to add, find or remove pointers. */ user_context = netsnmp_create_data_list("$context", NULL, NULL);@ else@ user_context = &${context}_user_context;@ end@ /* * No support for any flags yet, but in the future you would * set any flags here. */ flags = 0; /* * call interface initialization code */ _${context}_initialize_interface(user_context, flags);} /* initialize_table_$context *//** * Shutdown the table $context */voidshutdown_table_$context(void){ /* * call interface shutdown code */ _${context}_shutdown_interface(&${context}_user_context);}########################################################################@ if $m2c_data_init == 1@/** * extra context initialization (eg default values) * * @param rowreq_ctx : row request context * @param user_init_ctx : void pointer for user (parameter to rowreq_ctx_allocate) * * @retval MFD_SUCCESS : no errors * @retval MFD_ERROR : error (context allocate will fail) */int${context}_rowreq_ctx_init(${context}_rowreq_ctx *rowreq_ctx, void *user_init_ctx){ DEBUGMSGTL(("verbose:$context:${context}_rowreq_ctx_init","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:210:o: |-> Perform extra $context rowreq initialization. (eg DEFVALS) */@ foreach $node nonindex@@ include m2c_setup_node.m2i@@ if $node.hasdefval == 0@@ next@@ end@##------------------------------------------------------@ if $node.needlength == 1@ /* * strings and oids are hard to handle automagically. * so all we've got for you is a hint: * * memcpy($m2c_data_item$node, $node.defval, * len($node.defval) * sizeof($m2c_data_itme$node[0]); */@ elsif $node.enums == 1@@ if "$node.perltype" ne "BITS"@@ eval $m2c_tmp_mt = $node.defval@@ foreach $e $v enum@@ include m2c_setup_enum.m2i@@ if $e eq $node.defval@@ eval $m2c_tmp_mt = $m2c_ename@@ end@@ end@ # for each@ end@ # ! bits $m2c_data_item$node = $m2c_tmp_mt;@ elsif ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@ $m2c_data_item$node = $node.defval;@ else@ /** $m2c_data_item$node = $node.defval; */@ end@ @ end@ foreach nonindex return MFD_SUCCESS;} /* ${context}_rowreq_ctx_init *//** * extra context cleanup * */void ${context}_rowreq_ctx_cleanup(${context}_rowreq_ctx *rowreq_ctx){ DEBUGMSGTL(("verbose:$context:${context}_rowreq_ctx_cleanup","called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:211:o: |-> Perform extra $context rowreq cleanup. */} /* ${context}_rowreq_ctx_cleanup */@ end@ // data_init########################################################################@if $m2c_table_persistent == 1@@ include mfd-persistence.m2i@@end@########################################################################/** * pre-request callback * * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error */int${context}_pre_request(${context}_registration * user_context){ DEBUGMSGTL(("verbose:${context}:${context}_pre_request","called\n")); /* * TODO:510:o: Perform $context pre-request actions. */ return MFD_SUCCESS;} /* ${context}_pre_request *//** * post-request callback * * Note: * New rows have been inserted into the container, and * deleted rows have been removed from the container and * released. * * @param user_context * @param rc : MFD_SUCCESS if all requests succeeded * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error (ignored) */int${context}_post_request(${context}_registration * user_context, int rc){ DEBUGMSGTL(("verbose:${context}:${context}_post_request","called\n")); /* * TODO:511:o: Perform $context post-request actions. */@ if $m2c_table_settable@ /* * check to set if any rows were changed. */ if (${context}_dirty_get()) { /* * check if request was successful. If so, this would be * a good place to save data to its persistent store. */ if (MFD_SUCCESS == rc) { /* * save changed rows, if you haven't already */@ if $m2c_table_persistent@ snmp_store(netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE));@ end@ } ${context}_dirty_set(0); /* clear table dirty flag */ }@ end@ return MFD_SUCCESS;} /* ${context}_post_request */@end@ // table########################################################################@if $m2c_create_fewer_files == 1@@ eval $mfd_processing_types = "c"@@ include mfd-data-get.m2c@@ include mfd-data-set.m2c@@else@@ eval $mfd_processing_types = "chi"@@ run mfd-data-get.m2c@@ run mfd-data-set.m2c@@end@########################################################################/** @{ */@if $m2c_mark_boundary == 1@/** END code generated by $RCSfile$ $Revision: 14170 $ */@end@############################################################################## Do support files##########################################################################@run generic-table-constants.m2c@@run mfd-interface.m2c@@run mfd-data-access.m2c@##@run mfd-readme.m2c@##@if $mfd_generate_doxygen == 1@@ run mfd-doxygen.m2c@@end@##@if $mfd_generate_makefile == 1@@ run mfd-makefile.m2m@@end@##@if $mfd_generate_subagent == 1@@ run subagent.m2c@@end@##
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -