-currentdir = Dir.pwd+"/"
-$doxywork = currentdir+"doxywork/"
-$srcman3 = currentdir+usr_or_ja+"/man/man3/"
-if usr_or_ja == "usr"
- $dstman3m = currentdir+"/man/man3m/"
-else
- $dstman3m = currentdir+"/man/ja/man3m/"
-end
+#
+# Setting up directory names.
+#
+
+$currentdir = Dir.pwd+"/"
+$srcdir=$currentdir+$*[1]+"/"
+$dstdir=$currentdir+$*[2]+"/"
+$doxywork = $currentdir+"doxywork/"
+$sampledir="sample/man3/"
+
+# fixed text
+
+$headfile = $currentdir+"manhead"
+$footfile = $currentdir+"manfoot"
+
+headbuf = open($headfile, "r").readlines
+footbuf = open($footfile, "r").readlines
+
+#
+# Extra information about header strings Doxygen generates in a man file.
+#
+
+def nextheader(text,index)
+ header = text[index+1..text.size].find{|i| i =~ /\.S(S|H)/}
+ return header
+ end
+
+grouptext = open($sampledir+"SampleGroup.3","r").readlines.reverse
+
+fd = grouptext.index(grouptext.find{|i| i =~ /SampleFunction/})
+$fdheader = nextheader(grouptext,fd)
+
+restofthetext = grouptext[fd+1..grouptext.size]
+
+fl = restofthetext.index(restofthetext.find{|i| i =~ /SampleFunction/})
+$flheader = nextheader(restofthetext,fl)