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

📄 mib2c.storage.conf

📁 eCos操作系统源码
💻 CONF
📖 第 1 页 / 共 2 页
字号:
code:	" . eval ("\"$variables{$mib->{type}}{vartest}\"") . "## .conf persistent save Code per table#type:		code-persistent-sectionsprocess:	code-persistent-sectionsskipif:		$mib->{'access'} =~ /NoAccess/code:	    cptr = read_config_store_data($variables{$mib->{type}}{asnType}, cptr, &StorageTmp->$name, &" . eval ("\"$variables{$mib->{type}}{varlenname}\"") . ");## Code code per table#type:		code-var_tableprocesstable:	code-var_tablecode:	/*code:	 * var_$vtable():code:	 *   Handle this table separately from the scalar value case.code:	 *   The workings of this are basically the same as for var_$outputName above.code:	 */code:	unsigned char *code:	var_$vtable(struct variable *vp,code:	    	    oid     *name,code:	    	    size_t  *length,code:	    	    int     exact,code:	    	    size_t  *var_len,code:	    	    WriteMethod **write_method)code:	{code:code:	struct ${vtable}_data *StorageTmp = NULL;code:	code:	  DEBUGMSGTL((\"$outputName\", \"var_$vtable: Entering...  \\n\"));code:	  /* code:	   * this assumes you have registered all your data properlycdoe:	   * with header_complex_add() somewhere before thiscode:	   */code:	  if ((StorageTmp =code:	       header_complex(${vtable}Storage, vp,name,length,exact,code:	                           var_len,write_method)) == NULL)code:	    return NULL;code:	code:	  /* code:	   * this is where we do the value assignments for the mib results.code:	   */code:	  switch(vp->magic) {\n\ncode:	$variables{$vtable}{'code-case-statements'}{'processed'}code:	    default:code:	      ERROR_MSG(\"\");code:	  }code:	  return NULL;code:	}############################################################################# case statement sections############################################################################type:		code-case-statementsprocess:	code-case-statementsskipif:		$mib->{'access'} =~ /NoAccess/code:		    case $NAME:code:		        " . (($mib->{'access'} =~ /ReadWrite|WriteOnly|Create/) ? "*write_method = write_$mib->{label};" : "") . "code:		        *var_len = $variables{$mib->{'type'}}{'sizeofstart'}StorageTmp->$mib->{label}$variables{$mib->{'type'}}{'sizeofend'};code:		        return (u_char *) $variables{$mib->{'type'}}{'storageret'}StorageTmp->$mib->{label};code:		############################################################################# storage structure information############################################################################type:		variable-structure-infoprocess:	variable-structure-infoskipif:		$mib->{'access'} =~ /NoAccess/code:		" . sprintf("#define   %-20s  $count", $NAME) . "code:		" . sprintf("  { %-20s, %-14s, %-6.6s, %s, %d, { %s } },", $NAME, $variables{$mib->{'type'}}{'asnType'}, $accessToUCD{$mib->{'access'}}, "var_$vroutine", $depth-1, $subid) . "############################################################################# write function definition, also appended to the end of the .c file.############################################################################## Header info: declair write functions for set processing#process:	code-write-func-decltype:		code-write-func-declskipif:		$mib->{'access'} !~ /Write|Create/code:		WriteMethod write_$name;## C code#type:		code-write-funcprocess:	code-write-funcskipif:		$mib->{'textualConvention'} eq "RowStatus" || $mib->{'access'} !~ /Write|Create/code:	intcode:	write_$name(int      action,code:	            u_char   *var_val,code:	            u_char   var_val_type,code:	            size_t   var_val_len,code:	            u_char   *statP,code:	            oid      *name,code:	            size_t    name_len)code:	{code:	  static $variables{$mib->{'type'}}{tmpvar} tmpvar;code:	  struct ${vroutine}_data *StorageTmp = NULL;code:	  static size_t tmplen;code:	  size_t newlen=name_len - (sizeof(${outputName}_variables_oid)/sizeof(oid) + $depth - 1);code:code:	  DEBUGMSGTL((\"$outputName\", \"write_$name entering action=%d...  \\n\", action));code:	  if ((StorageTmp =code:	       header_complex(${vroutine}Storage, NULL,code:	                      &name[sizeof(${outputName}_variables_oid)/sizeof(oid) + $depth - 1], code:	                      &newlen, 1, NULL, NULL)) == NULL)code:	      return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */code:	code:	  switch ( action ) {code:	        case RESERVE1:code:	          if (var_val_type != $variables{$mib->{'type'}}{asnType}){code:	              fprintf(stderr, \"write to $name not $variables{$mib->{'type'}}{asnType}\\n\");code:	              return SNMP_ERR_WRONGTYPE;code:	          }code:	          break;code:	code:	        case RESERVE2:code:	             /* memory reseveration, final preparation... */code:	          break;code:	code:	        case FREE:code:	             /* Release any resources that have been allocated */code:	          break;code:	code:	        case ACTION:code:	             /* The variable has been stored in $variables{$mib->{'type'}}{variable} forcode:	             you to use, and you have just been asked to do something withcode:	             it.  Note that anything done here must be reversable in the UNDO case */code:		".eval ("\"$variables{$mib->{type}}{action}\"")."code:	          break;code:	code:	        case UNDO:code:	             /* Back out any changes made in the ACTION case */code:		".eval ("\"$variables{$mib->{type}}{undo}\"")."code:	          break;code:	code:	        case COMMIT:code:	             /* Things are working well, so it's now safe to make the changecode:	             permanently.  Make sure that anything done here can't fail! */code:		".eval ("\"$variables{$mib->{'type'}}{'commit'}\"")."code:	          break;code:	  }code:	  return SNMP_ERR_NOERROR;code:	}code:code:############################################################################# copy memory from varlist############################################################################type:		code-varlist-copyprocess:	code-varlist-copyskipif:		$variables{$vroutine}{$name}{'isanindex'} != 1code:	            memdup((u_char **) &(StorageNew->$name), code:	                   vp->val.$variables{$mib->{'type'}}{variable},code:	                   vp->val_len);code:	            StorageNew->${name}Len = vp->val_len;code:	            vp = vp->next_variable;############################################################################# add null pointers to a varlist; value to be parsed later############################################################################type:		code-varlist-add-nullprocess:	code-varlist-add-nullskipif:		$variables{$vroutine}{$name}{'isanindex'} != 1code:	  	  snmp_varlist_add_variable(&vars, NULL, 0, $variables{$mib->{'type'}}{asnType}, NULL, 0); /* $name */############################################################################# write function definition for a RowStatus object, #   - allows for creation/deletion.############################################################################## Header info: declair write functions for set processing#process:	code-write-rowstatus-decltype:		code-write-rowstatus-declskipif:		$mib->{'textualConvention'} ne "RowStatus"code:		WriteMethod write_$name;## code#type:		code-write-rowstatusprocess:	code-write-rowstatusskipif:		$mib->{'textualConvention'} ne "RowStatus"code:	intcode:	write_$name(int      action,code:	            u_char   *var_val,code:	            u_char   var_val_type,code:	            size_t   var_val_len,code:	            u_char   *statP,code:	            oid      *name,code:	            size_t    name_len)code:	{code:	  struct ${vroutine}_data *StorageTmp = NULL;code:	  static struct ${vroutine}_data *StorageNew, *StorageDel;code:	  size_t newlen=name_len - (sizeof(${vroutine}_variables_oid)/sizeof(oid) + 3 - 1);code:	  static int old_value;code:	  int set_value;code:	  static struct variable_list *vars, *vp;code:	  struct header_complex_index *hciptr;code:	  char who[MAX_OID_LEN], flagName[MAX_OID_LEN];code:	code:	  StorageTmp =code:	    header_complex(${vroutine}Storage, NULL,code:	                   &name[sizeof(${vroutine}_variables_oid)/sizeof(oid) + 3 - 1], code:	                   &newlen, 1, NULL, NULL);code:	  code:	  code:	  if (var_val_type != ASN_INTEGER || var_val == NULL){code:	    fprintf(stderr, \"write to $name not ASN_INTEGER\\n\");code:	    return SNMP_ERR_WRONGTYPE;code:	  }code:	  set_value = *((long *) var_val);code:	code:	  /* check legal range, and notReady is reserved for us, not a user */code:	  if (set_value < 1 || set_value > 6 || set_value == RS_NOTREADY)code:	    return SNMP_ERR_INCONSISTENTVALUE;code:	    code:	  switch ( action ) {code:	        case RESERVE1:code:		  /* stage one: test validity */code:	          if (StorageTmp == NULL) {code:	            /* create the row now? */code:	code:	            /* ditch illegal values now */code:	            if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE)code:	              return SNMP_ERR_INCONSISTENTVALUE;code:	    code:	            /* destroying a non-existent row is actually legal */code:	            if (set_value == RS_DESTROY) {code:	              return SNMP_ERR_NOERROR;code:	            }code:	code:	            /* illegal creation values */code:	            if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE) {code:	              return SNMP_ERR_INCONSISTENTVALUE;code:	            }code:	          } else {code:	            /* row exists.  Check for a valid state change */code:	            if (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT) {code:	              /* can't create a row that exists */code:	              return SNMP_ERR_INCONSISTENTVALUE;code:	            }code:		    /* XXX: interaction with row storage type needed */code:	          }code:	          break;code:	code:	code:	        case RESERVE2:code:	          /* memory reseveration, final preparation... */code:	          if (StorageTmp == NULL) {code:	            /* creation */code:	            vars = NULL;code:	code:	$variables{'code-varlist-add-null'}{'processed'}code:	                    code:	            if (header_complex_parse_oid(&(name[sizeof(${vroutine}_variables_oid)/sizeof(oid)+2]), newlen,code:	                                         vars) != SNMPERR_SUCCESS) {code:	              /* XXX: free, zero vars */code:	              return SNMP_ERR_INCONSISTENTNAME;code:	            }code:	            vp = vars;code:	code:	            StorageNew = SNMP_MALLOC_STRUCT(${vroutine}_data);code:	$variables{'code-varlist-copy'}{'processed'}code:	code:	            StorageNew->$name = set_value;code:	            /* XXX: free, zero vars, no longer needed? */code:	          }code:	          code:	          break;code:	code:	code:	        case FREE:code:	          /* XXX: free, zero vars */code:	          /* Release any resources that have been allocated */code:	          break;code:	code:	code:	        case ACTION:code:	             /* The variable has been stored in set_value for you tocode:	             use, and you have just been asked to do something withcode:	             it.  Note that anything done here must be reversable incode:	             the UNDO case */code:	             code:	             if (StorageTmp == NULL) {code:	               /* row creation, so add it */code:	               if (StorageNew != NULL)code:	                 ${vroutine}_add(StorageNew);code:	               /* XXX: ack, and if it is NULL? */code:	             } else if (set_value != RS_DESTROY) {code:	               /* set the flag? */code:	               old_value = StorageTmp->$name;code:	               StorageTmp->$name = *((long *) var_val);code:	             } else {code:	               /* destroy...  extract it for now */code:	               hciptr =code:	                 header_complex_find_entry(${vroutine}Storage,code:	                                           StorageTmp);code:	               StorageDel =code:	                 header_complex_extract_entry(&${vroutine}Storage,code:	                                              hciptr);code:	             }code:	          break;code:	code:	code:	        case UNDO:code:	             /* Back out any changes made in the ACTION case */code:	             if (StorageTmp == NULL) {code:	               /* row creation, so remove it again */code:	               hciptr =code:	                 header_complex_find_entry(${vroutine}Storage,code:	                                           StorageTmp);code:	               StorageDel =code:	                 header_complex_extract_entry(&${vroutine}Storage,code:	                                              hciptr);code:	               /* XXX: free it */code:	             } else if (StorageDel != NULL) {code:	               /* row deletion, so add it again */code:	               ${vroutine}_add(StorageDel);code:	             } else {code:	               StorageTmp->$name = old_value;code:	             }code:	          break;code:	code:	code:	        case COMMIT:code:	             /* Things are working well, so it's now safe to make the changecode:	             permanently.  Make sure that anything done here can't fail! */code:	          if (StorageDel != NULL) {code:	            StorageDel == 0;code:	            /* XXX: free it, its dead */code:	          }code:	          break;code:	  }code:	  return SNMP_ERR_NOERROR;code:	}code:	

⌨️ 快捷键说明

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