Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch extended-nntp-examples
Excluding Merge-Ins
This is equivalent to a diff from
45c988bdfc
to ca6a84e367
2015-02-26
| | |
19:26 |
|
check-in: 212d1feefe user: andreask tags: trunk
|
2015-02-25
| | |
08:26 |
|
Leaf
check-in: ca6a84e367 user: aku tags: extended-nntp-examples
|
2015-02-24
| | |
23:20 |
|
check-in: 45c988bdfc user: andreask tags: trunk
|
21:19 |
|
check-in: d3be285f5a user: andreask tags: trunk
|
| | |
Changes to examples/nntp/dirstore.
︙ | | |
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
|
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
+
-
-
-
+
+
+
+
+
-
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
#
# The application supports the API expected by 'pullnews' for saving
# and id handling.
# Signature (syntax) of the storage command:
#
# (1) <cmd> last => Returns last id processed.
# (2) <cmd> names => Returns list of all known ids
# (2) <cmd> save <id> => Take message through stdin, and save, mark <id> as last.
# (3) <cmd> save <id> => Take message through stdin, and save, mark <id> as last.
# (4) <cmd> get <id> => Return message <id> through stdout.
# (5) <cmd> has <id> => Return boolean indicating existence of message <id>
#
# Here, <cmd> = dirstore <path-to-archive-directory>
proc main {} {
if {![cmdline]} usage
$::method
}
proc cmdline {} {
global argv directory method saveid
global argv directory method theid theid
if {[llength $argv] < 2} {return 0}
# Retrieve arguments
lassign $argv directory method
if {$method ni {last save get has names}} {return 0}
if {$method eq "save"} {
if {$method in {save get has}} {
if {[llength $argv] != 3} {return 0}
set saveid [lindex $argv 2]
set theid [lindex $argv 2]
} else {
if {[llength $argv] != 2} {return 0}
}
validatedir store $directory
return 1
}
proc validatedir {which path} {
if {![file exists $path]} { stop "$which does not exist: $path" }
if {![file isdirectory $path]} { stop "$which not a file: $path" }
if {![file readable $path]} { stop "$which not readable: $path" }
if {![file writable $path]} { stop "$which not writable: $path" }
}
proc usage {} {
global argv0
puts stderr "$argv0: wrong # args, should be \"$argv0 last|(save <id>)\""
puts stderr "$argv0: wrong # args, should be \"$argv0 <directory> last|names|(save <id>)|(get <id>)\""
exit 1
}
proc stop {text} {
global argv0
puts stderr "$argv0: $text"
exit 1
}
proc last {} {
global directory
if {![file exists $directory/last]} {
set id {}
} else {
set id [string trim [fileutil::cat $directory/last]]
}
puts $id
return
}
proc names {} {
global directory
set ids {}
if {[file exists $directory]} {
foreach id [lsort -dict [glob -nocomplain -directory $directory -tails q*]] {
lappend ids [string range $id 1 end]
}
}
puts [join $ids \n]
return
}
proc save {} {
global directory saveid
global directory theid
set dst [open $directory/current w]
fcopy stdin $dst
close $dst
file rename -force $directory/current $directory/q$saveid
file rename -force $directory/current $directory/q$theid
fileutil::writeFile $directory/last $saveid
fileutil::writeFile $directory/last $theid
return
}
proc get {} {
global directory theid
set src [open $directory/q$theid r]
fcopy $src stdout
close $src
return
}
proc has {} {
global directory theid
puts -nonewline stdout [file exists $directory/q$theid]
return
}
main
exit
|
Added examples/nntp/movenews.