591bcac2615be144cb5614e7018d2084499d4186
1 structure PassGen
:> PASSGEN
= struct
6 val db
= ref (NONE
: C
.conn option
)
7 fun getDb () = valOf (!db
)
11 val c
= C
.conn passgenDbstring
14 ignore (C
.dml c
"BEGIN")
29 val id
= case C
.oneRow db
"SELECT nextval('PassSeq')" of
30 [id
] => C
.intFromSql id
31 | _
=> raise Fail
"Bad nextval() return"
33 val proc
= Unix
.execute ("/usr/bin/apg", ["/usr/bin/apg", "-d", "-n", "1"])
34 val inf
= Unix
.textInstreamOf proc
36 val pass
= case TextIO.inputLine inf
of
37 NONE
=> raise Fail
"No apg output"
38 | SOME line
=> String.substring (line
, 0, size line
- 1)
40 ignore (Unix
.reap proc
);
41 ignore (C
.dml
db ($`INSERT INTO
Pass (id
, pass
) VALUES (^
(C
.intToSql id
), ^
(C
.stringToSql pass
))`
));