View/Edit #4:give_quota

Switch to edit mode.

Name(s): give_quota
1:  "Transfer args[2] bytes and args[3] objects to args[1]"
2:  "returns actual amount transferred."
3:  if (!$perm_utils:controls(caller_perms(), this))
4:    raise(E_PERM)
5:  endif
6:  {to, bytes, objects, dbytes} = args
7:  if (!to:isa($accountable))
8:    raise(E_INVARG, "Don't just give your quota to anyone!")
9:  endif
10: bytes = min(bytes, this:free_bytes())
11: objects = min(objects, this:free_objects())
12: dbytes = min(dbytes, this:free_dbytes())
13: bytes = max(bytes, 0)
14: objects = max(objects, 0)
15: dbytes = max(dbytes, 0)
16: if (!(to_i = $list_utils:iassoc(to, this.quota_contribs)))
17:   this.quota_contribs = {@this.quota_contribs, {to, 0, 0, 0}}
18:   to_i = length(this.quota_contribs)
19: endif
20: if (!(this_i = $list_utils:iassoc(this, to.quota_contribs)))
21:   to.quota_contribs = {@to.quota_contribs, {this, 0, 0, 0}}
22:   this_i = length(to.quota_contribs)
23: endif
24: this.quota_contribs[to_i][2] = this.quota_contribs[to_i][2] + bytes
25: to.quota_contribs[this_i][2] = to.quota_contribs[this_i][2] - bytes
26: this.quota_contribs[to_i][3] = this.quota_contribs[to_i][3] + objects
27: to.quota_contribs[this_i][3] = to.quota_contribs[this_i][3] - objects
28: to.quota_contribs[this_i][4] = to.quota_contribs[this_i][4] - dbytes
29: this.quota_contribs[to_i][4] = this.quota_contribs[to_i][4] + dbytes
30: this.quota_contribs[to_i][2..4] == {0, 0, 0} && (this.quota_contribs = listdelete(this.quota_contribs, to_i))
31: to.quota_contribs[this_i][2..4] == {0, 0, 0} && (to.quota_contribs = listdelete(this.quota_contribs, this_i))
32: return {bytes, objects, dbytes}
33: "This verb previously owned by manta (#7165), and chowned to $slacker upon dewizarding (Sat Aug 17 14:50:04 2002 MDT)."
34: "Last modified by Dax (#789) on Sat Aug 17 14:50:04 2002 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]