Fossil

Check-in [570783f7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add initial basic mnemonic encoding support.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dg-codenames
Files: files | file ages | folders
SHA1:570783f795fa98127dbc084218a01703d1c49a32
User & Date: dg 2013-09-04 20:42:08
Context
2013-09-04
20:44
Merge from trunk. check-in: 15090b94 user: dg tags: dg-codenames
20:42
Add initial basic mnemonic encoding support. check-in: 570783f7 user: dg tags: dg-codenames
2013-08-29
20:12
Create new branch named "dg-codenames" check-in: 42ccbaa4 user: dg tags: dg-codenames
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/db.c.

739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
  sqlite3_create_function(
    db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0
  );
  sqlite3_create_function(
    db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0
  );
  if( g.fSqlTrace ) sqlite3_trace(db, db_sql_trace, 0);
  re_add_sql_func(db);
  sqlite3_exec(db, "PRAGMA foreign_keys=OFF;", 0, 0, 0);
  return db;
}


/*
** Detaches the zLabel database.







|







739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
  sqlite3_create_function(
    db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0
  );
  sqlite3_create_function(
    db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0
  );
  if( g.fSqlTrace ) sqlite3_trace(db, db_sql_trace, 0);
  add_sql_func(db);
  sqlite3_exec(db, "PRAGMA foreign_keys=OFF;", 0, 0, 0);
  return db;
}


/*
** Detaches the zLabel database.

Changes to src/main.mk.

73
74
75
76
77
78
79

80
81
82
83
84
85
86
...
183
184
185
186
187
188
189

190
191
192
193
194
195
196
...
292
293
294
295
296
297
298

299
300
301
302
303
304
305
...
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
855
856
857
858
859
860
861






862
863
864
865
866
867
868
...
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
  $(SRCDIR)/main.c \
  $(SRCDIR)/manifest.c \
  $(SRCDIR)/markdown.c \
  $(SRCDIR)/markdown_html.c \
  $(SRCDIR)/md5.c \
  $(SRCDIR)/merge.c \
  $(SRCDIR)/merge3.c \

  $(SRCDIR)/moderate.c \
  $(SRCDIR)/name.c \
  $(SRCDIR)/path.c \
  $(SRCDIR)/pivot.c \
  $(SRCDIR)/popen.c \
  $(SRCDIR)/pqueue.c \
  $(SRCDIR)/printf.c \
................................................................................
  $(OBJDIR)/manifest_.c \
  $(OBJDIR)/markdown_.c \
  $(OBJDIR)/markdown_html_.c \
  $(OBJDIR)/md5_.c \
  $(OBJDIR)/merge_.c \
  $(OBJDIR)/merge3_.c \
  $(OBJDIR)/moderate_.c \

  $(OBJDIR)/name_.c \
  $(OBJDIR)/path_.c \
  $(OBJDIR)/pivot_.c \
  $(OBJDIR)/popen_.c \
  $(OBJDIR)/pqueue_.c \
  $(OBJDIR)/printf_.c \
  $(OBJDIR)/rebuild_.c \
................................................................................
 $(OBJDIR)/manifest.o \
 $(OBJDIR)/markdown.o \
 $(OBJDIR)/markdown_html.o \
 $(OBJDIR)/md5.o \
 $(OBJDIR)/merge.o \
 $(OBJDIR)/merge3.o \
 $(OBJDIR)/moderate.o \

 $(OBJDIR)/name.o \
 $(OBJDIR)/path.o \
 $(OBJDIR)/pivot.o \
 $(OBJDIR)/popen.o \
 $(OBJDIR)/pqueue.o \
 $(OBJDIR)/printf.o \
 $(OBJDIR)/rebuild.o \
................................................................................
clean:	
	rm -rf $(OBJDIR)/* $(APPNAME)


$(OBJDIR)/page_index.h: $(TRANS_SRC) $(OBJDIR)/mkindex
	$(OBJDIR)/mkindex $(TRANS_SRC) >$@
$(OBJDIR)/headers:	$(OBJDIR)/page_index.h $(OBJDIR)/makeheaders $(OBJDIR)/VERSION.h
	$(OBJDIR)/makeheaders  $(OBJDIR)/add_.c:$(OBJDIR)/add.h $(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h $(OBJDIR)/attach_.c:$(OBJDIR)/attach.h $(OBJDIR)/bag_.c:$(OBJDIR)/bag.h $(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h $(OBJDIR)/blob_.c:$(OBJDIR)/blob.h $(OBJDIR)/branch_.c:$(OBJDIR)/branch.h $(OBJDIR)/browse_.c:$(OBJDIR)/browse.h $(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h $(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h $(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h $(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h $(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h $(OBJDIR)/clone_.c:$(OBJDIR)/clone.h $(OBJDIR)/comformat_.c:$(OBJDIR)/comformat.h $(OBJDIR)/configure_.c:$(OBJDIR)/configure.h $(OBJDIR)/content_.c:$(OBJDIR)/content.h $(OBJDIR)/db_.c:$(OBJDIR)/db.h $(OBJDIR)/delta_.c:$(OBJDIR)/delta.h $(OBJDIR)/deltacmd_.c:$(OBJDIR)/deltacmd.h $(OBJDIR)/descendants_.c:$(OBJDIR)/descendants.h $(OBJDIR)/diff_.c:$(OBJDIR)/diff.h $(OBJDIR)/diffcmd_.c:$(OBJDIR)/diffcmd.h $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h $(OBJDIR)/event_.c:$(OBJDIR)/event.h $(OBJDIR)/export_.c:$(OBJDIR)/export.h $(OBJDIR)/file_.c:$(OBJDIR)/file.h $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h $(OBJDIR)/graph_.c:$(OBJDIR)/graph.h $(OBJDIR)/gzip_.c:$(OBJDIR)/gzip.h $(OBJDIR)/http_.c:$(OBJDIR)/http.h $(OBJDIR)/http_socket_.c:$(OBJDIR)/http_socket.h $(OBJDIR)/http_ssl_.c:$(OBJDIR)/http_ssl.h $(OBJDIR)/http_transport_.c:$(OBJDIR)/http_transport.h $(OBJDIR)/import_.c:$(OBJDIR)/import.h $(OBJDIR)/info_.c:$(OBJDIR)/info.h $(OBJDIR)/json_.c:$(OBJDIR)/json.h $(OBJDIR)/json_artifact_.c:$(OBJDIR)/json_artifact.h $(OBJDIR)/json_branch_.c:$(OBJDIR)/json_branch.h $(OBJDIR)/json_config_.c:$(OBJDIR)/json_config.h $(OBJDIR)/json_diff_.c:$(OBJDIR)/json_diff.h $(OBJDIR)/json_dir_.c:$(OBJDIR)/json_dir.h $(OBJDIR)/json_finfo_.c:$(OBJDIR)/json_finfo.h $(OBJDIR)/json_login_.c:$(OBJDIR)/json_login.h $(OBJDIR)/json_query_.c:$(OBJDIR)/json_query.h $(OBJDIR)/json_report_.c:$(OBJDIR)/json_report.h $(OBJDIR)/json_status_.c:$(OBJDIR)/json_status.h $(OBJDIR)/json_tag_.c:$(OBJDIR)/json_tag.h $(OBJDIR)/json_timeline_.c:$(OBJDIR)/json_timeline.h $(OBJDIR)/json_user_.c:$(OBJDIR)/json_user.h $(OBJDIR)/json_wiki_.c:$(OBJDIR)/json_wiki.h $(OBJDIR)/leaf_.c:$(OBJDIR)/leaf.h $(OBJDIR)/login_.c:$(OBJDIR)/login.h $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h $(OBJDIR)/main_.c:$(OBJDIR)/main.h $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h $(OBJDIR)/name_.c:$(OBJDIR)/name.h $(OBJDIR)/path_.c:$(OBJDIR)/path.h $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h $(OBJDIR)/report_.c:$(OBJDIR)/report.h $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h $(OBJDIR)/search_.c:$(OBJDIR)/search.h $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h $(OBJDIR)/sqlcmd_.c:$(OBJDIR)/sqlcmd.h $(OBJDIR)/stash_.c:$(OBJDIR)/stash.h $(OBJDIR)/stat_.c:$(OBJDIR)/stat.h $(OBJDIR)/style_.c:$(OBJDIR)/style.h $(OBJDIR)/sync_.c:$(OBJDIR)/sync.h $(OBJDIR)/tag_.c:$(OBJDIR)/tag.h $(OBJDIR)/tar_.c:$(OBJDIR)/tar.h $(OBJDIR)/th_main_.c:$(OBJDIR)/th_main.h $(OBJDIR)/timeline_.c:$(OBJDIR)/timeline.h $(OBJDIR)/tkt_.c:$(OBJDIR)/tkt.h $(OBJDIR)/tktsetup_.c:$(OBJDIR)/tktsetup.h $(OBJDIR)/undo_.c:$(OBJDIR)/undo.h $(OBJDIR)/unicode_.c:$(OBJDIR)/unicode.h $(OBJDIR)/update_.c:$(OBJDIR)/update.h $(OBJDIR)/url_.c:$(OBJDIR)/url.h $(OBJDIR)/user_.c:$(OBJDIR)/user.h $(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h $(OBJDIR)/util_.c:$(OBJDIR)/util.h $(OBJDIR)/verify_.c:$(OBJDIR)/verify.h $(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h $(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h $(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h $(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h $(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h $(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h $(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h $(OBJDIR)/zip_.c:$(OBJDIR)/zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h $(OBJDIR)/VERSION.h
	touch $(OBJDIR)/headers
$(OBJDIR)/headers: Makefile
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/json_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
Makefile:
$(OBJDIR)/add_.c:	$(SRCDIR)/add.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/add.c >$(OBJDIR)/add_.c

................................................................................
$(OBJDIR)/merge3.h:	$(OBJDIR)/headers
$(OBJDIR)/moderate_.c:	$(SRCDIR)/moderate.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/moderate.c >$(OBJDIR)/moderate_.c

$(OBJDIR)/moderate.o:	$(OBJDIR)/moderate_.c $(OBJDIR)/moderate.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/moderate.o -c $(OBJDIR)/moderate_.c







$(OBJDIR)/moderate.h:	$(OBJDIR)/headers
$(OBJDIR)/name_.c:	$(SRCDIR)/name.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/name.c >$(OBJDIR)/name_.c

$(OBJDIR)/name.o:	$(OBJDIR)/name_.c $(OBJDIR)/name.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/name.o -c $(OBJDIR)/name_.c

................................................................................
$(OBJDIR)/skins.o:	$(OBJDIR)/skins_.c $(OBJDIR)/skins.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/skins.o -c $(OBJDIR)/skins_.c

$(OBJDIR)/skins.h:	$(OBJDIR)/headers
$(OBJDIR)/sqlcmd_.c:	$(SRCDIR)/sqlcmd.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/sqlcmd.c >$(OBJDIR)/sqlcmd_.c

$(OBJDIR)/sqlcmd.o:	$(OBJDIR)/sqlcmd_.c $(OBJDIR)/sqlcmd.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/sqlcmd.o -c $(OBJDIR)/sqlcmd_.c

$(OBJDIR)/sqlcmd.h:	$(OBJDIR)/headers
$(OBJDIR)/stash_.c:	$(SRCDIR)/stash.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/stash.c >$(OBJDIR)/stash_.c

$(OBJDIR)/stash.o:	$(OBJDIR)/stash_.c $(OBJDIR)/stash.h  $(SRCDIR)/config.h







>







 







>







 







>







 







|







 







>
>
>
>
>
>







 







|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
...
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
...
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
...
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
  $(SRCDIR)/main.c \
  $(SRCDIR)/manifest.c \
  $(SRCDIR)/markdown.c \
  $(SRCDIR)/markdown_html.c \
  $(SRCDIR)/md5.c \
  $(SRCDIR)/merge.c \
  $(SRCDIR)/merge3.c \
  $(SRCDIR)/mnemonic.c \
  $(SRCDIR)/moderate.c \
  $(SRCDIR)/name.c \
  $(SRCDIR)/path.c \
  $(SRCDIR)/pivot.c \
  $(SRCDIR)/popen.c \
  $(SRCDIR)/pqueue.c \
  $(SRCDIR)/printf.c \
................................................................................
  $(OBJDIR)/manifest_.c \
  $(OBJDIR)/markdown_.c \
  $(OBJDIR)/markdown_html_.c \
  $(OBJDIR)/md5_.c \
  $(OBJDIR)/merge_.c \
  $(OBJDIR)/merge3_.c \
  $(OBJDIR)/moderate_.c \
  $(OBJDIR)/mnemonic_.c \
  $(OBJDIR)/name_.c \
  $(OBJDIR)/path_.c \
  $(OBJDIR)/pivot_.c \
  $(OBJDIR)/popen_.c \
  $(OBJDIR)/pqueue_.c \
  $(OBJDIR)/printf_.c \
  $(OBJDIR)/rebuild_.c \
................................................................................
 $(OBJDIR)/manifest.o \
 $(OBJDIR)/markdown.o \
 $(OBJDIR)/markdown_html.o \
 $(OBJDIR)/md5.o \
 $(OBJDIR)/merge.o \
 $(OBJDIR)/merge3.o \
 $(OBJDIR)/moderate.o \
 $(OBJDIR)/mnemonic.o \
 $(OBJDIR)/name.o \
 $(OBJDIR)/path.o \
 $(OBJDIR)/pivot.o \
 $(OBJDIR)/popen.o \
 $(OBJDIR)/pqueue.o \
 $(OBJDIR)/printf.o \
 $(OBJDIR)/rebuild.o \
................................................................................
clean:	
	rm -rf $(OBJDIR)/* $(APPNAME)


$(OBJDIR)/page_index.h: $(TRANS_SRC) $(OBJDIR)/mkindex
	$(OBJDIR)/mkindex $(TRANS_SRC) >$@
$(OBJDIR)/headers:	$(OBJDIR)/page_index.h $(OBJDIR)/makeheaders $(OBJDIR)/VERSION.h
	$(OBJDIR)/makeheaders  $(OBJDIR)/add_.c:$(OBJDIR)/add.h $(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h $(OBJDIR)/attach_.c:$(OBJDIR)/attach.h $(OBJDIR)/bag_.c:$(OBJDIR)/bag.h $(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h $(OBJDIR)/blob_.c:$(OBJDIR)/blob.h $(OBJDIR)/branch_.c:$(OBJDIR)/branch.h $(OBJDIR)/browse_.c:$(OBJDIR)/browse.h $(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h $(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h $(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h $(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h $(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h $(OBJDIR)/clone_.c:$(OBJDIR)/clone.h $(OBJDIR)/comformat_.c:$(OBJDIR)/comformat.h $(OBJDIR)/configure_.c:$(OBJDIR)/configure.h $(OBJDIR)/content_.c:$(OBJDIR)/content.h $(OBJDIR)/db_.c:$(OBJDIR)/db.h $(OBJDIR)/delta_.c:$(OBJDIR)/delta.h $(OBJDIR)/deltacmd_.c:$(OBJDIR)/deltacmd.h $(OBJDIR)/descendants_.c:$(OBJDIR)/descendants.h $(OBJDIR)/diff_.c:$(OBJDIR)/diff.h $(OBJDIR)/diffcmd_.c:$(OBJDIR)/diffcmd.h $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h $(OBJDIR)/event_.c:$(OBJDIR)/event.h $(OBJDIR)/export_.c:$(OBJDIR)/export.h $(OBJDIR)/file_.c:$(OBJDIR)/file.h $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h $(OBJDIR)/graph_.c:$(OBJDIR)/graph.h $(OBJDIR)/gzip_.c:$(OBJDIR)/gzip.h $(OBJDIR)/http_.c:$(OBJDIR)/http.h $(OBJDIR)/http_socket_.c:$(OBJDIR)/http_socket.h $(OBJDIR)/http_ssl_.c:$(OBJDIR)/http_ssl.h $(OBJDIR)/http_transport_.c:$(OBJDIR)/http_transport.h $(OBJDIR)/import_.c:$(OBJDIR)/import.h $(OBJDIR)/info_.c:$(OBJDIR)/info.h $(OBJDIR)/json_.c:$(OBJDIR)/json.h $(OBJDIR)/json_artifact_.c:$(OBJDIR)/json_artifact.h $(OBJDIR)/json_branch_.c:$(OBJDIR)/json_branch.h $(OBJDIR)/json_config_.c:$(OBJDIR)/json_config.h $(OBJDIR)/json_diff_.c:$(OBJDIR)/json_diff.h $(OBJDIR)/json_dir_.c:$(OBJDIR)/json_dir.h $(OBJDIR)/json_finfo_.c:$(OBJDIR)/json_finfo.h $(OBJDIR)/json_login_.c:$(OBJDIR)/json_login.h $(OBJDIR)/json_query_.c:$(OBJDIR)/json_query.h $(OBJDIR)/json_report_.c:$(OBJDIR)/json_report.h $(OBJDIR)/json_status_.c:$(OBJDIR)/json_status.h $(OBJDIR)/json_tag_.c:$(OBJDIR)/json_tag.h $(OBJDIR)/json_timeline_.c:$(OBJDIR)/json_timeline.h $(OBJDIR)/json_user_.c:$(OBJDIR)/json_user.h $(OBJDIR)/json_wiki_.c:$(OBJDIR)/json_wiki.h $(OBJDIR)/leaf_.c:$(OBJDIR)/leaf.h $(OBJDIR)/login_.c:$(OBJDIR)/login.h $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h $(OBJDIR)/main_.c:$(OBJDIR)/main.h $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h $(OBJDIR)/mnemonic_.c:$(OBJDIR)/mnemonic.h $(OBJDIR)/name_.c:$(OBJDIR)/name.h $(OBJDIR)/path_.c:$(OBJDIR)/path.h $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h $(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h $(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h $(OBJDIR)/report_.c:$(OBJDIR)/report.h $(OBJDIR)/rss_.c:$(OBJDIR)/rss.h $(OBJDIR)/schema_.c:$(OBJDIR)/schema.h $(OBJDIR)/search_.c:$(OBJDIR)/search.h $(OBJDIR)/setup_.c:$(OBJDIR)/setup.h $(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h $(OBJDIR)/shun_.c:$(OBJDIR)/shun.h $(OBJDIR)/skins_.c:$(OBJDIR)/skins.h $(OBJDIR)/sqlcmd_.c:$(OBJDIR)/sqlcmd.h $(OBJDIR)/stash_.c:$(OBJDIR)/stash.h $(OBJDIR)/stat_.c:$(OBJDIR)/stat.h $(OBJDIR)/style_.c:$(OBJDIR)/style.h $(OBJDIR)/sync_.c:$(OBJDIR)/sync.h $(OBJDIR)/tag_.c:$(OBJDIR)/tag.h $(OBJDIR)/tar_.c:$(OBJDIR)/tar.h $(OBJDIR)/th_main_.c:$(OBJDIR)/th_main.h $(OBJDIR)/timeline_.c:$(OBJDIR)/timeline.h $(OBJDIR)/tkt_.c:$(OBJDIR)/tkt.h $(OBJDIR)/tktsetup_.c:$(OBJDIR)/tktsetup.h $(OBJDIR)/undo_.c:$(OBJDIR)/undo.h $(OBJDIR)/unicode_.c:$(OBJDIR)/unicode.h $(OBJDIR)/update_.c:$(OBJDIR)/update.h $(OBJDIR)/url_.c:$(OBJDIR)/url.h $(OBJDIR)/user_.c:$(OBJDIR)/user.h $(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h $(OBJDIR)/util_.c:$(OBJDIR)/util.h $(OBJDIR)/verify_.c:$(OBJDIR)/verify.h $(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h $(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h $(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h $(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h $(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h $(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h $(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h $(OBJDIR)/zip_.c:$(OBJDIR)/zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h $(OBJDIR)/VERSION.h
	touch $(OBJDIR)/headers
$(OBJDIR)/headers: Makefile
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/json_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
Makefile:
$(OBJDIR)/add_.c:	$(SRCDIR)/add.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/add.c >$(OBJDIR)/add_.c

................................................................................
$(OBJDIR)/merge3.h:	$(OBJDIR)/headers
$(OBJDIR)/moderate_.c:	$(SRCDIR)/moderate.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/moderate.c >$(OBJDIR)/moderate_.c

$(OBJDIR)/moderate.o:	$(OBJDIR)/moderate_.c $(OBJDIR)/moderate.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/moderate.o -c $(OBJDIR)/moderate_.c

$(OBJDIR)/mnemonic_.c:	$(SRCDIR)/mnemonic.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/mnemonic.c >$(OBJDIR)/mnemonic_.c

$(OBJDIR)/mnemonic.o:	$(OBJDIR)/mnemonic_.c $(OBJDIR)/mnemonic.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/mnemonic.o -c $(OBJDIR)/mnemonic_.c

$(OBJDIR)/moderate.h:	$(OBJDIR)/headers
$(OBJDIR)/name_.c:	$(SRCDIR)/name.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/name.c >$(OBJDIR)/name_.c

$(OBJDIR)/name.o:	$(OBJDIR)/name_.c $(OBJDIR)/name.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/name.o -c $(OBJDIR)/name_.c

................................................................................
$(OBJDIR)/skins.o:	$(OBJDIR)/skins_.c $(OBJDIR)/skins.h  $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/skins.o -c $(OBJDIR)/skins_.c

$(OBJDIR)/skins.h:	$(OBJDIR)/headers
$(OBJDIR)/sqlcmd_.c:	$(SRCDIR)/sqlcmd.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/sqlcmd.c >$(OBJDIR)/sqlcmd_.c

$(OBJDIR)/sqlcmd.o:	$(OBJDIR)/sqlcmd_.c $(OBJDIR)/sqlcmd.h $(OBJDIR)/mnemonic.h $(SRCDIR)/config.h
	$(XTCC) -o $(OBJDIR)/sqlcmd.o -c $(OBJDIR)/sqlcmd_.c

$(OBJDIR)/sqlcmd.h:	$(OBJDIR)/headers
$(OBJDIR)/stash_.c:	$(SRCDIR)/stash.c $(OBJDIR)/translate
	$(OBJDIR)/translate $(SRCDIR)/stash.c >$(OBJDIR)/stash_.c

$(OBJDIR)/stash.o:	$(OBJDIR)/stash_.c $(OBJDIR)/stash.h  $(SRCDIR)/config.h

Added src/mnemonic.c.

































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
/*
** Copyright (c) 2008 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)

** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
** merchantability or fitness for a particular purpose.
**
** Author contact information:
**   drh@hwaci.com
**   http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains the code to do mnemonic encoding of commit IDs. The
** wordlist and algorithm is taken from:
**
**   https://github.com/singpolyma/mnemonicode
**
** The original code is MIT licensed, but this code uses a reimplementation
** from scratch anyway.
*/

#include "config.h"
#include "mnemonic.h"

#define MN_BASE 1626
#define MN_REMAINDER 7

static const char* basewordlist[MN_BASE] =
{
  "ACADEMY",  "ACROBAT",  "ACTIVE",   "ACTOR",    "ADAM",     "ADMIRAL",
  "ADRIAN",   "AFRICA",   "AGENDA",   "AGENT",    "AIRLINE",  "AIRPORT",
  "ALADDIN",  "ALARM",    "ALASKA",   "ALBERT",   "ALBINO",   "ALBUM",
  "ALCOHOL",  "ALEX",     "ALGEBRA",  "ALIBI",    "ALICE",    "ALIEN",
  "ALPHA",    "ALPINE",   "AMADEUS",  "AMANDA",   "AMAZON",   "AMBER",
  "AMERICA",  "AMIGO",    "ANALOG",   "ANATOMY",  "ANGEL",    "ANIMAL",
  "ANTENNA",  "ANTONIO",  "APOLLO",   "APRIL",    "ARCHIVE",  "ARCTIC",
  "ARIZONA",  "ARNOLD",   "AROMA",    "ARTHUR",   "ARTIST",   "ASIA",
  "ASPECT",   "ASPIRIN",  "ATHENA",   "ATHLETE",  "ATLAS",    "AUDIO",
  "AUGUST",   "AUSTRIA",  "AXIOM",    "AZTEC",    "BALANCE",  "BALLAD",
  "BANANA",   "BANDIT",   "BANJO",    "BARCODE",  "BARON",    "BASIC",
  "BATTERY",  "BELGIUM",  "BERLIN",   "BERMUDA",  "BERNARD",  "BIKINI",
  "BINARY",   "BINGO",    "BIOLOGY",  "BLOCK",    "BLONDE",   "BONUS",
  "BORIS",    "BOSTON",   "BOXER",    "BRANDY",   "BRAVO",    "BRAZIL",
  "BRONZE",   "BROWN",    "BRUCE",    "BRUNO",    "BURGER",   "BURMA",
  "CABINET",  "CACTUS",   "CAFE",     "CAIRO",    "CAKE",     "CALYPSO",
  "CAMEL",    "CAMERA",   "CAMPUS",   "CANADA",   "CANAL",    "CANNON",
  "CANOE",    "CANTINA",  "CANVAS",   "CANYON",   "CAPITAL",  "CARAMEL",
  "CARAVAN",  "CARBON",   "CARGO",    "CARLO",    "CAROL",    "CARPET",
  "CARTEL",   "CASINO",   "CASTLE",   "CASTRO",   "CATALOG",  "CAVIAR",
  "CECILIA",  "CEMENT",   "CENTER",   "CENTURY",  "CERAMIC",  "CHAMBER",
  "CHANCE",   "CHANGE",   "CHAOS",    "CHARLIE",  "CHARM",    "CHARTER",
  "CHEF",     "CHEMIST",  "CHERRY",   "CHESS",    "CHICAGO",  "CHICKEN",
  "CHIEF",    "CHINA",    "CIGAR",    "CINEMA",   "CIRCUS",   "CITIZEN",
  "CITY",     "CLARA",    "CLASSIC",  "CLAUDIA",  "CLEAN",    "CLIENT",
  "CLIMAX",   "CLINIC",   "CLOCK",    "CLUB",     "COBRA",    "COCONUT",
  "COLA",     "COLLECT",  "COLOMBO",  "COLONY",   "COLOR",    "COMBAT",
  "COMEDY",   "COMET",    "COMMAND",  "COMPACT",  "COMPANY",  "COMPLEX",
  "CONCEPT",  "CONCERT",  "CONNECT",  "CONSUL",   "CONTACT",  "CONTEXT",
  "CONTOUR",  "CONTROL",  "CONVERT",  "COPY",     "CORNER",   "CORONA",
  "CORRECT",  "COSMOS",   "COUPLE",   "COURAGE",  "COWBOY",   "CRAFT",
  "CRASH",    "CREDIT",   "CRICKET",  "CRITIC",   "CROWN",    "CRYSTAL",
  "CUBA",     "CULTURE",  "DALLAS",   "DANCE",    "DANIEL",   "DAVID",
  "DECADE",   "DECIMAL",  "DELIVER",  "DELTA",    "DELUXE",   "DEMAND",
  "DEMO",     "DENMARK",  "DERBY",    "DESIGN",   "DETECT",   "DEVELOP",
  "DIAGRAM",  "DIALOG",   "DIAMOND",  "DIANA",    "DIEGO",    "DIESEL",
  "DIET",     "DIGITAL",  "DILEMMA",  "DIPLOMA",  "DIRECT",   "DISCO",
  "DISNEY",   "DISTANT",  "DOCTOR",   "DOLLAR",   "DOMINIC",  "DOMINO",
  "DONALD",   "DRAGON",   "DRAMA",    "DUBLIN",   "DUET",     "DYNAMIC",
  "EAST",     "ECOLOGY",  "ECONOMY",  "EDGAR",    "EGYPT",    "ELASTIC",
  "ELEGANT",  "ELEMENT",  "ELITE",    "ELVIS",    "EMAIL",    "ENERGY",
  "ENGINE",   "ENGLISH",  "EPISODE",  "EQUATOR",  "ESCORT",   "ETHNIC",
  "EUROPE",   "EVEREST",  "EVIDENT",  "EXACT",    "EXAMPLE",  "EXIT",
  "EXOTIC",   "EXPORT",   "EXPRESS",  "EXTRA",    "FABRIC",   "FACTOR",
  "FALCON",   "FAMILY",   "FANTASY",  "FASHION",  "FIBER",    "FICTION",
  "FIDEL",    "FIESTA",   "FIGURE",   "FILM",     "FILTER",   "FINAL",
  "FINANCE",  "FINISH",   "FINLAND",  "FLASH",    "FLORIDA",  "FLOWER",
  "FLUID",    "FLUTE",    "FOCUS",    "FORD",     "FOREST",   "FORMAL",
  "FORMAT",   "FORMULA",  "FORTUNE",  "FORUM",    "FRAGILE",  "FRANCE",
  "FRANK",    "FRIEND",   "FROZEN",   "FUTURE",   "GABRIEL",  "GALAXY",
  "GALLERY",  "GAMMA",    "GARAGE",   "GARDEN",   "GARLIC",   "GEMINI",
  "GENERAL",  "GENETIC",  "GENIUS",   "GERMANY",  "GLOBAL",   "GLORIA",
  "GOLF",     "GONDOLA",  "GONG",     "GOOD",     "GORDON",   "GORILLA",
  "GRAND",    "GRANITE",  "GRAPH",    "GREEN",    "GROUP",    "GUIDE",
  "GUITAR",   "GURU",     "HAND",     "HAPPY",    "HARBOR",   "HARMONY",
  "HARVARD",  "HAVANA",   "HAWAII",   "HELENA",   "HELLO",    "HENRY",
  "HILTON",   "HISTORY",  "HORIZON",  "HOTEL",    "HUMAN",    "HUMOR",
  "ICON",     "IDEA",     "IGLOO",    "IGOR",     "IMAGE",    "IMPACT",
  "IMPORT",   "INDEX",    "INDIA",    "INDIGO",   "INPUT",    "INSECT",
  "INSTANT",  "IRIS",     "ITALIAN",  "JACKET",   "JACOB",    "JAGUAR",
  "JANET",    "JAPAN",    "JARGON",   "JAZZ",     "JEEP",     "JOHN",
  "JOKER",    "JORDAN",   "JUMBO",    "JUNE",     "JUNGLE",   "JUNIOR",
  "JUPITER",  "KARATE",   "KARMA",    "KAYAK",    "KERMIT",   "KILO",
  "KING",     "KOALA",    "KOREA",    "LABOR",    "LADY",     "LAGOON",
  "LAPTOP",   "LASER",    "LATIN",    "LAVA",     "LECTURE",  "LEFT",
  "LEGAL",    "LEMON",    "LEVEL",    "LEXICON",  "LIBERAL",  "LIBRA",
  "LIMBO",    "LIMIT",    "LINDA",    "LINEAR",   "LION",     "LIQUID",
  "LITER",    "LITTLE",   "LLAMA",    "LOBBY",    "LOBSTER",  "LOCAL",
  "LOGIC",    "LOGO",     "LOLA",     "LONDON",   "LOTUS",    "LUCAS",
  "LUNAR",    "MACHINE",  "MACRO",    "MADAM",    "MADONNA",  "MADRID",
  "MAESTRO",  "MAGIC",    "MAGNET",   "MAGNUM",   "MAJOR",    "MAMA",
  "MAMBO",    "MANAGER",  "MANGO",    "MANILA",   "MARCO",    "MARINA",
  "MARKET",   "MARS",     "MARTIN",   "MARVIN",   "MASTER",   "MATRIX",
  "MAXIMUM",  "MEDIA",    "MEDICAL",  "MEGA",     "MELODY",   "MELON",
  "MEMO",     "MENTAL",   "MENTOR",   "MENU",     "MERCURY",  "MESSAGE",
  "METAL",    "METEOR",   "METER",    "METHOD",   "METRO",    "MEXICO",
  "MIAMI",    "MICRO",    "MILLION",  "MINERAL",  "MINIMUM",  "MINUS",
  "MINUTE",   "MIRACLE",  "MIRAGE",   "MIRANDA",  "MISTER",   "MIXER",
  "MOBILE",   "MODEL",    "MODEM",    "MODERN",   "MODULAR",  "MOMENT",
  "MONACO",   "MONICA",   "MONITOR",  "MONO",     "MONSTER",  "MONTANA",
  "MORGAN",   "MOTEL",    "MOTIF",    "MOTOR",    "MOZART",   "MULTI",
  "MUSEUM",   "MUSIC",    "MUSTANG",  "NATURAL",  "NEON",     "NEPAL",
  "NEPTUNE",  "NERVE",    "NEUTRAL",  "NEVADA",   "NEWS",     "NINJA",
  "NIRVANA",  "NORMAL",   "NOVA",     "NOVEL",    "NUCLEAR",  "NUMERIC",
  "NYLON",    "OASIS",    "OBJECT",   "OBSERVE",  "OCEAN",    "OCTOPUS",
  "OLIVIA",   "OLYMPIC",  "OMEGA",    "OPERA",    "OPTIC",    "OPTIMAL",
  "ORANGE",   "ORBIT",    "ORGANIC",  "ORIENT",   "ORIGIN",   "ORLANDO",
  "OSCAR",    "OXFORD",   "OXYGEN",   "OZONE",    "PABLO",    "PACIFIC",
  "PAGODA",   "PALACE",   "PAMELA",   "PANAMA",   "PANDA",    "PANEL",
  "PANIC",    "PARADOX",  "PARDON",   "PARIS",    "PARKER",   "PARKING",
  "PARODY",   "PARTNER",  "PASSAGE",  "PASSIVE",  "PASTA",    "PASTEL",
  "PATENT",   "PATRIOT",  "PATROL",   "PATRON",   "PEGASUS",  "PELICAN",
  "PENGUIN",  "PEPPER",   "PERCENT",  "PERFECT",  "PERFUME",  "PERIOD",
  "PERMIT",   "PERSON",   "PERU",     "PHONE",    "PHOTO",    "PIANO",
  "PICASSO",  "PICNIC",   "PICTURE",  "PIGMENT",  "PILGRIM",  "PILOT",
  "PIRATE",   "PIXEL",    "PIZZA",    "PLANET",   "PLASMA",   "PLASTER",
  "PLASTIC",  "PLAZA",    "POCKET",   "POEM",     "POETIC",   "POKER",
  "POLARIS",  "POLICE",   "POLITIC",  "POLO",     "POLYGON",  "PONY",
  "POPCORN",  "POPULAR",  "POSTAGE",  "POSTAL",   "PRECISE",  "PREFIX",
  "PREMIUM",  "PRESENT",  "PRICE",    "PRINCE",   "PRINTER",  "PRISM",
  "PRIVATE",  "PRODUCT",  "PROFILE",  "PROGRAM",  "PROJECT",  "PROTECT",
  "PROTON",   "PUBLIC",   "PULSE",    "PUMA",     "PYRAMID",  "QUEEN",
  "RADAR",    "RADIO",    "RANDOM",   "RAPID",    "REBEL",    "RECORD",
  "RECYCLE",  "REFLEX",   "REFORM",   "REGARD",   "REGULAR",  "RELAX",
  "REPORT",   "REPTILE",  "REVERSE",  "RICARDO",  "RINGO",    "RITUAL",
  "ROBERT",   "ROBOT",    "ROCKET",   "RODEO",    "ROMEO",    "ROYAL",
  "RUSSIAN",  "SAFARI",   "SALAD",    "SALAMI",   "SALMON",   "SALON",
  "SALUTE",   "SAMBA",    "SANDRA",   "SANTANA",  "SARDINE",  "SCHOOL",
  "SCREEN",   "SCRIPT",   "SECOND",   "SECRET",   "SECTION",  "SEGMENT",
  "SELECT",   "SEMINAR",  "SENATOR",  "SENIOR",   "SENSOR",   "SERIAL",
  "SERVICE",  "SHERIFF",  "SHOCK",    "SIERRA",   "SIGNAL",   "SILICON",
  "SILVER",   "SIMILAR",  "SIMON",    "SINGLE",   "SIREN",    "SLOGAN",
  "SOCIAL",   "SODA",     "SOLAR",    "SOLID",    "SOLO",     "SONIC",
  "SOVIET",   "SPECIAL",  "SPEED",    "SPIRAL",   "SPIRIT",   "SPORT",
  "STATIC",   "STATION",  "STATUS",   "STEREO",   "STONE",    "STOP",
  "STREET",   "STRONG",   "STUDENT",  "STUDIO",   "STYLE",    "SUBJECT",
  "SULTAN",   "SUPER",    "SUSAN",    "SUSHI",    "SUZUKI",   "SWITCH",
  "SYMBOL",   "SYSTEM",   "TACTIC",   "TAHITI",   "TALENT",   "TANGO",
  "TARZAN",   "TAXI",     "TELEX",    "TEMPO",    "TENNIS",   "TEXAS",
  "TEXTILE",  "THEORY",   "THERMOS",  "TIGER",    "TITANIC",  "TOKYO",
  "TOMATO",   "TOPIC",    "TORNADO",  "TORONTO",  "TORPEDO",  "TOTAL",
  "TOTEM",    "TOURIST",  "TRACTOR",  "TRAFFIC",  "TRANSIT",  "TRAPEZE",
  "TRAVEL",   "TRIBAL",   "TRICK",    "TRIDENT",  "TRILOGY",  "TRIPOD",
  "TROPIC",   "TRUMPET",  "TULIP",    "TUNA",     "TURBO",    "TWIST",
  "ULTRA",    "UNIFORM",  "UNION",    "URANIUM",  "VACUUM",   "VALID",
  "VAMPIRE",  "VANILLA",  "VATICAN",  "VELVET",   "VENTURA",  "VENUS",
  "VERTIGO",  "VETERAN",  "VICTOR",   "VIDEO",    "VIENNA",   "VIKING",
  "VILLAGE",  "VINCENT",  "VIOLET",   "VIOLIN",   "VIRTUAL",  "VIRUS",
  "VISA",     "VISION",   "VISITOR",  "VISUAL",   "VITAMIN",  "VIVA",
  "VOCAL",    "VODKA",    "VOLCANO",  "VOLTAGE",  "VOLUME",   "VOYAGE",
  "WATER",    "WEEKEND",  "WELCOME",  "WESTERN",  "WINDOW",   "WINTER",
  "WIZARD",   "WOLF",     "WORLD",    "XRAY",     "YANKEE",   "YOGA",
  "YOGURT",   "YOYO",     "ZEBRA",    "ZERO",     "ZIGZAG",   "ZIPPER",
  "ZODIAC",   "ZOOM",     "ABRAHAM",  "ACTION",   "ADDRESS",  "ALABAMA",
  "ALFRED",   "ALMOND",   "AMMONIA",  "ANALYZE",  "ANNUAL",   "ANSWER",
  "APPLE",    "ARENA",    "ARMADA",   "ARSENAL",  "ATLANTA",  "ATOMIC",
  "AVENUE",   "AVERAGE",  "BAGEL",    "BAKER",    "BALLET",   "BAMBINO",
  "BAMBOO",   "BARBARA",  "BASKET",   "BAZAAR",   "BENEFIT",  "BICYCLE",
  "BISHOP",   "BLITZ",    "BONJOUR",  "BOTTLE",   "BRIDGE",   "BRITISH",
  "BROTHER",  "BRUSH",    "BUDGET",   "CABARET",  "CADET",    "CANDLE",
  "CAPITAN",  "CAPSULE",  "CAREER",   "CARTOON",  "CHANNEL",  "CHAPTER",
  "CHEESE",   "CIRCLE",   "COBALT",   "COCKPIT",  "COLLEGE",  "COMPASS",
  "COMRADE",  "CONDOR",   "CRIMSON",  "CYCLONE",  "DARWIN",   "DECLARE",
  "DEGREE",   "DELETE",   "DELPHI",   "DENVER",   "DESERT",   "DIVIDE",
  "DOLBY",    "DOMAIN",   "DOMINGO",  "DOUBLE",   "DRINK",    "DRIVER",
  "EAGLE",    "EARTH",    "ECHO",     "ECLIPSE",  "EDITOR",   "EDUCATE",
  "EDWARD",   "EFFECT",   "ELECTRA",  "EMERALD",  "EMOTION",  "EMPIRE",
  "EMPTY",    "ESCAPE",   "ETERNAL",  "EVENING",  "EXHIBIT",  "EXPAND",
  "EXPLORE",  "EXTREME",  "FERRARI",  "FIRST",    "FLAG",     "FOLIO",
  "FORGET",   "FORWARD",  "FREEDOM",  "FRESH",    "FRIDAY",   "FUJI",
  "GALILEO",  "GARCIA",   "GENESIS",  "GOLD",     "GRAVITY",  "HABITAT",
  "HAMLET",   "HARLEM",   "HELIUM",   "HOLIDAY",  "HOUSE",    "HUNTER",
  "IBIZA",    "ICEBERG",  "IMAGINE",  "INFANT",   "ISOTOPE",  "JACKSON",
  "JAMAICA",  "JASMINE",  "JAVA",     "JESSICA",  "JUDO",     "KITCHEN",
  "LAZARUS",  "LETTER",   "LICENSE",  "LITHIUM",  "LOYAL",    "LUCKY",
  "MAGENTA",  "MAILBOX",  "MANUAL",   "MARBLE",   "MARY",     "MAXWELL",
  "MAYOR",    "MILK",     "MONARCH",  "MONDAY",   "MONEY",    "MORNING",
  "MOTHER",   "MYSTERY",  "NATIVE",   "NECTAR",   "NELSON",   "NETWORK",
  "NEXT",     "NIKITA",   "NOBEL",    "NOBODY",   "NOMINAL",  "NORWAY",
  "NOTHING",  "NUMBER",   "OCTOBER",  "OFFICE",   "OLIVER",   "OPINION",
  "OPTION",   "ORDER",    "OUTSIDE",  "PACKAGE",  "PANCAKE",  "PANDORA",
  "PANTHER",  "PAPA",     "PATIENT",  "PATTERN",  "PEDRO",    "PENCIL",
  "PEOPLE",   "PHANTOM",  "PHILIPS",  "PIONEER",  "PLUTO",    "PODIUM",
  "PORTAL",   "POTATO",   "PRIZE",    "PROCESS",  "PROTEIN",  "PROXY",
  "PUMP",     "PUPIL",    "PYTHON",   "QUALITY",  "QUARTER",  "QUIET",
  "RABBIT",   "RADICAL",  "RADIUS",   "RAINBOW",  "RALPH",    "RAMIREZ",
  "RAVIOLI",  "RAYMOND",  "RESPECT",  "RESPOND",  "RESULT",   "RESUME",
  "RETRO",    "RICHARD",  "RIGHT",    "RISK",     "RIVER",    "ROGER",
  "ROMAN",    "RONDO",    "SABRINA",  "SALARY",   "SALSA",    "SAMPLE",
  "SAMUEL",   "SATURN",   "SAVAGE",   "SCARLET",  "SCOOP",    "SCORPIO",
  "SCRATCH",  "SCROLL",   "SECTOR",   "SERPENT",  "SHADOW",   "SHAMPOO",
  "SHARON",   "SHARP",    "SHORT",    "SHRINK",   "SILENCE",  "SILK",
  "SIMPLE",   "SLANG",    "SMART",    "SMOKE",    "SNAKE",    "SOCIETY",
  "SONAR",    "SONATA",   "SOPRANO",  "SOURCE",   "SPARTA",   "SPHERE",
  "SPIDER",   "SPONSOR",  "SPRING",   "ACID",     "ADIOS",    "AGATHA",
  "ALAMO",    "ALERT",    "ALMANAC",  "ALOHA",    "ANDREA",   "ANITA",
  "ARCADE",   "AURORA",   "AVALON",   "BABY",     "BAGGAGE",  "BALLOON",
  "BANK",     "BASIL",    "BEGIN",    "BISCUIT",  "BLUE",     "BOMBAY",
  "BRAIN",    "BRENDA",   "BRIGADE",  "CABLE",    "CARMEN",   "CELLO",
  "CELTIC",   "CHARIOT",  "CHROME",   "CITRUS",   "CIVIL",    "CLOUD",
  "COMMON",   "COMPARE",  "COOL",     "COPPER",   "CORAL",    "CRATER",
  "CUBIC",    "CUPID",    "CYCLE",    "DEPEND",   "DOOR",     "DREAM",
  "DYNASTY",  "EDISON",   "EDITION",  "ENIGMA",   "EQUAL",    "ERIC",
  "EVENT",    "EVITA",    "EXODUS",   "EXTEND",   "FAMOUS",   "FARMER",
  "FOOD",     "FOSSIL",   "FROG",     "FRUIT",    "GENEVA",   "GENTLE",
  "GEORGE",   "GIANT",    "GILBERT",  "GOSSIP",   "GRAM",     "GREEK",
  "GRILLE",   "HAMMER",   "HARVEST",  "HAZARD",   "HEAVEN",   "HERBERT",
  "HEROIC",   "HEXAGON",  "HUSBAND",  "IMMUNE",   "INCA",     "INCH",
  "INITIAL",  "ISABEL",   "IVORY",    "JASON",    "JEROME",   "JOEL",
  "JOSHUA",   "JOURNAL",  "JUDGE",    "JULIET",   "JUMP",     "JUSTICE",
  "KIMONO",   "KINETIC",  "LEONID",   "LIMA",     "MAZE",     "MEDUSA",
  "MEMBER",   "MEMPHIS",  "MICHAEL",  "MIGUEL",   "MILAN",    "MILE",
  "MILLER",   "MIMIC",    "MIMOSA",   "MISSION",  "MONKEY",   "MORAL",
  "MOSES",    "MOUSE",    "NANCY",    "NATASHA",  "NEBULA",   "NICKEL",
  "NINA",     "NOISE",    "ORCHID",   "OREGANO",  "ORIGAMI",  "ORINOCO",
  "ORION",    "OTHELLO",  "PAPER",    "PAPRIKA",  "PRELUDE",  "PREPARE",
  "PRETEND",  "PROFIT",   "PROMISE",  "PROVIDE",  "PUZZLE",   "REMOTE",
  "REPAIR",   "REPLY",    "RIVAL",    "RIVIERA",  "ROBIN",    "ROSE",
  "ROVER",    "RUDOLF",   "SAGA",     "SAHARA",   "SCHOLAR",  "SHELTER",
  "SHIP",     "SHOE",     "SIGMA",    "SISTER",   "SLEEP",    "SMILE",
  "SPAIN",    "SPARK",    "SPLIT",    "SPRAY",    "SQUARE",   "STADIUM",
  "STAR",     "STORM",    "STORY",    "STRANGE",  "STRETCH",  "STUART",
  "SUBWAY",   "SUGAR",    "SULFUR",   "SUMMER",   "SURVIVE",  "SWEET",
  "SWIM",     "TABLE",    "TABOO",    "TARGET",   "TEACHER",  "TELECOM",
  "TEMPLE",   "TIBET",    "TICKET",   "TINA",     "TODAY",    "TOGA",
  "TOMMY",    "TOWER",    "TRIVIAL",  "TUNNEL",   "TURTLE",   "TWIN",
  "UNCLE",    "UNICORN",  "UNIQUE",   "UPDATE",   "VALERY",   "VEGA",
  "VERSION",  "VOODOO",   "WARNING",  "WILLIAM",  "WONDER",   "YEAR",
  "YELLOW",   "YOUNG",    "ABSENT",   "ABSORB",   "ACCENT",   "ALFONSO",
  "ALIAS",    "AMBIENT",  "ANDY",     "ANVIL",    "APPEAR",   "APROPOS",
  "ARCHER",   "ARIEL",    "ARMOR",    "ARROW",    "AUSTIN",   "AVATAR",
  "AXIS",     "BABOON",   "BAHAMA",   "BALI",     "BALSA",    "BAZOOKA",
  "BEACH",    "BEAST",    "BEATLES",  "BEAUTY",   "BEFORE",   "BENNY",
  "BETTY",    "BETWEEN",  "BEYOND",   "BILLY",    "BISON",    "BLAST",
  "BLESS",    "BOGART",   "BONANZA",  "BOOK",     "BORDER",   "BRAVE",
  "BREAD",    "BREAK",    "BROKEN",   "BUCKET",   "BUENOS",   "BUFFALO",
  "BUNDLE",   "BUTTON",   "BUZZER",   "BYTE",     "CAESAR",   "CAMILLA",
  "CANARY",   "CANDID",   "CARROT",   "CAVE",     "CHANT",    "CHILD",
  "CHOICE",   "CHRIS",    "CIPHER",   "CLARION",  "CLARK",    "CLEVER",
  "CLIFF",    "CLONE",    "CONAN",    "CONDUCT",  "CONGO",    "CONTENT",
  "COSTUME",  "COTTON",   "COVER",    "CRACK",    "CURRENT",  "DANUBE",
  "DATA",     "DECIDE",   "DESIRE",   "DETAIL",   "DEXTER",   "DINNER",
  "DISPUTE",  "DONOR",    "DRUID",    "DRUM",     "EASY",     "EDDIE",
  "ENJOY",    "ENRICO",   "EPOXY",    "EROSION",  "EXCEPT",   "EXILE",
  "EXPLAIN",  "FAME",     "FAST",     "FATHER",   "FELIX",    "FIELD",
  "FIONA",    "FIRE",     "FISH",     "FLAME",    "FLEX",     "FLIPPER",
  "FLOAT",    "FLOOD",    "FLOOR",    "FORBID",   "FOREVER",  "FRACTAL",
  "FRAME",    "FREDDIE",  "FRONT",    "FUEL",     "GALLOP",   "GAME",
  "GARBO",    "GATE",     "GIBSON",   "GINGER",   "GIRAFFE",  "GIZMO",
  "GLASS",    "GOBLIN",   "GOPHER",   "GRACE",    "GRAY",     "GREGORY",
  "GRID",     "GRIFFIN",  "GROUND",   "GUEST",    "GUSTAV",   "GYRO",
  "HAIR",     "HALT",     "HARRIS",   "HEART",    "HEAVY",    "HERMAN",
  "HIPPIE",   "HOBBY",    "HONEY",    "HOPE",     "HORSE",    "HOSTEL",
  "HYDRO",    "IMITATE",  "INFO",     "INGRID",   "INSIDE",   "INVENT",
  "INVEST",   "INVITE",   "IRON",     "IVAN",     "JAMES",    "JESTER",
  "JIMMY",    "JOIN",     "JOSEPH",   "JUICE",    "JULIUS",   "JULY",
  "JUSTIN",   "KANSAS",   "KARL",     "KEVIN",    "KIWI",     "LADDER",
  "LAKE",     "LAURA",    "LEARN",    "LEGACY",   "LEGEND",   "LESSON",
  "LIFE",     "LIGHT",    "LIST",     "LOCATE",   "LOPEZ",    "LORENZO",
  "LOVE",     "LUNCH",    "MALTA",    "MAMMAL",   "MARGO",    "MARION",
  "MASK",     "MATCH",    "MAYDAY",   "MEANING",  "MERCY",    "MIDDLE",
  "MIKE",     "MIRROR",   "MODEST",   "MORPH",    "MORRIS",   "NADIA",
  "NATO",     "NAVY",     "NEEDLE",   "NEURON",   "NEVER",    "NEWTON",
  "NICE",     "NIGHT",    "NISSAN",   "NITRO",    "NIXON",    "NORTH",
  "OBERON",   "OCTAVIA",  "OHIO",     "OLGA",     "OPEN",     "OPUS",
  "ORCA",     "OVAL",     "OWNER",    "PAGE",     "PAINT",    "PALMA",
  "PARADE",   "PARENT",   "PAROLE",   "PAUL",     "PEACE",    "PEARL",
  "PERFORM",  "PHOENIX",  "PHRASE",   "PIERRE",   "PINBALL",  "PLACE",
  "PLATE",    "PLATO",    "PLUME",    "POGO",     "POINT",    "POLITE",
  "POLKA",    "PONCHO",   "POWDER",   "PRAGUE",   "PRESS",    "PRESTO",
  "PRETTY",   "PRIME",    "PROMO",    "QUASI",    "QUEST",    "QUICK",
  "QUIZ",     "QUOTA",    "RACE",     "RACHEL",   "RAJA",     "RANGER",
  "REGION",   "REMARK",   "RENT",     "REWARD",   "RHINO",    "RIBBON",
  "RIDER",    "ROAD",     "RODENT",   "ROUND",    "RUBBER",   "RUBY",
  "RUFUS",    "SABINE",   "SADDLE",   "SAILOR",   "SAINT",    "SALT",
  "SATIRE",   "SCALE",    "SCUBA",    "SEASON",   "SECURE",   "SHAKE",
  "SHALLOW",  "SHANNON",  "SHAVE",    "SHELF",    "SHERMAN",  "SHINE",
  "SHIRT",    "SIDE",     "SINATRA",  "SINCERE",  "SIZE",     "SLALOM",
  "SLOW",     "SMALL",    "SNOW",     "SOFIA",    "SONG",     "SOUND",
  "SOUTH",    "SPEECH",   "SPELL",    "SPEND",    "SPOON",    "STAGE",
  "STAMP",    "STAND",    "STATE",    "STELLA",   "STICK",    "STING",
  "STOCK",    "STORE",    "SUNDAY",   "SUNSET",   "SUPPORT",  "SWEDEN",
  "SWING",    "TAPE",     "THINK",    "THOMAS",   "TICTAC",   "TIME",
  "TOAST",    "TOBACCO",  "TONIGHT",  "TORCH",    "TORSO",    "TOUCH",
  "TOYOTA",   "TRADE",    "TRIBUNE",  "TRINITY",  "TRITON",   "TRUCK",
  "TRUST",    "TYPE",     "UNDER",    "UNIT",     "URBAN",    "URGENT",
  "USER",     "VALUE",    "VENDOR",   "VENICE",   "VERONA",   "VIBRATE",
  "VIRGO",    "VISIBLE",  "VISTA",    "VITAL",    "VOICE",    "VORTEX",
  "WAITER",   "WATCH",    "WAVE",     "WEATHER",  "WEDDING",  "WHEEL",
  "WHISKEY",  "WISDOM",   "DEAL",     "NULL",     "NURSE",    "QUEBEC",
  "RESERVE",  "REUNION",  "ROOF",     "SINGER",   "VERBAL",   "AMEN"
};

static const char* extwordlist[MN_REMAINDER] =
{
  "EGO",      "FAX",      "JET",      "JOB",      "RIO",      "SKI",
  "YES"
};

/*
** String comparator which supports both '\0' and ' ' as a terminator
** character.
*/

static int strspacecmp(const char* s1, const char* s2)
{
  int c1, c2;

  do
  {
    c1 = *s1++;
    c2 = *s2++;
    if ((c1 == '\0') || (c2 == ' '))
    {
      if (c1 == ' ')
        c1 = '\0';
      if (c2 == ' ')
        c2 = '\0';
      break;
    }
  }
  while (c1 == c2);

  return c1 - c2;
}

/*
** Look up a word in the base dictionary and return its index; -1 if the word
** is not in the dictionary.
*/

static int baseword_to_index(const char* word)
{
  int i;

  for (i=0; i<sizeof(basewordlist)/sizeof(*basewordlist); i++)
    if (strspacecmp(basewordlist[i], word) == 0)
      return i;

  return -1;
}

/*
** Look up a word by index in the base dictionary and return the string.
*/

static const char* index_to_baseword(int index)
{
  return basewordlist[index];
}

/*
** Look up a word in the extended dictionary and return its index; -1 if the
** word is not in the dictionary.
*/

static int extword_to_index(const char* word)
{
  int i;

  for (i=0; i<sizeof(extwordlist)/sizeof(*extwordlist); i++)
    if (strspacecmp(extwordlist[i], word) == 0)
      return i;

  return -1;
}

/*
** Look up a word by index in the extended dictionary and return the string.
*/

static const char* index_to_extword(int index)
{
  return extwordlist[index];
}

/*
** Encode a hex-character string using mnemonic encoding, writing the
** result into the supplied blob.
*/

int mnemonic_encode(const char* zString, Blob* xBlob)
{
  int stringlen = strlen(zString);
  unsigned int accumulator;
  int charsread;
  int first = 1;

  while (stringlen > 0)
  {
    /* Read up to four bytes worth of digest into the accumulator. */

    {
      int i = sscanf(zString, "%8x%n", &accumulator, &charsread);
      if (i == 0)
        return 0;
      if (i == EOF)
        break;
      if (charsread & 1) /* Ensure we read complete bytes (pairs of chars) */
        return 0;

      zString += charsread;
    }

    /* Insert a leading space, if necessary. */

    if (!first)
      blob_appendf(xBlob, " ");
    first = 0;

    /* Actually do the encoding. */

    {
      switch (charsread)
      {
        /* 24-bit encodings are special. */

        case 6:
          blob_appendf(xBlob, "%s ", index_to_baseword(accumulator % MN_BASE));
          accumulator /= MN_BASE;

          blob_appendf(xBlob, "%s ", index_to_baseword(accumulator % MN_BASE));
          accumulator /= MN_BASE;

          blob_appendf(xBlob, "%s", index_to_extword(accumulator));
          break;

        /* Otherwise, just follow the common pattern. */

        case 8:
          blob_appendf(xBlob, "%s ", index_to_baseword(accumulator % MN_BASE));
          accumulator /= MN_BASE;
          /* fall through */

        case 4:
          blob_appendf(xBlob, "%s ", index_to_baseword(accumulator % MN_BASE));
          accumulator /= MN_BASE;
          /* fall through */

        case 2:
          blob_appendf(xBlob, "%s", index_to_baseword(accumulator));
          break;
      }
    }
  }

  return 1;
}

/*
** Decode a a mnemonic encoded string, writing the resulting hex-character
** string into the supplied blob.
*/

int mnemonic_decode(const char* zString, Blob* xBlob)
{
  const char* word1;
  const char* word2;
  const char* word3;
  const char* p;
  int i;
  unsigned int value;

  do
  {
    word1 = word2 = word3 = NULL;

    /* Read up to three words from the string. */

    word1 = zString;
    p = strchr(zString, ' ');
    if (!p)
      zString = NULL;
    else
    {
      zString = p+1;
      word2 = zString;
      p = strchr(zString, ' ');
      if (!p)
        zString = NULL;
      else
      {
        zString = p+1;
        word3 = zString;
        p = strchr(zString, ' ');
        if (!p)
          zString = NULL;
        else
          zString = p+1;
      }
    }

    if (word1 && !word2 && !word3)
    {
      /* One word means one byte. */

      i = baseword_to_index(word1);
      if (i == -1)
        return 0;

      blob_appendf(xBlob, "%02x", i);
    }
    else if (word1 && word2 && !word3)
    {
      /* Two words means two bytes. */

      i = baseword_to_index(word1);
      if (i == -1)
        return 0;
      value = i;

      i = baseword_to_index(word2);
      if (i == -1)
        return 0;
      value += i*MN_BASE;

      blob_appendf(xBlob, "%04x", value);
    }
    else
    {
      /* Three words means either three or four bytes, depending on what
       * the final word is. */

      i = baseword_to_index(word1);
      if (i == -1)
        return 0;
      value = i;

      i = baseword_to_index(word2);
      if (i == -1)
        return 0;
      value += i*MN_BASE;

      i = baseword_to_index(word3);
      if (i == -1)
      {
        i = extword_to_index(word3);
        if (i == -1)
          return 0;
        value += i*MN_BASE*MN_BASE;
        blob_appendf(xBlob, "%06x", value);
      }
      else
      {
        value += i*MN_BASE*MN_BASE;
        blob_appendf(xBlob, "%08x", value);
      }
    }
  }
  while (zString);

  return 1;
}

/*
** Implementation of the "mnemonic_encode(X)" SQL function.  The argument X
** is an artifact ID prefix (hex characters). It will be mnemonic encoded
** and returned as a string.
*/
static void sqlcmd_mnemonic_encode(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  Blob x;
  const char *zName;
  int rc;
  assert( argc==1 );

  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;

  blob_zero(&x);
  rc = mnemonic_encode(zName, &x);
  if ( rc==0 ){
    sqlite3_result_error(context, "could not mnemonic encode value", -1);
  }else{
    sqlite3_result_text(context, blob_buffer(&x), blob_size(&x),
                                 SQLITE_TRANSIENT);
  }
  blob_reset(&x);
}

/*
** Implementation of the "mnemonic_decode(X)" SQL function.  The argument X
** is an mnemonic encoded artifact ID prefix (a string of words). It will be
** decoded and returned as a string of hex characters.
**
** If the string is not a valid mnemonic encoded value, it is returned
** unchanged.
*/
static void sqlcmd_mnemonic_decode(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  Blob x;
  const char *zName;
  int rc;
  assert( argc==1 );

  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;

  blob_zero(&x);
  rc = mnemonic_decode(zName, &x);
  if ( rc==0 ){
    sqlite3_result_text(context, zName, -1, SQLITE_TRANSIENT);
  }else{
    sqlite3_result_text(context, blob_buffer(&x), blob_size(&x),
                                 SQLITE_TRANSIENT);
  }
  blob_reset(&x);
}

/*
** Add the SQL functions that wrap mnemonic_encode() and mnemonic_decode().
*/

void mnemonic_add_sql_func(sqlite3 *db)
{
  sqlite3_create_function(db, "mnemonic_encode", 1, SQLITE_ANY, 0,
                          sqlcmd_mnemonic_encode, 0, 0);
  sqlite3_create_function(db, "mnemonic_decode", 1, SQLITE_ANY, 0,
                          sqlcmd_mnemonic_decode, 0, 0);
}

Changes to src/shell.c.

3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249


3250

3251

3252
3253
3254
3255
3256
3257
3258
  if( data.zDbFilename==0 ){
#ifndef SQLITE_OMIT_MEMORYDB
    data.zDbFilename = ":memory:";
#else
    fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
    return 1;
#endif
    /***** Begin Fossil Patch *****/
    {
      extern void fossil_open(const char **);
      fossil_open(&data.zDbFilename);
    }
    /***** End Fossil Patch *****/
  }
  data.out = stdout;

  /* Go ahead and open the database file if it already exists.  If the
  ** file does not exist, delay opening it.  This prevents empty database
  ** files from being created if a user mistypes the database name argument
  ** to the sqlite command-line tool.
  */
  if( access(data.zDbFilename, 0)==0 ){


    open_db(&data);

  }


  /* Process the initialization file if there is one.  If no -init option
  ** is given on the command line, look for a file named ~/.sqliterc and
  ** try to process it.
  */
  rc = process_sqliterc(&data,zInitFile);
  if( rc>0 ){







<
<
<
<
|
<
|







|
>
>

>

>







3228
3229
3230
3231
3232
3233
3234




3235

3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
  if( data.zDbFilename==0 ){
#ifndef SQLITE_OMIT_MEMORYDB
    data.zDbFilename = ":memory:";
#else
    fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
    return 1;
#endif




  }


  data.out = stdout;

  /* Go ahead and open the database file if it already exists.  If the
  ** file does not exist, delay opening it.  This prevents empty database
  ** files from being created if a user mistypes the database name argument
  ** to the sqlite command-line tool.
  */
  /***** Begin Fossil Patch *****/
  {
    extern void fossil_open(const char **);
    open_db(&data);
    add_sql_func(data.db);
  }
  /***** End Fossil Patch *****/

  /* Process the initialization file if there is one.  If no -init option
  ** is given on the command line, look for a file named ~/.sqliterc and
  ** try to process it.
  */
  rc = process_sqliterc(&data,zInitFile);
  if( rc>0 ){

Changes to src/sqlcmd.c.

101
102
103
104
105
106
107
108
109
110
111
112

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
  }else{
    sqlite3_result_error(context, "input is not zlib compressed", -1);
  }
}

/*
** This is the "automatic extension" initializer that runs right after
** the connection to the repository database is opened.  Set up the
** database connection to be more useful to the human operator.
*/
static int sqlcmd_autoinit(

  sqlite3 *db,
  const char **pzErrMsg,
  const void *notUsed
){
  sqlite3_create_function(db, "content", 1, SQLITE_ANY, 0,
                          sqlcmd_content, 0, 0);
  sqlite3_create_function(db, "compress", 1, SQLITE_ANY, 0,
                          sqlcmd_compress, 0, 0);
  sqlite3_create_function(db, "decompress", 1, SQLITE_ANY, 0,
                          sqlcmd_decompress, 0, 0);
  re_add_sql_func(db);
  g.repositoryOpen = 1;
  g.db = db;
  return SQLITE_OK;
}


/*
** COMMAND: sqlite3
**
** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
................................................................................
  extern int sqlite3_shell(int, char**);
  db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
  db_close(1);
  sqlite3_shutdown();
  sqlite3_shell(g.argc-1, g.argv+1);
  g.db = 0;
}

/*
** This routine is called by the patched sqlite3 command-line shell in order
** to load the name and database connection for the open Fossil database.
*/
void fossil_open(const char **pzRepoName){
  sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
  *pzRepoName = g.zRepositoryName;
}







|
|
<

<
>
|
<
<








|
<
<







 







<
<
<
<
<
<
<
<
<
101
102
103
104
105
106
107
108
109

110

111
112


113
114
115
116
117
118
119
120
121


122
123
124
125
126
127
128
...
139
140
141
142
143
144
145









    sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
  }else{
    sqlite3_result_error(context, "input is not zlib compressed", -1);
  }
}

/*
** This function adds any SQL functions that we might need during the
** session.

*/

void add_sql_func(
  sqlite3 *db


){
  sqlite3_create_function(db, "content", 1, SQLITE_ANY, 0,
                          sqlcmd_content, 0, 0);
  sqlite3_create_function(db, "compress", 1, SQLITE_ANY, 0,
                          sqlcmd_compress, 0, 0);
  sqlite3_create_function(db, "decompress", 1, SQLITE_ANY, 0,
                          sqlcmd_decompress, 0, 0);
  re_add_sql_func(db);
  mnemonic_add_sql_func(db);


}


/*
** COMMAND: sqlite3
**
** Usage: %fossil sqlite3 ?DATABASE? ?OPTIONS?
................................................................................
  extern int sqlite3_shell(int, char**);
  db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
  db_close(1);
  sqlite3_shutdown();
  sqlite3_shell(g.argc-1, g.argv+1);
  g.db = 0;
}









Changes to src/tkt.c.

1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
        }else{
          eCmd = set;
        }
        if( g.argc==3 ){
          usage("set|change|history TICKETUUID");
        }
        zTktUuid = db_text(0, 
          "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%s*'", g.argv[3]
        );
        if( !zTktUuid ){
          fossil_fatal("unknown ticket: '%s'!",g.argv[3]);
        }
        i=4;
      }else if( strncmp(g.argv[2],"add",n)==0 ){
        eCmd = add;







|







1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
        }else{
          eCmd = set;
        }
        if( g.argc==3 ){
          usage("set|change|history TICKETUUID");
        }
        zTktUuid = db_text(0, 
          "SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB (mnemonic_decode(%Q)||'*')", g.argv[3]
        );
        if( !zTktUuid ){
          fossil_fatal("unknown ticket: '%s'!",g.argv[3]);
        }
        i=4;
      }else if( strncmp(g.argv[2],"add",n)==0 ){
        eCmd = add;