HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/self/root/proc/thread-self/root/usr/share/doc/m2crypto-0.21.1/demo/medusa/counter.py
# -*- Mode: Python; tab-width: 4 -*-

# It is tempting to add an __int__ method to this class, but it's not
# a good idea.  This class tries to gracefully handle integer
# overflow, and to hide this detail from both the programmer and the
# user.  Note that the __str__ method can be relied on for printing out
# the value of a counter:
#
# >>> print 'Total Client: %s' % self.total_clients
#
# If you need to do arithmetic with the value, then use the 'as_long'
# method, the use of long arithmetic is a reminder that the counter
# will overflow.

class counter:
	"general-purpose counter"

	def __init__ (self, initial_value=0):
		self.value = initial_value
	
	def increment (self, delta=1):
		result = self.value
		try:
			self.value = self.value + delta
		except OverflowError:
			self.value = long(self.value) + delta
		return result

	def decrement (self, delta=1):
		result = self.value
		try:
			self.value = self.value - delta
		except OverflowError:
			self.value = long(self.value) - delta
		return result

	def as_long (self):
		return long(self.value)

	def __nonzero__ (self):
		return self.value != 0

	def __repr__ (self):
		return '<counter value=%s at %x>' % (self.value, id(self))

	def __str__ (self):
		return str(long(self.value))
		#return str(long(self.value))[:-1]