forked from bcosorg/bcos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OwnerNamed.sol
106 lines (86 loc) · 3.16 KB
/
OwnerNamed.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
*@file OwnerNamed.sol
*@author yanze
*@time 2016-11-29
*@desc the defination of OwnerNamed contract
*/
pragma solidity ^0.4.2;
import "LibString.sol";
import "LibInt.sol";
contract OwnerNamed {
using LibString for *;
using LibInt for *;
address owner;
function OwnerNamed() {
owner = msg.sender;
}
function register(string _name, string _version) public {
//rm.register(_name,_version);
}
function kill() public {
if (msg.sender != owner) {
return;
}
}
//test begin
function getOwner() constant public returns (string _ret) {
_ret = owner.addrToAsciiString();
}
function getSender() constant public returns (string _ret) {
_ret = msg.sender.addrToAsciiString();
}
uint errno = 0;
function getErrno() constant returns (uint) {
return errno;
}
/** 日志函数, 内容长度限制为32字符,返回值必须(勿删除) */
function log(string _str) constant public returns(uint) {
log0(bytes32(stringToUint(_str)));
return 0;
}
/** 日志函数, 内容长度限制为32字符,返回值必须(勿删除) */
function log(string _str, string _topic) constant public returns(uint) {
log1(bytes32(stringToUint(_str)), bytes32(stringToUint(_topic)));
return 0;
}
/** 日志函数, 内容长度限制为32字符,返回值必须(勿删除) */
function log(string _str, string _str2, string _topic) constant public returns(uint) {
string memory logStr = "";
logStr = logStr.concat(_str, _str2);
log1(bytes32(stringToUint(logStr)), bytes32(stringToUint(_topic)));
}
/** 日志函数, 内容长度限制为32字符,返回值必须(勿删除) */
function log(string _str, uint _ui) constant public returns(uint) {
string memory logStr = "";
logStr = logStr.concat(_str, _ui.toString());
log0(bytes32(stringToUint(logStr)));
}
/** 日志函数, 内容长度限制为32字符,返回值必须(勿删除) */
function log(string _str, int _i) constant public returns(uint) {
string memory logStr = "";
logStr = logStr.concat(_str, _i.toString());
log0(bytes32(stringToUint(logStr)));
return 0;
}
/** 日志函数, 内容长度限制为32字符,返回值必须(勿删除) */
function log(string _str, address _addr) constant public returns(uint) {
string memory logStr = "";
logStr = logStr.concat(_str, uint(_addr).toAddrString());
log0(bytes32(stringToUint(logStr)));
return 0;
}
/** string convert to uint256 */
function stringToUint(string _str) constant returns(uint _ret) {
uint len = bytes(_str).length;
if (len > 32) {
len = 32;
}
_ret = 0;
for(uint i=0; i<32; ++i) {
if (i < len)
_ret = _ret*256 + uint8(bytes(_str)[i]);
else
_ret = _ret*256;
}
}
}